all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* macro with argument
@ 2003-10-20 11:16 Joerg Schuster
  2003-10-20 11:57 ` David Kastrup
  0 siblings, 1 reply; 6+ messages in thread
From: Joerg Schuster @ 2003-10-20 11:16 UTC (permalink / raw)


Hello,

how can I write "macros with arguments"?

Example: 

[Me:]    M-x my_macro
[Emacs:] your argument:
[Me:]    foo

Then emacs should print e.g.

bla foo blo

Jörg

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: macro with argument
  2003-10-20 11:16 macro with argument Joerg Schuster
@ 2003-10-20 11:57 ` David Kastrup
  2003-10-20 12:33   ` Joakim Hove
  2003-10-20 13:16   ` Joerg Schuster
  0 siblings, 2 replies; 6+ messages in thread
From: David Kastrup @ 2003-10-20 11:57 UTC (permalink / raw)


Joerg Schuster <js@cis.uni-muenchen.de> writes:

> Hello,
> 
> how can I write "macros with arguments"?
> 
> Example: 
> 
> [Me:]    M-x my_macro
> [Emacs:] your argument:
> [Me:]    foo
> 
> Then emacs should print e.g.
> 
> bla foo blo

(defun my_macro (string) (interactive "syour argument: ") (message
"bla %s blo" string))

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: macro with argument
  2003-10-20 11:57 ` David Kastrup
@ 2003-10-20 12:33   ` Joakim Hove
  2003-10-20 13:16   ` Joerg Schuster
  1 sibling, 0 replies; 6+ messages in thread
From: Joakim Hove @ 2003-10-20 12:33 UTC (permalink / raw)



David Kastrup <dak@gnu.org> writes:


>> how can I write "macros with arguments"?
>> 
>> Example: 
>> 
>> [Me:]    M-x my_macro
>> [Emacs:] your argument:
>> [Me:]    foo
>> 
>> Then emacs should print e.g.
>> 
>> bla foo blo
>
> (defun my_macro (string) (interactive "syour argument: ") (message
> "bla %s blo" string))

I.e. - write a small e-lisp function to achieve what you want, and not
a conventional macro. Check the documentation of the special form
(interactive )
 
               C-h f interactive

too see how the argument is read from you.

HTH - Joakim

-- 
  /--------------------------------------------------------------------\
 / Joakim Hove  / hove@bccs.no  /  (55 5) 84076       |                 \
 | Unifob AS, Avdeling for Beregningsvitenskap (BCCS) | Stabburveien 18 |
 | CMU                                                | 5231 Paradis    |
 \ Thormøhlensgt.55, 5020 Bergen.                     | 55 91 28 18     /
  \--------------------------------------------------------------------/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: macro with argument
  2003-10-20 11:57 ` David Kastrup
  2003-10-20 12:33   ` Joakim Hove
@ 2003-10-20 13:16   ` Joerg Schuster
  2003-10-20 13:20     ` Joakim Hove
  1 sibling, 1 reply; 6+ messages in thread
From: Joerg Schuster @ 2003-10-20 13:16 UTC (permalink / raw)


David Kastrup <dak@gnu.org> writes:

> (defun my_macro (string) (interactive "syour argument: ") (message
> "bla %s blo" string))

This prints "bla [argument] blo" in the mini buffer. I wanted Emacs to
print it in the active (?) buffer, i.e. in the buffer from which I
call the function. 

Jörg

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: macro with argument
  2003-10-20 13:16   ` Joerg Schuster
@ 2003-10-20 13:20     ` Joakim Hove
  2003-10-20 13:48       ` Joerg Schuster
  0 siblings, 1 reply; 6+ messages in thread
From: Joakim Hove @ 2003-10-20 13:20 UTC (permalink / raw)



Joerg Schuster <js@cis.uni-muenchen.de> writes:

> David Kastrup <dak@gnu.org> writes:
>
>> (defun my_macro (string) (interactive "syour argument: ") (message
>> "bla %s blo" string))
>
> This prints "bla [argument] blo" in the mini buffer. I wanted Emacs to
> print it in the active (?) buffer, i.e. in the buffer from which I
> call the function. 

Replace the (message ) function with (insert ):

  (insert (format "bla %s blo" string))

HTH - Joakim



-- 
  /--------------------------------------------------------------------\
 / Joakim Hove  / hove@bccs.no  /  (55 5) 84076       |                 \
 | Unifob AS, Avdeling for Beregningsvitenskap (BCCS) | Stabburveien 18 |
 | CMU                                                | 5231 Paradis    |
 \ Thormøhlensgt.55, 5020 Bergen.                     | 55 91 28 18     /
  \--------------------------------------------------------------------/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: macro with argument
  2003-10-20 13:20     ` Joakim Hove
@ 2003-10-20 13:48       ` Joerg Schuster
  0 siblings, 0 replies; 6+ messages in thread
From: Joerg Schuster @ 2003-10-20 13:48 UTC (permalink / raw)


Joakim Hove <hove@bccs.no> writes:

> Replace the (message ) function with (insert ):
> 
>   (insert (format "bla %s blo" string))
> 
Hello Joakim and David,

thanks a lot.

Jörg

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-10-20 13:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-20 11:16 macro with argument Joerg Schuster
2003-10-20 11:57 ` David Kastrup
2003-10-20 12:33   ` Joakim Hove
2003-10-20 13:16   ` Joerg Schuster
2003-10-20 13:20     ` Joakim Hove
2003-10-20 13:48       ` Joerg Schuster

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.