From: ken <gebser@mousecar.com>
To: help-gnu-emacs@gnu.org
Subject: Re: goof in small function where???
Date: Tue, 22 Jul 2014 06:28:33 -0400 [thread overview]
Message-ID: <53CE3CD1.9050908@mousecar.com> (raw)
In-Reply-To: <87ha291zkf.fsf@web.de>
On 07/22/2014 06:02 AM Michael Heerdegen wrote:
> ken <gebser@mousecar.com> writes:
>
>> (defun file-name-into-kill-buffer ()
>> "Put path/filename of current buffer onto kill-ring so to paste
>> into an X application. Also display it in minibuffer."
>> (interactive)
>> (let ((str (buffer-file-name)))
>> (and str
>> (kill-new str)
>> (message "Copied filename %s to kill ring" str)))
>> )
>
> This doesn't work when `kill-new' returns nil, which happens when
> `interprogram-cut-function' is nil (which is the default). Note that
> the doc of `kill-new' doesn't say anything about the return value, it
> can be anything.
>
> Ergo: the `and' should better be a `when'.
Yes! That fixed it!! Thanks very much.
I'm vaguely understanding that the 'and' doesn't evaluate '(message...'
when '(kill-new...' returns nil and, since its return value is
undefined, it can do on occasion. Replacing 'and' with 'when' ensures
'(message...' is evaluated regardless of what '(kill-new...' returns.
Is that about right?
Thanks again.
next prev parent reply other threads:[~2014-07-22 10:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-22 9:21 goof in small function where??? ken
2014-07-22 10:02 ` Michael Heerdegen
2014-07-22 10:28 ` ken [this message]
2014-07-22 11:07 ` Michael Heerdegen
2014-07-22 10:33 ` Thorsten Jolitz
2014-07-22 10:52 ` Thorsten Jolitz
2014-07-22 11:09 ` Michael Heerdegen
[not found] <mailman.5851.1406020938.1147.help-gnu-emacs@gnu.org>
2014-07-22 9:41 ` Joost Kremers
2014-07-22 10:16 ` ken
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53CE3CD1.9050908@mousecar.com \
--to=gebser@mousecar.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.