From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: Quoted function in `define-key' Date: Sat, 04 Feb 2017 13:10:34 -0500 Message-ID: References: <874m0a6ywa.fsf@vicarie.i-did-not-set--mail-host-address--so-tickle-me> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1486231871 24627 195.159.176.226 (4 Feb 2017 18:11:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 4 Feb 2017 18:11:11 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Feb 04 19:11:07 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ca4nj-0006DJ-EW for geh-help-gnu-emacs@m.gmane.org; Sat, 04 Feb 2017 19:11:07 +0100 Original-Received: from localhost ([::1]:40483 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ca4no-0000pm-Qr for geh-help-gnu-emacs@m.gmane.org; Sat, 04 Feb 2017 13:11:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ca4nP-0000ph-07 for help-gnu-emacs@gnu.org; Sat, 04 Feb 2017 13:10:47 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ca4nL-0002I7-NW for help-gnu-emacs@gnu.org; Sat, 04 Feb 2017 13:10:46 -0500 Original-Received: from [195.159.176.226] (port=56498 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ca4nL-0002HO-GW for help-gnu-emacs@gnu.org; Sat, 04 Feb 2017 13:10:43 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1ca4nD-00056h-Io for help-gnu-emacs@gnu.org; Sat, 04 Feb 2017 19:10:35 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 41 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:cAMoE83dDFa5EOa0RFPxlyILb1c= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112240 Archived-At: >>>>> "Narendra" == Narendra Joshi 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. "Exactly the same"? Well, clearly not, since it behaves differently: (eval (cdr el)) => (quote function-name) (eval 'function-name) => function-name A good first rule is that if you're using `eval` it means you're not really doing it right: (dolist (el (append (mapcar (lambda (el) (cons (vconcat [?\f] (nth 1 el)) (intern "rinari-find-%s" (nth 0 el)))) rinari-jump-schema) rinari-minor-mode-keybindings)) (define-key rinari-prefix-map (car el) (cdr el))) -- Stefan