Reputation: 622
I'm new to emacs and newer to lisp
I'm trying to set Meta + spacebar to set the mark for highlighting text (at current cursor position). searching around online and experimenting I've ended up with the command
(global-set-key (kbd "M-SPC") 'push-mark nil nil 1)
The above command isn't working for me though, I'm getting an "incorrect number of arguments error".
Got the function definition,
How would I format the command to pass in three values?
The error is definitely due to the push-mark function call as other functions such as backward-char (which I'm not passing inputs to) work correctly
Upvotes: 1
Views: 98
Reputation: 30708
To add a bit to what @phils says:
push-mark
is not a command: its definition has no interactive
spec. Note that phils's example includes (interactive)
in the anonymous function, making it a command.
Unlike push-mark
, push-mark-command
, as its name suggests, is a command. If you want the effect of push-mark
then just bind push-mark-command
, or better yet set-mark-command
.
Upvotes: 2
Reputation: 73345
As C-hf global-set-key
RET tells you, global-set-key
takes two arguments: (global-set-key KEY COMMAND)
You're passing five arguments: (global-set-key (kbd "M-SPC") 'push-mark nil nil 1)
Hence "wrong number of arguments".
You can either supply the symbol for a named function, or an anonymous function / lambda.
e.g.: (global-set-key (kbd "M-SPC") (lambda () (interactive) (push-mark nil nil 1)))
Upvotes: 2