Search code examples
emacsadvising-functionsdefadvice

Warning when I revert from desktop session. Emacs


Yesterday I found desktop mode from EmacsWiki, and then I configure it for my Emacs 24:

;; Desktop
(require 'desktop)

;; save the desktop file automatically if it already exists
(desktop-save-mode 1)

;; use only one desktop
(setq desktop-path '("~/.emacs.d/tmp/"))
(setq desktop-dirname "~/.emacs.d/tmp/")
(setq desktop-base-file-name "desktop.cache")

But I got a warning in *Compile-Log* buffer when I restart Emacs:

Warning: ad-Orig-kill-region called with 3 arguments, but accepts only 2

Anyone else encounter this warning when use desktop? Or, any add-ons else better than desktop-mode?


Solution

  • The ad-Orig- prefix is telling you that the function kill-region is advised. Possibly that advice is causing issues?

    C-hf kill-region RET should tell you the name of the advice; chances are good that it's something in your own config, so I would look for it there firstly.

    See if disabling the advice resolves the problem.

    I do note an oddity with this function in Emacs 24; the source code for kill-region clearly takes an optional third argument, but that *Help* screen mentions only the two required args.

    I checked in Emacs 23, and the help there mentions all three arguments.

    Perhaps there's a bug in Emacs 24 which is responsible for both the discrepancy in the help output, and the error you're seeing?