all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Redirect Output
@ 2010-03-30 21:23 Johan Andersson
  2010-03-30 22:08 ` Lennart Borgman
  0 siblings, 1 reply; 4+ messages in thread
From: Johan Andersson @ 2010-03-30 21:23 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 701 bytes --]

Hey,

I have a batch program where I run some Elisp functions and then print some
results. The problem is that some of the functions I'm calling produces
output. And I don't want that. So I'm basically looking for a way to only
output my printing.

The first I thought about was redirecting stdout to something else. Like
this:


#!/usr/bin/emacs --script

(let* ((buffer (get-buffer-create "output"))
       (standard-output buffer))
  (print "some printing"))


That works fine, except that it does not bite on message. Like this:


#!/usr/bin/emacs --script
(let* ((buffer (get-buffer-create "output"))
       (standard-output buffer))
  (message "some message"))


Any ideas how I can solve this?

[-- Attachment #2: Type: text/html, Size: 1064 bytes --]

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

* Re: Redirect Output
  2010-03-30 21:23 Redirect Output Johan Andersson
@ 2010-03-30 22:08 ` Lennart Borgman
  2010-03-30 22:14   ` Johan Andersson
  0 siblings, 1 reply; 4+ messages in thread
From: Lennart Borgman @ 2010-03-30 22:08 UTC (permalink / raw)
  To: Johan Andersson; +Cc: help-gnu-emacs

On Tue, Mar 30, 2010 at 11:23 PM, Johan Andersson
<johan.rejeep@gmail.com> wrote:
> Hey,
> I have a batch program where I run some Elisp functions and then print some
> results. The problem is that some of the functions I'm calling produces
> output. And I don't want that. So I'm basically looking for a way to only
> output my printing.
> The first I thought about was redirecting stdout to something else. Like
> this:
>
> #!/usr/bin/emacs --script
> (let* ((buffer (get-buffer-create "output"))
>        (standard-output buffer))
>   (print "some printing"))
>
> That works fine, except that it does not bite on message. Like this:
>
> #!/usr/bin/emacs --script
> (let* ((buffer (get-buffer-create "output"))
>        (standard-output buffer))
>   (message "some message"))
>
> Any ideas how I can solve this?

defadvice the `message' function?




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

* Re: Redirect Output
  2010-03-30 22:08 ` Lennart Borgman
@ 2010-03-30 22:14   ` Johan Andersson
  2010-03-31 12:41     ` Johan Andersson
  0 siblings, 1 reply; 4+ messages in thread
From: Johan Andersson @ 2010-03-30 22:14 UTC (permalink / raw)
  Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1199 bytes --]

Lennart, You're almost my private Emacs tutor :)

Didn't know about advicing! Looks like it could solve it! I will look into
it and get back with the results. But that'll have to wait until tomorrow.

Thanks!

On Tue, Mar 30, 2010 at 10:08 PM, Lennart Borgman <lennart.borgman@gmail.com
> wrote:

> On Tue, Mar 30, 2010 at 11:23 PM, Johan Andersson
> <johan.rejeep@gmail.com> wrote:
> > Hey,
> > I have a batch program where I run some Elisp functions and then
> print some
> > results. The problem is that some of the functions I'm calling produces
> > output. And I don't want that. So I'm basically looking for a way to only
> > output my printing.
> > The first I thought about was redirecting stdout to something else. Like
> > this:
> >
> > #!/usr/bin/emacs --script
> > (let* ((buffer (get-buffer-create "output"))
> >        (standard-output buffer))
> >   (print "some printing"))
> >
> > That works fine, except that it does not bite on message. Like this:
> >
> > #!/usr/bin/emacs --script
> > (let* ((buffer (get-buffer-create "output"))
> >        (standard-output buffer))
> >   (message "some message"))
> >
> > Any ideas how I can solve this?
>
> defadvice the `message' function?
>

[-- Attachment #2: Type: text/html, Size: 1896 bytes --]

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

* Re: Redirect Output
  2010-03-30 22:14   ` Johan Andersson
@ 2010-03-31 12:41     ` Johan Andersson
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Andersson @ 2010-03-31 12:41 UTC (permalink / raw)
  To: Johan Andersson; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1545 bytes --]

I solved it like this:

  (defadvice message (around message-around (format-string &rest args)
activate))
  (defun message-force (format-string &rest args)
    (princ (apply 'format format-string args)))

Thanks!

On Tue, Mar 30, 2010 at 10:14 PM, Johan Andersson <johan.rejeep@gmail.com>wrote:

> Lennart, You're almost my private Emacs tutor :)
>
> Didn't know about advicing! Looks like it could solve it! I will look into
> it and get back with the results. But that'll have to wait until tomorrow.
>
> Thanks!
>
> On Tue, Mar 30, 2010 at 10:08 PM, Lennart Borgman <
> lennart.borgman@gmail.com> wrote:
>
>> On Tue, Mar 30, 2010 at 11:23 PM, Johan Andersson
>> <johan.rejeep@gmail.com> wrote:
>> > Hey,
>> > I have a batch program where I run some Elisp functions and then
>> print some
>> > results. The problem is that some of the functions I'm calling produces
>> > output. And I don't want that. So I'm basically looking for a way to
>> only
>> > output my printing.
>> > The first I thought about was redirecting stdout to something else. Like
>> > this:
>> >
>> > #!/usr/bin/emacs --script
>> > (let* ((buffer (get-buffer-create "output"))
>> >        (standard-output buffer))
>> >   (print "some printing"))
>> >
>> > That works fine, except that it does not bite on message. Like this:
>> >
>> > #!/usr/bin/emacs --script
>> > (let* ((buffer (get-buffer-create "output"))
>> >        (standard-output buffer))
>> >   (message "some message"))
>> >
>> > Any ideas how I can solve this?
>>
>> defadvice the `message' function?
>>
>
>

[-- Attachment #2: Type: text/html, Size: 2554 bytes --]

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

end of thread, other threads:[~2010-03-31 12:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-30 21:23 Redirect Output Johan Andersson
2010-03-30 22:08 ` Lennart Borgman
2010-03-30 22:14   ` Johan Andersson
2010-03-31 12:41     ` Johan Andersson

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.