Function: calc-yank-internal
calc-yank-internal is an autoloaded and byte-compiled function defined
in calc-yank.el.gz.
Signature
(calc-yank-internal RADIX THING-RAW)
Documentation
Internal common implementation for yank functions.
This function is used by both calc-yank and calc-yank-mouse-primary.
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calc-yank.el.gz
;; This function uses calc-last-kill if possible to get an exact result,
;; otherwise it just parses the yanked string.
;;;###autoload
(defun calc-yank-internal (radix thing-raw)
"Internal common implementation for yank functions.
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
(if (or (null radix)
;; Match examples: -2#10, 10\n(10#10,01)
(string-match-p "^[-(]*[0-9]\\{1,2\\}#" thing-raw))
thing-raw
(progn
(if (listp radix)
(progn
(setq radix-num
(read-number
"Set radix for yanked content (2-36): "))
(when (not (and (integerp radix-num)
(<= 2 radix-num)
(>= 36 radix-num)))
(error (concat "The radix has to be an "
"integer between 2 and 36."))))
(setq radix-num
(cond ((eq radix 2) 2)
((eq radix 8) 8)
((eq radix 0) 10)
((eq radix 6) 16)
(t (message
(concat "No radix prepended "
"for invalid *numeric* "
"prefix %0d.")
radix)
nil))))
(if radix-num
(progn
(setq radix-notation
(concat (number-to-string radix-num) "#"))
(setq valid-num-regexp
(math-number-regexp radix-num))
;; Ensure that the radix-notation is prefixed
;; correctly even for multi-line yanks like below,
;; 111
;; 1111
(replace-regexp-in-string
valid-num-regexp
(concat radix-notation "\\&")
thing-raw))
thing-raw)))))
(if (eq (car-safe calc-last-kill) thing-raw)
(cdr calc-last-kill)
(if (stringp thing)
(let ((val (math-read-exprs (calc-clean-newlines thing))))
(if (eq (car-safe val) 'error)
(progn
(setq val (math-read-exprs thing))
(if (eq (car-safe val) 'error)
(error "Bad format in yanked data")
val))
val))))))))