* How to discard return value of a function?
@ 2012-08-19 9:35 Plamen Tanovski
2012-08-19 9:52 ` Leo
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Plamen Tanovski @ 2012-08-19 9:35 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
I'm trying to write a skeleton with (search-forward) in it. But
(search-forward) always returns the point and skeleton inserts it as a
string in the buffer, which of course is not what I want. Ho can I
discard the return value of a function? I searched the elisp reference
and the net but didn't found anything. Sure, I can assign the return to
a variable, but there must be a better solution.
best regards
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to discard return value of a function?
2012-08-19 9:35 How to discard return value of a function? Plamen Tanovski
@ 2012-08-19 9:52 ` Leo
[not found] ` <mailman.7236.1345369957.855.help-gnu-emacs@gnu.org>
2012-08-22 15:04 ` Stefan Monnier
2 siblings, 0 replies; 6+ messages in thread
From: Leo @ 2012-08-19 9:52 UTC (permalink / raw)
To: help-gnu-emacs
(progn (YOURFUNCTION ...) nil)
--
Sent from my Emacs
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to discard return value of a function?
[not found] ` <mailman.7236.1345369957.855.help-gnu-emacs@gnu.org>
@ 2012-08-20 19:47 ` jpkotta
2012-08-21 0:13 ` Barry Margolin
0 siblings, 1 reply; 6+ messages in thread
From: jpkotta @ 2012-08-20 19:47 UTC (permalink / raw)
To: gnu.emacs.help; +Cc: help-gnu-emacs
On Sunday, August 19, 2012 4:52:21 AM UTC-5, Leo wrote:
> (progn (YOURFUNCTION ...) nil)
>
> --
>
> Sent from my Emacs
You can also use advice, but (progn ... nil) is probably preferable.
(defun foo ()
(interactive)
t)
(defadvice foo (after modify-return-value activate)
(setq ad-return-value nil))
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to discard return value of a function?
2012-08-20 19:47 ` jpkotta
@ 2012-08-21 0:13 ` Barry Margolin
2012-08-21 15:59 ` jpkotta
0 siblings, 1 reply; 6+ messages in thread
From: Barry Margolin @ 2012-08-21 0:13 UTC (permalink / raw)
To: help-gnu-emacs
In article <88a339ab-f737-40d1-8f3a-7cd6b66c585e@googlegroups.com>,
jpkotta <jpkotta@gmail.com> wrote:
> On Sunday, August 19, 2012 4:52:21 AM UTC-5, Leo wrote:
> > (progn (YOURFUNCTION ...) nil)
>
> You can also use advice, but (progn ... nil) is probably preferable.
>
> (defun foo ()
> (interactive)
> t)
>
> (defadvice foo (after modify-return-value activate)
> (setq ad-return-value nil))
If he advised search-forward to return nil, that would break lots of
other things. He just wants to ignore the return value in one
particular place where he calls it.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to discard return value of a function?
2012-08-21 0:13 ` Barry Margolin
@ 2012-08-21 15:59 ` jpkotta
0 siblings, 0 replies; 6+ messages in thread
From: jpkotta @ 2012-08-21 15:59 UTC (permalink / raw)
To: help-gnu-emacs
On Monday, August 20, 2012 7:13:35 PM UTC-5, Barry Margolin wrote:
> In article <88a339ab-f737-40d1-8f3a-7cd6b66c585e@googlegroups.com>,
>
> jpkotta <jpkotta@gmail.com> wrote:
>
>
>
> > On Sunday, August 19, 2012 4:52:21 AM UTC-5, Leo wrote:
>
> > > (progn (YOURFUNCTION ...) nil)
>
> >
>
> > You can also use advice, but (progn ... nil) is probably preferable.
>
> >
>
> > (defun foo ()
>
> > (interactive)
>
> > t)
>
> >
>
> > (defadvice foo (after modify-return-value activate)
>
> > (setq ad-return-value nil))
>
>
>
> If he advised search-forward to return nil, that would break lots of
>
> other things. He just wants to ignore the return value in one
>
> particular place where he calls it.
>
>
>
> --
>
> Barry Margolin, barmar@alum.mit.edu
>
> Arlington, MA
>
> *** PLEASE post questions in newsgroups, not directly to me ***
Yeah, I realized that after I posted. I tried to delete the post but I guess it got posted twice for some reason.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to discard return value of a function?
2012-08-19 9:35 How to discard return value of a function? Plamen Tanovski
2012-08-19 9:52 ` Leo
[not found] ` <mailman.7236.1345369957.855.help-gnu-emacs@gnu.org>
@ 2012-08-22 15:04 ` Stefan Monnier
2 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2012-08-22 15:04 UTC (permalink / raw)
To: help-gnu-emacs
> I'm trying to write a skeleton with (search-forward) in it. But
> (search-forward) always returns the point and skeleton inserts it as a
> string in the buffer, which of course is not what I want.
C-h f skeleton-insert RET says:
Quoted Lisp expressions are evaluated for their side-effects.
Other Lisp expressions are evaluated and the value treated as above.
so you can use '(search-forward ...) in your skeleton to tell skeleton
that the return value should be ignored.
Otherwise, you can also use (ignore (search-forward ...)) since `ignore'
always returns nil.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-08-22 15:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-19 9:35 How to discard return value of a function? Plamen Tanovski
2012-08-19 9:52 ` Leo
[not found] ` <mailman.7236.1345369957.855.help-gnu-emacs@gnu.org>
2012-08-20 19:47 ` jpkotta
2012-08-21 0:13 ` Barry Margolin
2012-08-21 15:59 ` jpkotta
2012-08-22 15:04 ` Stefan Monnier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).