[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 26.1 emacs-mac 7.2; map key to interactive lisp function (command) w

From: Van L
Subject: Re: 26.1 emacs-mac 7.2; map key to interactive lisp function (command) with an argument
Date: Mon, 22 Oct 2018 10:00:27 +1100

Thank you so much Eli, Michael.

│ the general form is
│  (global-set-key KEY COMMAND)
│ where COMMAND is a _symbol_, like this:
│  (global-set-key (kbd "C-c o") 'foo)
│ So you need to define an interactive function named SOMETHING:
│  (defun SOMETHING (...)
│    (interactive)
│    ...)
│ then bind it to a key:
│  (global-set-key (kbd "C-c o") 'SOMETHING)

│  1  (defun set-face-height (number)
│  2    "Face height is set to NUMBER."
│  3    (interactive "nInsert number: ")
│  4    (set-face-attribute 'default (selected-frame) :height number))
│  5  
│  6  (defun set-face-height-202 ()
│  7    "Set height of face to 202"
│  8    (interactive)
│  9    (set-face-attribute 'default (selected-frame) :height 202))
│ 10  (global-set-key (kbd "C-c o") 'set-face-height-202)
│ 11  
│ 12  (defun set-face-height-256 ()
│ 13    "Set height of face to 256"
│ 14    (interactive)
│ 15    (set-face-attribute 'default (selected-frame) :height 256))
│ 16  (global-set-key (kbd "C-c O") 'set-face-height-256)

At the outset my goal was to get rid of lines 6 to 9, 12 to 15.

To do that is to call a function with an argument in the place of

I hit the documentation as follows:

  1) (info "(elisp) Calling Functions")
     - experiment with funcall and fail
  2) (info "(elisp) Interactive Call")
     - experiment with funcall-interactively and fail

Along the way I came across two mentions of what a COMMAND is. 

The errors I got mentioned “commandp”.

I didn't lookup global-set-key (lazily) believing I needed a list decorated the 
right-way to slot in the
context given by 'SOMETHING, which I understand to be a quote or
'(quoted list).

  COMMAND is the command definition to use; usually it is
  a symbol naming an interactively-callable function.

  [ I am going to read that as follows: In use the COMMAND is usually
    a symbol naming an interactive function which is called. ]

>> IOW, it usually should be a symbol,
>> whereas in your example it is a
>> list that calls a function.

The guiding lamp I take to Lisp is it is a Russian Doll of lists.  

If I plug a list to that-list-context-right it will work. 

Obviously it is more complicated than that. 

The COMMAND has to be an "expression that evals to (fbound) symbol” and I’d 
like a function with an argument to be that.

That will by explained going from

(info "(elisp) Symbols”)

Thank you.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]