GNU bug report logs - #18469
24.4.50; quick-calc: Insert result into the current buffer

Previous Next

Package: emacs;

Reported by: Christopher Schmidt <ch <at> ristopher.com>

Date: Sat, 13 Sep 2014 18:42:02 UTC

Severity: wishlist

Found in version 24.4.50

Done: Jay Belanger <jay.p.belanger <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Christopher Schmidt <ch <at> ristopher.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.4.50; quick-calc: Insert result into the current buffer
Date: Sat, 13 Sep 2014 14:40:54 -0400 (EDT)
[Message part 1 (text/plain, inline)]
severity: wishlist

There is this nifty feature of quick-calc (C-x * q):

    (info "(calc)Quick Calculator")

    If you finish your formula by typing <LFD> (or `C-j') instead of
    <RET>, the result is inserted immediately into the current buffer
    rather than going into the kill ring.

This should be mentioned in the doc string.

In fact, considering that inserting the result of a quick calculation
into the current is an elementary use case, quick-calc's prefix arg
should be dedicated to enabling this feature.

[Message part 2 (text/x-diff, inline)]
--- doc/misc/ChangeLog
+++ doc/misc/ChangeLog
@@ -1,3 +1,8 @@
+2014-09-13  Christopher Schmidt  <ch <at> ristopher.com>
+
+	* calc.texi (Quick Calculator):
+	Mention prefix argument of `quick-calc'.  (Bug#)
+
 2014-09-04  Paul Eggert  <eggert <at> cs.ucla.edu>
 
 	Less chatter in 'make' output.
--- doc/misc/calc.texi
+++ doc/misc/calc.texi
@@ -10168,9 +10168,10 @@
 explicit alternative to @kbd{$} notation, or to yank the result
 into the Calculator stack after typing @kbd{C-x * c}.
 
-If you finish your formula by typing @key{LFD} (or @kbd{C-j}) instead
-of @key{RET}, the result is inserted immediately into the current
-buffer rather than going into the kill ring.
+If you give a prefix argument to @kbd{C-x * q} or finish your formula
+by typing @key{LFD} (or @kbd{C-j}) instead of @key{RET}, the result is
+inserted immediately into the current buffer rather than going into
+the kill ring.
 
 Quick Calculator results are actually evaluated as if by the @kbd{=}
 key (which replaces variable names by their stored values, if any).
--- etc/ChangeLog
+++ etc/ChangeLog
@@ -1,5 +1,7 @@
 2014-09-13  Christopher Schmidt  <ch <at> ristopher.com>
 
+	* NEWS: Mention prefix argument of `quick-calc'.  (Bug#)
+
 	* NEWS: Mention nil `calendar-mode-line-format' will not modify
 	the mode line of the calendar buffer.  (Bug#18467)
 
--- etc/NEWS
+++ etc/NEWS
@@ -116,6 +116,11 @@
 ** Macro `minibuffer-with-setup-hook' takes (:append FUN) to mean
 appending FUN to `minibuffer-setup-hook'.
 
+** Calc
+
+*** If `quick-calc' is called with a prefix argument, insert the
+result of the calculation into the current buffer.
+
 ** Calendar and diary
 
 +++
--- lisp/ChangeLog
+++ lisp/ChangeLog
@@ -1,5 +1,9 @@
 2014-09-13  Christopher Schmidt  <ch <at> ristopher.com>
 
+	* calc/calc.el (quick-calc):
+	* calc/calc-aent.el (calc-do-quick-calc):
+	New argument INSERT.  (Bug#)
+
 	* calendar/calendar.el (calendar-update-mode-line):
 	Do not overwrite mode-line-format if calendar-mode-line-format is
 	nil.  (Bug#18467)
--- lisp/calc/calc-aent.el
+++ lisp/calc/calc-aent.el
@@ -52,7 +52,8 @@
   "The history list for quick-calc.")
 
 ;;;###autoload
-(defun calc-do-quick-calc ()
+(defun calc-do-quick-calc (&optional insert)
+  (interactive "P")
   (require 'calc-ext)
   (calc-check-defines)
   (if (eq major-mode 'calc-mode)
@@ -108,7 +109,8 @@
 		    (setq buf long))))
 	  (calc-handle-whys)
 	  (message "Result: %s" buf)))
-      (if (eq last-command-event 10)
+      (if (or insert
+	      (eq last-command-event 10))
 	  (insert shortbuf)
         (kill-new shortbuf)))))
 
--- lisp/calc/calc.el
+++ lisp/calc/calc.el
@@ -147,7 +147,7 @@
 (declare-function calc-edit-finish "calc-yank" (&optional keep))
 (declare-function calc-edit-cancel "calc-yank" ())
 (declare-function calc-locate-cursor-element "calc-yank" (pt))
-(declare-function calc-do-quick-calc "calc-aent" ())
+(declare-function calc-do-quick-calc "calc-aent" (&optional insert))
 (declare-function calc-do-calc-eval "calc-aent" (str separator args))
 (declare-function calc-do-keypad "calc-keypd" (&optional full-display interactive))
 (declare-function calcFunc-unixtime "calc-forms" (date &optional zone))
@@ -1549,10 +1549,12 @@
         (and kbuf (bury-buffer kbuf))))))
 
 ;;;###autoload
-(defun quick-calc ()
-  "Do a quick calculation in the minibuffer without invoking full Calculator."
-  (interactive)
-  (calc-do-quick-calc))
+(defun quick-calc (&optional insert)
+  "Do a quick calculation in the minibuffer without invoking full Calculator.
+With prefix argument INSERT, insert the result in the current
+buffer.  Otherwise, the result is copied into the kill ring."
+  (interactive "P")
+  (calc-do-quick-calc insert))
 
 ;;;###autoload
 (defun calc-eval (str &optional separator &rest args)

This bug report was last modified 10 years and 269 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.