From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Van L Newsgroups: gmane.emacs.help Subject: Re: 26.1 emacs-mac 7.2; map key to interactive lisp function (command) with an argument Date: Mon, 22 Oct 2018 10:00:27 +1100 Message-ID: <34075097-4888-4CA1-84BE-23F1380EF41E@scratch.space> References: <50DFDFDA-C01D-49AA-97FB-30DF4DE9BB46@scratch.space> <878t2r11m5.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1540163315 31561 195.159.176.226 (21 Oct 2018 23:08:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 21 Oct 2018 23:08:35 +0000 (UTC) To: help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 22 01:08:31 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 1gEMpi-00086t-Oj for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Oct 2018 01:08:30 +0200 Original-Received: from localhost ([::1]:60531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEMrp-0005F4-4P for geh-help-gnu-emacs@m.gmane.org; Sun, 21 Oct 2018 19:10:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEMrL-00052L-4q for help-gnu-emacs@gnu.org; Sun, 21 Oct 2018 19:10:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEMi4-0007cd-Lq for help-gnu-emacs@gnu.org; Sun, 21 Oct 2018 19:00:41 -0400 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:58689) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gEMi4-0007bg-Eb for help-gnu-emacs@gnu.org; Sun, 21 Oct 2018 19:00:36 -0400 X-Originating-IP: 14.203.214.4 Original-Received: from epi.local (14-203-214-4.tpgi.com.au [14.203.214.4]) (Authenticated sender: van@scratch.space) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 945DA1C0005 for ; Sun, 21 Oct 2018 23:00:33 +0000 (UTC) In-Reply-To: <878t2r11m5.fsf@web.de> X-Mailer: Apple Mail (2.3124) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.70.183.197 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:118385 Archived-At: Thank you so much Eli, Michael. =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 the general form is =E2=94=82=20 =E2=94=82 (global-set-key KEY COMMAND) =E2=94=82=20 =E2=94=82 where COMMAND is a _symbol_, like this: =E2=94=82=20 =E2=94=82 (global-set-key (kbd "C-c o") 'foo) =E2=94=82=20 =E2=94=82 So you need to define an interactive function named SOMETHING: =E2=94=82=20 =E2=94=82 (defun SOMETHING (...) =E2=94=82 (interactive) =E2=94=82 ...) =E2=94=82=20 =E2=94=82 then bind it to a key: =E2=94=82=20 =E2=94=82 (global-set-key (kbd "C-c o") 'SOMETHING) =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 1 (defun set-face-height (number) =E2=94=82 2 "Face height is set to NUMBER." =E2=94=82 3 (interactive "nInsert number: ") =E2=94=82 4 (set-face-attribute 'default (selected-frame) :height = number)) =E2=94=82 5 =20 =E2=94=82 6 (defun set-face-height-202 () =E2=94=82 7 "Set height of face to 202" =E2=94=82 8 (interactive) =E2=94=82 9 (set-face-attribute 'default (selected-frame) :height = 202)) =E2=94=82 10 (global-set-key (kbd "C-c o") 'set-face-height-202) =E2=94=82 11 =20 =E2=94=82 12 (defun set-face-height-256 () =E2=94=82 13 "Set height of face to 256" =E2=94=82 14 (interactive) =E2=94=82 15 (set-face-attribute 'default (selected-frame) :height = 256)) =E2=94=82 16 (global-set-key (kbd "C-c O") 'set-face-height-256) =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 At the outset my goal was to get rid of lines 6 to 9, 12 to 15. To do that is to call a function with an argument in the place of 'set-face-height-XXX. I hit the documentation as follows: 1) (info "(elisp) Calling Functions") - experiment with funcall and fail 2) (info "(elisp) Interactive Call") - experiment with funcall-interactively and fail Along the way I came across two mentions of what a COMMAND is.=20 The errors I got mentioned =E2=80=9Ccommandp=E2=80=9D. I didn't lookup global-set-key (lazily) believing I needed a list = decorated the right-way to slot in the context given by 'SOMETHING, which I understand to be a quote or '(quoted list). COMMAND is the command definition to use; usually it is a symbol naming an interactively-callable function. [ I am going to read that as follows: In use the COMMAND is usually a symbol naming an interactive function which is called. ] >> IOW, it usually should be a symbol, >> whereas in your example it is a >> list that calls a function. The guiding lamp I take to Lisp is it is a Russian Doll of lists. =20 If I plug a list to that-list-context-right it will work.=20 Obviously it is more complicated than that.=20 The COMMAND has to be an "expression that evals to (fbound) symbol=E2=80=9D= and I=E2=80=99d like a function with an argument to be that. That will by explained going from (info "(elisp) Symbols=E2=80=9D) Thank you.