unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: Filename of buffer into kill-ring functionality
Date: Thu, 31 Aug 2006 09:43:52 -0600	[thread overview]
Message-ID: <ed704c$lpb$1@sea.gmane.org> (raw)
In-Reply-To: <v91wqxkri6.fsf@marauder.physik.uni-ulm.de>

Reiner Steib wrote:
> On Thu, Aug 31 2006, Marco Wahl wrote:
> 
>> is there already a function in emacs that puts the
>> absolute filename belonging to a buffer into the
>> kill-ring?  
> 
> I'm not aware of any predefined function for this.  You might use this
> one:
> 
> (defun rs-kill-ring-save-buffer-file-name ()
>   "Add `buffer-file-name' in the kill ring."
>   (interactive)
>   (if (not (stringp buffer-file-name))
>       (error "Not visiting a file.")
>     (kill-new buffer-file-name)
>     ;; Give some visual feedback:
>     (message "String \"%s\" saved to kill ring." buffer-file-name)
>     buffer-file-name))

That can be easily generalized:

(defun kill-new-string-variable (variable)
   "Make the string value of VARIABLE the latest kill in the kill ring."
   (interactive (let ((current-buffer (current-buffer)))
		 (intern (completing-read "Variable: " obarray
					  (lambda (symbol)
					    (with-current-buffer current-buffer
					      (and (boundp symbol)
						   (stringp
						    (symbol-value symbol)))))
					  t))))
   ;; Let symbol-value and kill-new signal errors for unbound variables
   ;; and non-string values, respectively:
   (kill-new (symbol-value variable)))

(defun kill-new-buffer-file-name ()
   (kill-new-string-variable 'buffer-file-name))

-- 
Kevin

  reply	other threads:[~2006-08-31 15:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-31 10:04 Filename of buffer into kill-ring functionality Marco Wahl
2006-08-31 12:40 ` Reiner Steib
2006-08-31 15:43   ` Kevin Rodgers [this message]
2006-08-31 19:08     ` Reiner Steib
2006-08-31 20:40       ` Kevin Rodgers
     [not found]   ` <mailman.6092.1157039301.9609.help-gnu-emacs@gnu.org>
2006-09-01  7:38     ` Marco Wahl
2006-09-01  8:58 ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='ed704c$lpb$1@sea.gmane.org' \
    --to=ihs_4664@yahoo.com \
    /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.
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).