emacs-devel
[Top][All Lists]
Advanced

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

Defaults for set-variable


From: Juri Linkov
Subject: Defaults for set-variable
Date: Mon, 17 Oct 2005 18:35:55 +0300
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

I want to fix a bug in `set-variable' related to its default values.
It uses `read-variable' to read the name of a user variable
(a variable for which `user-variable-p' returns non-nil).
But there is one case where `set-variable' doesn't follow this
requirement: when a non-user variable name happens to be under point,
it picks it up from the buffer as a default value, and if the user
types RET, it accepts a non-user variable as a variable name argument
of `set-variable'.  The first hunk in the following patch fixes this
by testing the name of the default variable by `user-variable-p'.

The fix described above concerns the default value of the variable's
*name*.  While on this topic, I propose also to improve reading the
variable's *value* in `set-variable' by adding a default value to it.
A good default value is the old value of the variable.  There is
no need to display this default value in parentheses in the prompt,
but using M-n to obtain the old value as a basis for editing the new
value is very convenient, especially for slight modifications of large
strings and lists.

If this change is ok, then perhaps an entry in NEWS should be added
to inform about availability of the old value for editing via M-n
in the minibuffer.

Index: lisp/simple.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/simple.el,v
retrieving revision 1.755
diff -c -w -b -r1.755 simple.el
*** lisp/simple.el      16 Oct 2005 09:31:47 -0000      1.755
--- lisp/simple.el      17 Oct 2005 15:33:05 -0000
***************
*** 4572,4578 ****
  With a prefix argument, set VARIABLE to VALUE buffer-locally."
    (interactive
     (let* ((default-var (variable-at-point))
!           (var (if (symbolp default-var)
                        (read-variable (format "Set variable (default %s): " 
default-var)
                                       default-var)
                      (read-variable "Set variable: ")))
--- 4586,4592 ----
  With a prefix argument, set VARIABLE to VALUE buffer-locally."
    (interactive
     (let* ((default-var (variable-at-point))
!           (var (if (user-variable-p default-var)
                   (read-variable (format "Set variable (default %s): " 
default-var)
                                  default-var)
                 (read-variable "Set variable: ")))
***************
*** 4600,4606 ****
                                              arg))
                     (read
                      (read-string prompt nil
!                                  'set-variable-value-history))))))
       (list var val current-prefix-arg)))
  
    (and (custom-variable-p variable)
--- 4614,4621 ----
                                              arg))
                     (read
                      (read-string prompt nil
!                                  'set-variable-value-history
!                                (format "%S" (symbol-value var))))))))
       (list var val current-prefix-arg)))
  
    (and (custom-variable-p variable)

-- 
Juri Linkov
http://www.jurta.org/emacs/





reply via email to

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