unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Tim Johnson <tim@akwebsoft.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Proper use of function form
Date: Sun, 26 Apr 2020 17:58:32 -0800	[thread overview]
Message-ID: <66e22568-f976-0749-b4a6-e8bbe6f4b745@akwebsoft.com> (raw)
In-Reply-To: <CAM-tV--mvk08WBvP4gYTWnuy5kTKMjM55nd14xydDWmr1Bn40A@mail.gmail.com>


On 4/26/20 4:48 PM, Noam Postavsky wrote:
> On Sun, 26 Apr 2020 at 19:27, Tim Johnson <tim@akwebsoft.com> wrote:
>
>> (setq my-keypairs '("h" my-h-func "g" my-g-func "f" my-f-func))
>>
>> and using iteration to *programmatically* call define-key for multiple
>> key definitions as in
>>
>> (define-key mymap                               ;; add to keymap
>>       (kbd (concat ldr (nth ndx mylist)))    ;; sequence as in "g"
>>       (nth (+ ndx 1) mylist))                      ;; command as in my-g-func
>>
>> The form above is indeed a snippet from a defun that I have used for years
>>
>> Would it be better to change (nth (+ ndx 1) mylist) to (function (nth (+
>> ndx 1) mylist)) ?
> No, you would put the function in the `my-keypairs' initializer:
>
> (setq my-keypairs `("h" ,#'my-h-func "g" ,#'my-g-func "f" ,#'my-func))
>
> I usually don't bother sharp-quoting in lists of functions though.
>
Wow! I had been thinking of that myself, but not fully understanding how 
symbols are evaluated in descending layers in sexps, this is a great 
second opinion.

Thank you Noam.

... and keep 'em coming

-- 
Tim
tj49.com




  reply	other threads:[~2020-04-27  1:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-26 23:27 Proper use of function form Tim Johnson
2020-04-27  0:05 ` Michael Heerdegen
2020-04-27  0:43   ` Tim Johnson
2020-04-27  0:48 ` Noam Postavsky
2020-04-27  1:58   ` Tim Johnson [this message]
2020-04-27  8:06 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-04-27 19:12   ` Tim Johnson

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=66e22568-f976-0749-b4a6-e8bbe6f4b745@akwebsoft.com \
    --to=tim@akwebsoft.com \
    --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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).