From: Thorsten Jolitz <tjolitz@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: goof in small function where???
Date: Tue, 22 Jul 2014 12:33:54 +0200 [thread overview]
Message-ID: <87fvhtvg19.fsf@gmail.com> (raw)
In-Reply-To: 53CE2D32.2070502@mousecar.com
ken <gebser@mousecar.com> writes:
> The function below half works: it does put the buffer-file-name into
> the kill ring, but nothing is displayed in the minibuffer. Why? And
> how to fix this?
>
> (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)))
> )
Try:
#+begin_src emacs-lisp
(defun tj/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)))
(when str
(kill-new str)
(message "Copied filename %s to kill ring" str))))
#+end_src
#+results:
: tj/file-name-into-kill-buffer
#+begin_src emacs-lisp
(tj/file-name-into-kill-buffer)
#+end_src
#+results:
: Copied filename /home/tj/News/drafts/drafts/853 to kill ring
I guess `kill-new` is for side-effects only and returns nil, so in your
version the `message` call is never executed.
--
cheers,
Thorsten
next prev parent reply other threads:[~2014-07-22 10:33 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
2014-07-22 11:07 ` Michael Heerdegen
2014-07-22 10:33 ` Thorsten Jolitz [this message]
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=87fvhtvg19.fsf@gmail.com \
--to=tjolitz@gmail.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.