unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Defaults for set-variable
@ 2005-10-17 15:35 Juri Linkov
  2005-10-17 21:58 ` Richard M. Stallman
  2005-10-31 19:22 ` Drew Adams
  0 siblings, 2 replies; 31+ messages in thread
From: Juri Linkov @ 2005-10-17 15:35 UTC (permalink / raw)


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/

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2005-11-10  2:09 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-17 15:35 Defaults for set-variable Juri Linkov
2005-10-17 21:58 ` Richard M. Stallman
2005-10-19 15:43   ` Juri Linkov
2005-10-20  4:54     ` Richard M. Stallman
2005-10-31 19:22 ` Drew Adams
2005-10-31 21:20   ` Miles Bader
2005-10-31 22:15     ` Drew Adams
2005-10-31 23:17       ` Miles Bader
2005-11-01  0:49         ` Drew Adams
2005-11-01  2:00           ` Miles Bader
2005-11-01 11:29         ` Kim F. Storm
2005-11-01  9:15   ` Juri Linkov
2005-11-01 13:35     ` David Kastrup
2005-11-01 14:05       ` Miles Bader
2005-11-02 10:27     ` Richard M. Stallman
2005-11-02 16:22       ` Drew Adams
2005-11-02 20:41         ` Sascha Wilde
2005-11-03  7:52           ` Juri Linkov
2005-11-03  8:53             ` Sascha Wilde
2005-11-03 16:08               ` Drew Adams
2005-11-04  1:46                 ` Miles Bader
2005-11-04 12:07                   ` Juri Linkov
2005-11-04 12:35                     ` David Kastrup
2005-11-05  9:44                       ` Juri Linkov
2005-11-08 19:45                         ` Kevin Rodgers
2005-11-08 22:05                           ` Drew Adams
2005-11-09  9:34                             ` Juri Linkov
2005-11-09 13:17                               ` Kim F. Storm
2005-11-09 17:54                                 ` Juri Linkov
2005-11-10  2:09                               ` Richard M. Stallman
2005-11-03 13:51         ` Richard M. Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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