When I typed C-y
to call yank
, I got this.
apply: Symbol's value as variable is void: n
Debugger entered--Lisp error: (void-variable n)
ad-Advice-current-kill( ... [interprogram-paste-function interprogram-cut-function kill-ring kill-ring-yank-pointer yank-pop-change-selection 0 nil mapc kill-new error "Kill ring is empty" mod] 6 2016971] 0)
apply(ad-Advice-current-kill ... [interprogram-paste-function interprogram-cut-function kill-ring kill-ring-yank-pointer yank-pop-change-selection 0 nil mapc kill-new error "Kill ring is empty" mod] 6 2016971] 0)
current-kill(0)
yank(nil)
call-interactively(yank nil nil)
command-execute(yank)
The '...' in the traceback is messy code.
I have found it's this sentence that caused this error.
(require 'multiple-cursors)
The contents after querying function current-kill
.
current-kill is a compiled Lisp function in `simple.el'.
(current-kill ARG1 &optional ARG2)
:around advice: `ad-Advice-current-kill'
And the contents after pressing ad-Advice-current-kill
.
ad-Advice-current-kill is a compiled Lisp function.
(ad-Advice-current-kill AD--ADDOIT-FUNCTION ARG1 &optional ARG2)
Before-advice `interprogram-paste-for-all-cursors'.
It's really inconvenient that yank can't work. Hoping to solve it quickly, I post the source code for interprogram-paste-for-all-cursors
(defadvice current-kill (before interprogram-paste-for-all-cursors activate)
(let ((interprogram-paste (and (= n 0)
interprogram-paste-function
(funcall interprogram-paste-function))))
(when interprogram-paste
;; Add interprogram-paste to normal kill ring, just
;; like current-kill usually does for itself.
;; We have to do the work for it tho, since the funcall only returns
;; something once. It is not a pure function.
(let ((interprogram-cut-function nil))
(if (listp interprogram-paste)
(mapc 'kill-new (nreverse interprogram-paste))
(kill-new interprogram-paste))
;; And then add interprogram-paste to the kill-rings
;; of all the other cursors too.
(mc/for-each-fake-cursor
(let ((kill-ring (overlay-get cursor 'kill-ring))
(kill-ring-yank-pointer (overlay-get cursor 'kill-ring-yank-pointer)))
(if (listp interprogram-paste)
(mapc 'kill-new (nreverse interprogram-paste))
(kill-new interprogram-paste))
(overlay-put cursor 'kill-ring kill-ring)
(overlay-put cursor 'kill-ring-yank-pointer kill-ring-yank-pointer)))))))
M-x toggle-debug-on-error
to get the backtrace of the error. – wvxvw Nov 28 '16 at 15:02emacs -Q
(no init file)? If yes thenM-x report-emacs-bug
, providing a step-by-step recipe. If no, recursively bisect your init file to find the culprit. – Drew Nov 28 '16 at 15:24yank
works normally. – moyotar Nov 28 '16 at 15:28comment-region
to comment out 1/2, then 3/4, 7/8, 15/16,... until you isolate the problem. It's very quick to do. WithC-u
,comment-region
uncomments the region. – Drew Nov 28 '16 at 15:37C-h f current-kill
it will show you a help page describing where the advice was added. If you then move the point to the link to the advice and pressRET
, it should open the file where this advice was defined. It should be easy to figure out how this code ended up in your init file once you are there. – wvxvw Nov 28 '16 at 16:33multiple-cursors
forinterprogram-paste-for-all-cursors
. That seems to be where there is a reference to an unbound variablen
. A wild guess is that it is a free variable in a lambda form, and for some reason the file is not using lexical scope. If you cannot find or figure out what to do, consider sending a bug report to the maintainer of that library. – Drew Nov 28 '16 at 19:09interprogram-paste-for-all-cursors
– moyotar Nov 29 '16 at 08:41defadvice
form that probably changed recently. Since this advise specifiesactivate
flag (no idea what it's for), it might have been interpreted as arguments. Hence, try making it all explicit: copy the arguments fromcurrent-kill
plusfirst
(for position) beforeactivate
and see if it works. – wvxvw Nov 29 '16 at 13:56(defadvice current-kill (before interprogram-paste-for-all-cursors (n &optional do-not-move) first activate)
. – wvxvw Nov 30 '16 at 08:32