help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Filename of buffer into kill-ring functionality


From: Kevin Rodgers
Subject: Re: Filename of buffer into kill-ring functionality
Date: Thu, 31 Aug 2006 14:40:21 -0600
User-agent: Thunderbird 1.5.0.5 (Windows/20060719)

Reiner Steib wrote:
On Thu, Aug 31 2006, Kevin Rodgers wrote:

(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)))))

Is there a reason why you use (boundp symbol) inside
(with-current-buffer ...)?  In other words: Is there any difference
between these variants?

(with-current-buffer current-buffer
  (and (boundp symbol)
       (stringp (symbol-value symbol))))

(and (boundp symbol)
     (with-current-buffer current-buffer
       (stringp (symbol-value symbol))))

The reason with-current-buffer is necessary at all is that the predicate
is run by completing-read with the minibuffer as the current buffer.  I
did it the first way when I first realized that, and it was simpler to
just wrap the entire body of the predicate.

Whether there's a difference between the two depends on whether a
variable with a buffer local value can be unbound globally (or in other
buffers, like the minibuffer).  I think that depends on how buffer local
bindings are implemented, and the first way is safer since it doesn't
depend on how that.

--
Kevin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]