From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Quoted function in `define-key' Date: Sat, 04 Feb 2017 18:25:40 +0100 Message-ID: <87zii1dg17.fsf@drachen> References: <874m0a6ywa.fsf@vicarie.i-did-not-set--mail-host-address--so-tickle-me> <874m0ap3ex.fsf@drachen> <87efzedmlk.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 1486229175 28228 195.159.176.226 (4 Feb 2017 17:26:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 4 Feb 2017 17:26:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Narendra Joshi Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Feb 04 18:26:11 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 1ca46E-0007CT-Nu for geh-help-gnu-emacs@m.gmane.org; Sat, 04 Feb 2017 18:26:10 +0100 Original-Received: from localhost ([::1]:40375 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ca46K-0001SB-Bp for geh-help-gnu-emacs@m.gmane.org; Sat, 04 Feb 2017 12:26:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ca45t-0001S3-Of for help-gnu-emacs@gnu.org; Sat, 04 Feb 2017 12:25:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ca45o-0001d9-PU for help-gnu-emacs@gnu.org; Sat, 04 Feb 2017 12:25:49 -0500 Original-Received: from mout.web.de ([212.227.15.4]:63401) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ca45o-0001cU-C0 for help-gnu-emacs@gnu.org; Sat, 04 Feb 2017 12:25:44 -0500 Original-Received: from drachen.dragon ([188.98.111.232]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MBTXi-1chF6R0jEE-00AZw9; Sat, 04 Feb 2017 18:25:41 +0100 In-Reply-To: <87efzedmlk.fsf@vicarie.i-did-not-set--mail-host-address--so-tickle-me> (Narendra Joshi's message of "Sat, 04 Feb 2017 20:33:51 +0530") X-Provags-ID: V03:K0:sHU25DNAt1z8XZrux131g9UCWWjwWHgb/I5MkqRKr2V4ELk/bZt o+cY9D7EyIfVK5vKk42//DcIwuVYfTUZ+Fy2FQorjEfTEZaEPtPKB9Doe8MuZ9IBLJfM6PV 1y6D4ObQmdYvfGUAwBiLfI6vDG48FQN6zz+TXkQxkkrnsJM7EY10YEbbGAfAdV709SeNC8h HraqueUgjqhxsD5WIddyw== X-UI-Out-Filterresults: notjunk:1;V01:K0:AHxcRmyZ54o=:S8yYirM1BXzeaMJsgfUiNg /AD3RxdrphSDOAJliRZMRFoG/yxtPvzLt3pVmqjwO2/rz1Pz+026fwovvQEanpwmvC08UKDpI kfyPCxuNVagRRFfQHSV/l0eTTHosVu9k+JnSurp+0xArdI8CnZm1OMTb7H8gajJVnJFOWcarO FL09CY6AgQ9hahq6Z2KRx9O/tfqWs5UqJhDS4bD4eTX7aKPBOMYmk78DTUa1FTRlrd4y0DQR2 z0o+NtrH+4niZMZfsucddAcBkDHUHoDJ6nsMnWLwqDAD31Ny5tOS5aGBKpLrbmjC6TQMi2YTx odl61VvTPvkBz8sfU+lD367iyAEPRN+wlDpfoRgwCta0eMEqoNTyMY719PSZh/jly/NqvIsXQ PJXZR781dwkOt2paxeUjwUCbJeEGHd5q6hQrXedMN5D9DaHqzSe9u/SG1/5h36xd4IiVZEp+p Nyl+rFBEq8ofjd1Z3oRRuiO+CtrDieJJX+32sjH7at6/lEwLrCrKlw9U4Q3Eh45x/xfhgBSIw D5Qtmy6ohjs2bTR/Rn022N6hKnRrNzwn2pbUWbT9qQpn+xTMBHhmjhA61D2oZ9ZdhOtC5IEU4 dMGaYDr/cFz4qQHlRn19YXX9Tk4reRVn5lKLS7iuXWbwiYeFl4wCVW+XQyFi/M8JmylC9jDQ7 kspgs8QMiMZF/mG3tblXZV2Jogv6dvysEBmYgFNAFIFsM4K/taU8aGVVSCaFimvkBZT1cNfNo VUg0XXG+2A1sQXyONJpgfnDbI+rmG7cjSO41LVBqMd9rFMyakX0BMfmlvjhGa57orvbeQHdc X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.15.4 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:112239 Archived-At: Narendra Joshi writes: > (quote my-function) is exactly the same as 'my-function, i.e. Yes, the second is an alternative read syntax for the first expression. > (eq (quote my-function) 'my-function) evaluates to t. > > But here we are talking about the result of evaluating > > (quote my-function) which isn't a cons but a symbol. No, it's a list (and a cons), but the result of evaluation is a symbol. > But if we have `(quote my-function) that isn't the same as > 'my-function. `(quote my-function) and '(quote my-function) eval to the list (quote my-function). ''my-function is an alternative read syntax for '(quote my-function). But that all doesn't appear in the example. It's so: you want to specify a symbol as third argument to `define-key'. `define-key' is a function, so the argument positions are evaluated. Thus you want to specify an expression that evaluates to the symbol you want. (quote my-function) or 'my-function evaluate to the symbol you want. In (define-key rinari-prefix-map (car el) (cdr el)) the expression at that position is (cdr el), so that expression should eval to a symbol, not to a list like (quote symbol) - even when this list would give you what you want when it would be evaluated. Evaluation happens only once. With other words: when you write something like (define-key my-map keys 'my-function) you use the quote to prevent my-function from being evaluated, because you want to specify that symbol (unlike its binding as a variable), but _not_ because define-key would expect something quoted. BTW, most people prefer (define-key my-map keys #'my-function) however. #'my-function is a read syntax for (function my-function), where function is like quote but tells the byte compiler that the quoted thing is a function expression. > Side note: If anybody knows how to type inline code in gnus message, > it would be greatly appreciated. I use `message-mark-inserted-region' for multiline code, but I don't know of any rule for smaller snippets. Most of the time I don't care too much (like here). It's good style to quote a `symbol' like this, but I sometimes avoid it when code snippets already involve lots of quoting. HTH, Michael.