Article View: gnu.emacs.help
Article #189049How do I bind keys to function calls with arguments?
From: Alex Tomlinson
Date: Fri, 10 May 1991 02:08
Date: Fri, 10 May 1991 02:08
45 lines
1896 bytes
1896 bytes
How can I bind a key to a function call with an argument?
Here's what I have:
(define-key mode-specific-map "s" 'latex-sc)
(define-key mode-specific-map "e" 'latex-em)
(defun latex-sc (&optional arg)
(interactive "*p")
(backward-sexp arg)
(insert-string "{\\sc ")
(forward-sexp arg)
(insert-string "}"))
(defun latex-em (&optional arg)
(interactive "*p")
(backward-sexp arg)
(insert-string "{\\em ")
(forward-sexp arg)
(insert-string "}"))
I want to do something like this:
(define-key mode-specific-map "s" '(latex-cmd "sc"))
(define-key mode-specific-map "e" '(latex-cmd "em"))
(defun latex-cmd (str &optional arg)
(interactive "*s\np")
(backward-sexp arg)
(insert-string (concat "{\\" str " "))
(forward-sexp arg)
(insert-string "}"))
If I can do that, then I don't have to have a bunch of
defuns that are practically the same. Besides the syntax
of the define-key's, the arguments and use w/in (interactive)
aren't correct. I don't know how to have an optional arg and
required string.
Thanks in advance.
Please email responses.
Alex Tomlinson
Technical Details
Message-ID:
<ALEXT.91May9210835@doc.cc.utexas.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!math.fu-berlin.de!ira.uka.de!sol.ctr.columbia.edu!lll-winken!elroy.jpl.nasa.gov!swrinde!cs.utexas.edu!ut-emx!ccwf.cc.utexas.edu!alextShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103b8b,dc8c45a869a9818b,start X-Google-Attributes: gid103b8b,public X-Google-ArrivalTime: 1991-05-09 23:32:31 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!math.fu-berlin.de!ira.uka.de!sol.ctr.columbia.edu!lll-winken!elroy.jpl.nasa.gov!swrinde!cs.utexas.edu!ut-emx!ccwf.cc.utexas.edu!alext From: alext@ccwf.cc.utexas.edu (Alex Tomlinson) Newsgroups: gnu.emacs.help Subject: How do I bind keys to function calls with arguments? Message-ID: <ALEXT.91May9210835@doc.cc.utexas.edu> Date: 10 May 91 02:08:35 GMT Sender: news@ut-emx.uucp Distribution: gnu Organization: The University of Texas at Austin Lines: 45