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: 26.1 emacs-mac 7.2; map key to interactive lisp function (command) with an argument Date: Sun, 21 Oct 2018 22:33:22 +0200 Message-ID: <878t2r11m5.fsf@web.de> References: <50DFDFDA-C01D-49AA-97FB-30DF4DE9BB46@scratch.space> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1540154478 19745 195.159.176.226 (21 Oct 2018 20:41:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 21 Oct 2018 20:41:18 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: help-gnu-emacs To: Van L Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 21 22:41:14 2018 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 1gEKXA-000517-LI for geh-help-gnu-emacs@m.gmane.org; Sun, 21 Oct 2018 22:41:12 +0200 Original-Received: from localhost ([::1]:60151 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEKZH-0006qq-0A for geh-help-gnu-emacs@m.gmane.org; Sun, 21 Oct 2018 16:43:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEKYA-0006Be-Vr for help-gnu-emacs@gnu.org; Sun, 21 Oct 2018 16:42:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEKPh-0004tp-0v for help-gnu-emacs@gnu.org; Sun, 21 Oct 2018 16:33:33 -0400 Original-Received: from mout.web.de ([212.227.17.11]:33707) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEKPg-0004rg-Nz for help-gnu-emacs@gnu.org; Sun, 21 Oct 2018 16:33:28 -0400 Original-Received: from drachen.dragon ([94.218.210.177]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MLxs8-1gFSTH1blk-007mqN; Sun, 21 Oct 2018 22:33:23 +0200 Original-Received: from drachen.dragon ([94.218.210.177]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MLxs8-1gFSTH1blk-007mqN; Sun, 21 Oct 2018 22:33:23 +0200 In-Reply-To: <50DFDFDA-C01D-49AA-97FB-30DF4DE9BB46@scratch.space> (Van L.'s message of "Sun, 21 Oct 2018 15:18:39 +1100") X-Provags-ID: V03:K1:SbdxOsxTpXOS4L0yUVwCxm/r1ruK75bnJq8hOOfqFsHNN09wHcL +6HfdVac8T3sywub1YKni+UL7M+kX2VKcXfC+CAas4BOIUcac4djrbMSooTt+IPvJkWYp0l IYC/fjf9yTj/F0i9ue8Dh5NRCeEDPo+Ukl27acJ/Kvxk3CGMWQyC52ZGv79jkjFSf5Rav0B kOCjrZ2RIcdfGD73gM2gQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:zIfUbvoxu4o=:+SXXgk4ezdtX+vJE9u7ERp 9itjEHXsdcWHMwtAn0Q4q9hpxpWJcidTrv14OW9MLWQBeFJGqBLkxq3fmaAX+LBiqovubaphM nUYrp18eda64EYpdaHlwiw6Xnna8hNcrh45N2aOAfXy6ZhNDocZ0NSVRy3xP7YOIKbZPlCcED V+McwJGvTknBCR0RDYc8/2ZAYdMDfzlgBiTLQcHm+KGR/mkttRRSQkkCZfg7BoNjWQOLVVJ7l T7TLTxOOQOnJ3fYu7zdEEEyUPBdScHS9wT3CYFedWRQE/Di5R+oQ+ChIXhpDuKHy9vg06CyVs MA4tp1t+GT1THTciHSXvHjQFXUTwzSeOpd0VKGX9nOcbsBS9yhhrCbeIUmUJTX54ixkc759Pp KINp7a9nqRdgw3fpu2YgiS5a8CRsv/CyJtstXMeKtdOVEeV9lwrwbykvXIM5AvyOCkJvDZkIx R/zu8kC1aq9TU7hJ9D0c/uV4otx6jIeHc6p/szergwFR+cPsPqE8HOZPcunJaTHpMJzG1y1Oi X8Y1RFxQtEZYNpZovsbBdqBLL/KRuVoS3LVMmzaS15y5tRS5cpS1qjEhoK604tDDaqaRhXtnq U9mIN791uVw48XVh0oFj3gKfd/cwYrylse2DmYMGXarAIiyDBzflbyLlGyWz5hcfJhruXy7et X6TS6DJMWsExHeuXX1ujJjzJT911sLUaXAh7IljxmeVsU+7CSEZ+KU2WcEcanfRalXP5Sru43 +vByza/8TW+4OJB9cwwEY7Cf68vi1DIiPakoTpRDTg4g+FMDHEiZuajtySwSbw7iNEwAvHpO X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.11 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:118384 Archived-At: Van L writes: > =E2=94=82 (global-set-key (kbd "C-c o") (funcall-interactively > x-setface-height-i 202)) > =E2=94=82 (global-set-key (kbd "C-c O") (funcall-interactively > x-setface-height-i 256)) > =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 In addition to what Eli said: How could that even work? `global-set-key' is a function, so your `funcall-interactively' is evaluated already when the `global-set-key' expression is evaluated. Besides specifying a quoted function name at the COMMAND position in the `global-set-key' call, you can write there any expression that evaluates to an (fbound) symbol, which includes a `defun'. That means you can write (global-set-key KEY (defun name ...)) instead of using two expressions (defun name ...) (global-set-key KEY 'name) It's also possible to specify a function object (an anonymous function) as COMMAND argument: (global-set-key KEY (lambda () (interactive) CODE...) This has downsides, however: if you ask Emacs for help about KEY, like C-h k KEY, the information you get is less useful, in particular, you get no link to the source code, so it's harder to localize the definition in your files if you ever want to change KEY's binding. If you want to specify an anonymous command, you can define a helper macro that wraps the (lambda () (interactive) ...) around CODE. If your macro would be named "command", you could then write shorter (global-set-key KEY (command CODE...)) if this is your goal. Michael.