Path: utzoo!attcan!uunet!know!samsung!uakari.primate.wisc.edu!dali.cs.montana.edu!rpi!rpi.edu!tale From: tale@turing.cs.rpi.edu (David C Lawrence) Newsgroups: comp.emacs Subject: Re: syntax for function with argument Message-ID: Date: 19 Sep 90 16:31:57 GMT References: <1990Sep17.224911.22873@sics.se> <1990Sep18.035904.5608@iwarp.intel.com> Organization: Rensselaer Polytechnic Institute Computer Science, Troy NY Lines: 58 In <1990Sep17.224911.22873@sics.se>, ag@sics (Anders G|ransson) writes: | Suppose you want to assign a key-combination to a function by putting | (define-key-fully global-map "xyz" *something*) in your init-file but | you want to use the variant of the function you get when it is | supplied with an argument. | That is, you want to achieve the result of "C-u (arg) M-x foo" | by the key-combination "xyz". What is the *something* in this case? If it is a function which does not read from the minibuffer then *something* is "\C-uARG\M-xfoo". | I guess this is explained in the manual somewhere but I haven't | been able to find it. So if some kind soul could email me the | answer I'd be grateful. In <1990Sep18.035904.5608@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes: > Nope. It may be in the manual, and if it is, I haven't seen it, > but it'd be something more like this: The function documentation for define-key mentions that DEF can be a string which is treated as keyboard macros. Note however that keyboard macros are very simplistic and don't cope at all well at being asked to stop half way into an interactive command -- "\C-u\M-!" just won't work as a keyboard macro in vanilla GNU Emacs; it reads nothing in response to the Shell command: prompt rather than stopping and waiting for you to enter something. If you have a function which needs to read from the minibuffer then you must do it like Randal suggests, though I would use: (define-key xyz-with-prefix (arg) (interactive "P") (call-interactively (function xyz)) rather than his (btw, the ``let'' isn't syntactically correct): > (define xyz-with-prefix () > (interactive) > (let prefix-arg '(1) ; or whatever you're calling with > ; see (describe-variable 'prefix-arg) > (call-interactively 'xyz))) > Alternatively, you can lookup the arglist of 'xyz (at the proper place in > the source), and feed it arguments like: > (define xyz-with-prefix () > (interactive) > (xyz some-arg some-other-arg)) Some functions, however, behave differently depending on whether they are interactive-p. The former method makes sure that the results you get are the same as if you had given a prefix argument to the command interactively. -- (setq mail '("tale@cs.rpi.edu" "tale@ai.mit.edu" "tale@rpitsmts.bitnet")) I'm worried about the baggage retrieval system they've got at Heathrow.