I would like F5 to switch to the most recently used buffer. This functionality is accomplished by running M-x icicle-buffer and then hitting enter to not specify the buffer I want to switch to -- (the default behavior of icicle is to switch to the most recent buffer.)
I have tried editing my .emacs thus:
(defun most-recent-buffer-please ()
(interactive)
(icicle-buffer " "))
(global-set-key [(f5)] 'most-recent-buffer-please)
but when I evaluate this lisp, and then hit F5, I get an error that starts with Wrong number of arguments followed by a lot of gibberish characters. What am I doing wrong?
A function can have mandatory and/or optional arguments, or no arguments at all. When writing
elisp, it is usually a good idea to find out what arguments are available for certain functions by typingM-x describe-function RET [name of the function] RET. Drew (the author of Icicles) has indicated in his comment underneath the original question that the functionicicle-bufferis not designed to be used in conjunction with any arguments -- therefore, adding" "causes the error message that the original poster experienced.To switch to the previous buffer, Emacs already has a built-in function called
previous-buffer. Since the original poster has indicated a preference for thef5key, the following is an example of how to configure that keyboard shortcut so that it triggersprevious-buffer-- brackets are sufficient and the parentheses used by the original poster aroundf5can be omitted: