[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: goof in small function where???
From: |
Thorsten Jolitz |
Subject: |
Re: goof in small function where??? |
Date: |
Tue, 22 Jul 2014 12:33:54 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
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