From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Narendra Joshi Newsgroups: gmane.emacs.help Subject: Re: Quoted function in `define-key' Date: Sun, 05 Feb 2017 15:40:40 +0530 Message-ID: <87fujt7xsv.fsf@vicarie.i-did-not-set--mail-host-address--so-tickle-me> 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> <87zii1dg17.fsf@drachen> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1486289220 12033 195.159.176.226 (5 Feb 2017 10:07:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 5 Feb 2017 10:07:00 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cc: Narendra Joshi , help-gnu-emacs@gnu.org To: Michael Heerdegen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 05 11:06:55 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 1caJig-0002vz-TR for geh-help-gnu-emacs@m.gmane.org; Sun, 05 Feb 2017 11:06:55 +0100 Original-Received: from localhost ([::1]:42509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1caJim-0000uM-Iv for geh-help-gnu-emacs@m.gmane.org; Sun, 05 Feb 2017 05:07:00 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1caJiH-0000uF-K4 for help-gnu-emacs@gnu.org; Sun, 05 Feb 2017 05:06:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1caJiE-0004CB-EO for help-gnu-emacs@gnu.org; Sun, 05 Feb 2017 05:06:29 -0500 Original-Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:33695) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1caJiE-0004BU-8O for help-gnu-emacs@gnu.org; Sun, 05 Feb 2017 05:06:26 -0500 Original-Received: by mail-pf0-x243.google.com with SMTP id e4so4768708pfg.0 for ; Sun, 05 Feb 2017 02:06:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=c5Bd1OU+n9J/dBYWULeWled/yotPQAXAVGDYqmRh6eY=; b=HUpsFunPgQ5YZeesqQ2uMLY6oYglaI/NwbnP1H5VIYXlZNGF9REtmbj19zbQG+u+DB NCi614vjygUpeHBkrOPqs/Nll2u26y6sXOX724z4EGThFI0SF3L4fnZUilJ6Q41FbfXF rJBNnklXgJ+6m113NFrslsRsCtToU95XTbFrH8wNkltwJ4deb+vwcQpZ4qf52kKUGoBe icQ0cStL3xgIelbRlrhvSzzGXlGpnGfYNjzNv2Rvyw2cwqjwZcSn1BlF9zkA0b0P7rdI 7HZiJVKZU+fK4/26EkBvZW+Sr8qmVXjM0N90A4fucXeDPQnJR4FngvJaEm+YT+pkQ9Hv fO/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=c5Bd1OU+n9J/dBYWULeWled/yotPQAXAVGDYqmRh6eY=; b=avsHN6/95Q2Bk59dIupdFvPT70nKmYM1mb8cqCszUDsO7KJZQDPGjfhvhKQXb81HQt 7fKWOxwMtjKh71OrKc/E3iyo8HljQ+pM1MQq55nH5bJeNuGIjYTy+dGrFWA4G7mIqJmC YilTEzrS6IOFx1W5ba2r1ffndBP1p8y/khvM8AYTcpGzA/b6yFBrjjd5mFb2OrKplzkH /nquccd4glyE+26bAIlQ4Y0SlHReHaaKYgyGI8twVTsrsxBr9qkhShcktb0uSPR6d2w1 eCSTIMB71gz5RwyRfnmo7Xf7jIelmcj7McgCkHjpu5FCLLTpqGy7YmglRwX43i5SiroI aKoA== X-Gm-Message-State: AIkVDXInGL/9M/5xZRuHFIxmH/tmbC0eHofCKgcPKFSR8dlE2OkgOtQLnKmlVjdxZIWYIw== X-Received: by 10.99.42.78 with SMTP id q75mr6987133pgq.144.1486289185037; Sun, 05 Feb 2017 02:06:25 -0800 (PST) Original-Received: from vicarie ([182.70.84.252]) by smtp.gmail.com with ESMTPSA id l188sm80301608pfl.28.2017.02.05.02.06.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Feb 2017 02:06:24 -0800 (PST) X-Google-Original-From: Narendra Joshi In-Reply-To: <87zii1dg17.fsf@drachen> (Michael Heerdegen's message of "Sat, 04 Feb 2017 18:25:40 +0100") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::243 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:112250 Archived-At: Michael Heerdegen writes: > 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) This was really helpful. Thanks! :) > > 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. So, the symbol `my-function' can have the function definition in its value slot? What does the byte compiler do with this information? I am just curious about this. If this is recommended, I would also start quoting my functions as #'my-function. >> 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. Thanks! `message-mark-inserted-region' is good but I would probably change the boundary that it inserts. :) -- Narendra Joshi