help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Quoted function in `define-key'


From: Michael Heerdegen
Subject: Re: Quoted function in `define-key'
Date: Sat, 04 Feb 2017 13:05:10 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Narendra Joshi <address@hidden> writes:

> The following piece of code is confusing me. It is from `rinari-minor-mode'.
>
> (dolist (el (append (mapcar
>                      (lambda (el)
>                        (cons (concat "f" (second el))
>                              (read (format "'rinari-find-%S"
>                                            (first el)))))
>                      rinari-jump-schema)
>                     rinari-minor-mode-keybindings))
>   (eval `(define-key rinari-prefix-map ,(car el) ,(cdr el))))
>
>
> If I replace the last expression with:
>
> (define-key rinari-prefix-map (car el) (cdr el))
>
> why does it fail?
>
> (cdr el) is (quote function-name) which is exactly the same as
> 'function-name.

Sure, but this is then not evaluated again, and you want the DEF
argument of `define-key' to be function-name, not (quote function-name).

And yes, using `eval' in this context is indeed overkill (as well as
`read' which could be replaced with `intern').


Michael.



reply via email to

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