summaryrefslogtreecommitdiff
path: root/lisp/calc
diff options
context:
space:
mode:
authorBastian Beischer <bastian.beischer@rwth-aachen.de>2020-08-11 18:45:01 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2020-08-11 18:45:01 +0200
commite0fa8fef6f45177fa4fa1d9983182471ef765ce7 (patch)
tree531c0946339727d7ec50ea9eb600a76bfaeeeb4d /lisp/calc
parent4d4d3e42caca5d823dd66b62f25a1bdd833ba484 (diff)
downloademacs-e0fa8fef6f45177fa4fa1d9983182471ef765ce7.tar.gz
emacs-e0fa8fef6f45177fa4fa1d9983182471ef765ce7.tar.bz2
emacs-e0fa8fef6f45177fa4fa1d9983182471ef765ce7.zip
Make mouse-2 respect select-enable-primary etc
* lisp/calc/calc-yank.el (calc-yank-internal): Factor out into its own function (bug#23629). (calc-yank): Factored out from here. (calc-yank-mouse-primary): New command to Copyright-paperwork-exempt: yes
Diffstat (limited to 'lisp/calc')
-rw-r--r--lisp/calc/calc-yank.el58
1 files changed, 37 insertions, 21 deletions
diff --git a/lisp/calc/calc-yank.el b/lisp/calc/calc-yank.el
index f5150ca552c..b119f149801 100644
--- a/lisp/calc/calc-yank.el
+++ b/lisp/calc/calc-yank.el
@@ -150,34 +150,16 @@
;; otherwise it just parses the yanked string.
;; Modified to use Emacs 19 extended concept of kill-ring. -- daveg 12/15/96
;;;###autoload
-(defun calc-yank (radix)
- "Yank a value into the Calculator buffer.
-
-Valid numeric prefixes for RADIX: 0, 2, 6, 8
-No radix notation is prepended for any other numeric prefix.
-
-If RADIX is 2, prepend \"2#\" - Binary.
-If RADIX is 8, prepend \"8#\" - Octal.
-If RADIX is 0, prepend \"10#\" - Decimal.
-If RADIX is 6, prepend \"16#\" - Hexadecimal.
+(defun calc-yank-internal (radix thing-raw)
+ "Internal common implementation for yank functions.
-If RADIX is a non-nil list (created using \\[universal-argument]), the user
-will be prompted to enter the radix in the minibuffer.
-
-If RADIX is nil or if the yanked string already has a calc radix prefix, the
-yanked string will be passed on directly to the Calculator buffer without any
-alteration."
- (interactive "P")
+This function is used by both `calc-yank' and `calc-yank-mouse-primary'."
(calc-wrapper
(calc-pop-push-record-list
0 "yank"
(let* (radix-num
radix-notation
valid-num-regexp
- (thing-raw
- (if (fboundp 'current-kill)
- (current-kill 0 t)
- (car kill-ring-yank-pointer)))
(thing
(if (or (null radix)
;; Match examples: -2#10, 10\n(10#10,01)
@@ -232,6 +214,40 @@ alteration."
val))
val))))))))
+;;;###autoload
+(defun calc-yank-mouse-primary (radix)
+ "Yank the current primary selection into the Calculator buffer.
+See `calc-yank' for details about RADIX."
+ (interactive "P")
+ (if (or select-enable-primary
+ select-enable-clipboard)
+ (calc-yank-internal radix (gui-get-primary-selection))
+ ;; Yank from the kill ring.
+ (calc-yank radix)))
+
+;;;###autoload
+(defun calc-yank (radix)
+ "Yank a value into the Calculator buffer.
+
+Valid numeric prefixes for RADIX: 0, 2, 6, 8
+No radix notation is prepended for any other numeric prefix.
+
+If RADIX is 2, prepend \"2#\" - Binary.
+If RADIX is 8, prepend \"8#\" - Octal.
+If RADIX is 0, prepend \"10#\" - Decimal.
+If RADIX is 6, prepend \"16#\" - Hexadecimal.
+
+If RADIX is a non-nil list (created using \\[universal-argument]), the user
+will be prompted to enter the radix in the minibuffer.
+
+If RADIX is nil or if the yanked string already has a calc radix prefix, the
+yanked string will be passed on directly to the Calculator buffer without any
+alteration."
+ (interactive "P")
+ (calc-yank-internal radix (if (fboundp 'current-kill)
+ (current-kill 0 t)
+ (car kill-ring-yank-pointer))))
+
;;; The Calc set- and get-register commands are modified versions of functions
;;; in register.el