all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: 26.1 emacs-mac 7.2; map key to interactive lisp function (command) with an argument
Date: Mon, 22 Oct 2018 09:25:12 +0300	[thread overview]
Message-ID: <83ftwyts53.fsf@gnu.org> (raw)
In-Reply-To: <34075097-4888-4CA1-84BE-23F1380EF41E@scratch.space> (message from Van L on Mon, 22 Oct 2018 10:00:27 +1100)

> From: Van L <van@scratch.space>
> Date: Mon, 22 Oct 2018 10:00:27 +1100
> 
> ┌────
> │  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.

Why would you want that?  Copy/paste is cheap, much cheaper than your
time (assuming you need to do something other than play with Lisp
forms).  It's possible, but it's advanced stuff, so beginners are well
advised to steer away from that.

The "advanced" way of doing what you wanted was explained by Michael:
use a lambda-function that calls set-face-height with the appropriate
argument.  (Actually, I'd do away with set-face-height entiely, and
call set-face-attribute directly.)

>   1) (info "(elisp) Calling Functions")
>      - experiment with funcall and fail

funcall needs an argument that is a symbol or one whose value is a
symbol.  There's a telltale example in the doc string.

>   2) (info "(elisp) Interactive Call")
>      - experiment with funcall-interactively and fail

Ditto.

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

Yes, but there's a difference between a normal list and a quoted one:
the latter doesn't get evaluated right away.



  reply	other threads:[~2018-10-22  6:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-21  4:18 26.1 emacs-mac 7.2; map key to interactive lisp function (command) with an argument Van L
2018-10-21 12:26 ` Eli Zaretskii
2018-10-21 20:33 ` Michael Heerdegen
2018-10-21 23:00   ` Van L
2018-10-22  6:25     ` Eli Zaretskii [this message]
2018-10-22 21:55       ` Van L

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83ftwyts53.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.