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

* Re: Defaults for set-variable
  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-31 19:22 ` Drew Adams
  1 sibling, 1 reply; 31+ messages in thread
From: Richard M. Stallman @ 2005-10-17 21:58 UTC (permalink / raw)
  Cc: emacs-devel

The change is ok, but please don't bother mentioning it in NEWS.
It is below the threshold for mentioning there.  NEWS is already
so big as to be inconvenient for the users, so lowering that
threshold would be unfortunate.

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

* Re: Defaults for set-variable
  2005-10-17 21:58 ` Richard M. Stallman
@ 2005-10-19 15:43   ` Juri Linkov
  2005-10-20  4:54     ` Richard M. Stallman
  0 siblings, 1 reply; 31+ messages in thread
From: Juri Linkov @ 2005-10-19 15:43 UTC (permalink / raw)
  Cc: emacs-devel

> The change is ok, but please don't bother mentioning it in NEWS.
> It is below the threshold for mentioning there.  NEWS is already
> so big as to be inconvenient for the users, so lowering that
> threshold would be unfortunate.

Then what about documenting it in the Emacs manual?  Customization always
inserts the old value into editable fields in the customization buffer
(though, not as a Lisp expression that set-variable reads), so I think
this is a useful thing for users to know that set-variable can provide
the old value for editing too, via M-n:

Index: man/custom.texi
===================================================================
RCS file: /cvsroot/emacs/emacs/man/custom.texi,v
retrieving revision 1.90
diff -c -r1.90 custom.texi
*** man/custom.texi	5 Sep 2005 11:52:21 -0000	1.90
--- man/custom.texi	19 Oct 2005 07:27:38 -0000
***************
*** 790,796 ****
    The most convenient way to set a specific user option variable is
  with @kbd{M-x set-variable}.  This reads the variable name with the
  minibuffer (with completion), and then reads a Lisp expression for the
! new value using the minibuffer a second time.  For example,
  
  @example
  M-x set-variable @key{RET} fill-column @key{RET} 75 @key{RET}
--- 790,797 ----
    The most convenient way to set a specific user option variable is
  with @kbd{M-x set-variable}.  This reads the variable name with the
  minibuffer (with completion), and then reads a Lisp expression for the
! new value using the minibuffer a second time (you can insert the old
! value into the minibuffer for editing via @kbd{M-n}).  For example,
  
  @example
  M-x set-variable @key{RET} fill-column @key{RET} 75 @key{RET}

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

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

* Re: Defaults for set-variable
  2005-10-19 15:43   ` Juri Linkov
@ 2005-10-20  4:54     ` Richard M. Stallman
  0 siblings, 0 replies; 31+ messages in thread
From: Richard M. Stallman @ 2005-10-20  4:54 UTC (permalink / raw)
  Cc: emacs-devel

    Then what about documenting it in the Emacs manual?  Customization always
    inserts the old value into editable fields in the customization buffer
    (though, not as a Lisp expression that set-variable reads), so I think
    this is a useful thing for users to know that set-variable can provide
    the old value for editing too, via M-n:

Ok.  Please install that patch.

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

* RE: Defaults for set-variable
  2005-10-17 15:35 Defaults for set-variable Juri Linkov
  2005-10-17 21:58 ` Richard M. Stallman
@ 2005-10-31 19:22 ` Drew Adams
  2005-10-31 21:20   ` Miles Bader
  2005-11-01  9:15   ` Juri Linkov
  1 sibling, 2 replies; 31+ messages in thread
From: Drew Adams @ 2005-10-31 19:22 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 behavior before the fix was inconsistent, but it was sometimes useful (a
"feature"?). The fix makes sense, but it's too bad to lose a command that
sets a non user-option variable. (One could even use completion to get the
variable name: `C-h v foo TAB RET'; `M-x set-variable RET RET'.)

It's convenient to have a command to do this, as a shortcut for M-: `(setq
...)' - with `C-u' local option and no eval of value.  Any chance of having
a separate command, which works for any variable?

What's a bit unfortunate is that the name `set-variable' is already taken
(it really means `set-user-option').  `set-any-variable'?

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

* Re: Defaults for set-variable
  2005-10-31 19:22 ` Drew Adams
@ 2005-10-31 21:20   ` Miles Bader
  2005-10-31 22:15     ` Drew Adams
  2005-11-01  9:15   ` Juri Linkov
  1 sibling, 1 reply; 31+ messages in thread
From: Miles Bader @ 2005-10-31 21:20 UTC (permalink / raw)
  Cc: emacs-devel

2005/11/1, Drew Adams <drew.adams@oracle.com>:
> It's convenient to have a command to do this, as a shortcut for M-: `(setq
> ...)' - with `C-u' local option and no eval of value.  Any chance of having
> a separate command, which works for any variable?

Er, "M-: (setq '" is _shorter_ than M-x set-variable RET .... (and
variable-name completion is available via M-TAB).

[For grabbing the name from the buffer, use `C-M-SPC M-w' ... `C-y' 
-- it looks like a mouthful in text, but it's quite fast in practice.]

-miles
--
Do not taunt Happy Fun Ball.

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

* RE: Defaults for set-variable
  2005-10-31 21:20   ` Miles Bader
@ 2005-10-31 22:15     ` Drew Adams
  2005-10-31 23:17       ` Miles Bader
  0 siblings, 1 reply; 31+ messages in thread
From: Drew Adams @ 2005-10-31 22:15 UTC (permalink / raw)


    > It's convenient to have a command to do this, as a shortcut
    > for M-: `(setq ...)' - with `C-u' local option and no eval
    > of value.  Any chance of having a separate command, which
    > works for any variable?

    Er, "M-: (setq '" is _shorter_ than M-x set-variable RET

1. Counting keystrokes (but who's counting?), the two are about the same,
actually:

 M-: (setq SPC 'foo M-TAB SPC value) RET = 12 + foo + value

 vs

 M-x set-va RET foo TAB RET value RET    = 11 + foo + value


2.

    variable-name completion is available via M-TAB

`M-TAB' simply completes any Lisp symbol - it does not offer only variables
as completion candidates. The idea is to have completion against variable
names (only), just as `set-variable' currently offers completion against
user-option names.


3.

    For grabbing the name from the buffer, use `C-M-SPC M-w' ... `C-y'

a) That grabs any word, not just a variable name.
b) If point is in the middle of a name, it grabs only the rest of the name
under point; it does not grab the whole name. You need to start with
`C-M-b'.


4. Making the value local is a separate operation, if you use `M-:'.


Using `(setq foo...)' + `M-TAB' completion + your name-grabbing + a separate
operation for making the value local...takes longer and is more error-prone.

Which do you find more convenient for setting user options - setq or
set-variable? That is, you can use `M-: (setq foo '...)' today for user
options.  Do you, or do you use `M-x set-variable foo ...'?

In any case, there are of course ways to do without such a convenience. The
question is whether or not it is a convenience worth adding to Emacs.

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

* Re: Defaults for set-variable
  2005-10-31 22:15     ` Drew Adams
@ 2005-10-31 23:17       ` Miles Bader
  2005-11-01  0:49         ` Drew Adams
  2005-11-01 11:29         ` Kim F. Storm
  0 siblings, 2 replies; 31+ messages in thread
From: Miles Bader @ 2005-10-31 23:17 UTC (permalink / raw)
  Cc: emacs-devel

> Which do you find more convenient for setting user options - setq or
> set-variable? That is, you can use `M-: (setq foo '...)' today for user
> options.  Do you, or do you use `M-x set-variable foo ...'?

I use setq.

`set-variable' doesn't offer much different really.  It's mainly
useful as a gentle introduction for those who might be confused by
lisp syntax and the presence of internal variables.

> In any case, there are of course ways to do without such a convenience. The
> question is whether or not it is a convenience worth adding to Emacs.

It seems to me it's a "convenience" that applies only in a vanishingly
small number of cases (you want to set a variable which _isn't_ tagged
as a user variable, and just happens to have its name under point in
the current buffer), and not worth bloating the code to support.

-Miles
--
Do not taunt Happy Fun Ball.

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

* RE: Defaults for set-variable
  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
  1 sibling, 1 reply; 31+ messages in thread
From: Drew Adams @ 2005-11-01  0:49 UTC (permalink / raw)


    > Which do you find more convenient for setting user options - setq
    > or set-variable?  That is, you can use `M-: (setq foo '...)'
    > today for user options.  Do you [do that], or do you use
    > `M-x set-variable...'?

    I use setq.

OK.  So do you perhaps also feel that the existing `set-variable' command is
"not worth bloating the code to support"?  At least wrt your own use?  Do
you feel that it might be worth keeping, for use by others?

    `set-variable' [is] mainly useful as a gentle introduction for
    those who might be confused by lisp syntax and the presence of
    internal variables.

I see.  Real Lisp programmers don't...  They don't use commands at all, do
they?

    > The question is whether or not it is a convenience worth
    > adding to Emacs.

    It seems to me it's a "convenience" that applies only in a
    vanishingly small number of cases (you want to set a variable
    which _isn't_ tagged as a user variable, and just happens to
    have its name under point in the current buffer), and not
    worth bloating the code to support.

Your magic appears to produce vanishing out of thin air ;-).  Smoke and
mirrors, perhaps?

I said nothing about the variable name needing to be under point.  The
command would provide  _completion_  of all variable names - not only
user-option names (too hot!), and not all symbol names (too cold!).  (See
"Goldilocks and The 3 Bears", M. Goose, in ACM Communications, July 1324)

Completion doesn't just save a few keystrokes - it lets you know just what
the possible (existing variable) names are, and it prevents spelling errors.
What's good for the user-option goose is good for the any-variable gander -
in my book.

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

* Re: Defaults for set-variable
  2005-11-01  0:49         ` Drew Adams
@ 2005-11-01  2:00           ` Miles Bader
  0 siblings, 0 replies; 31+ messages in thread
From: Miles Bader @ 2005-11-01  2:00 UTC (permalink / raw)
  Cc: emacs-devel

2005/11/1, Drew Adams <drew.adams@oracle.com>:
>     I use setq.
>
> OK.  So do you perhaps also feel that the existing `set-variable' command is
> "not worth bloating the code to support"?  At least wrt your own use?  Do
> you feel that it might be worth keeping, for use by others?
>
>     `set-variable' [is] mainly useful as a gentle introduction for
>     those who might be confused by lisp syntax and the presence of
>     internal variables.
>
> I see.  Real Lisp programmers don't...  They don't use commands at all, do
> they?

Oh for christ's sake, don't get all pissy.

-miles
--
Do not taunt Happy Fun Ball.

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

* Re: Defaults for set-variable
  2005-10-31 19:22 ` Drew Adams
  2005-10-31 21:20   ` Miles Bader
@ 2005-11-01  9:15   ` Juri Linkov
  2005-11-01 13:35     ` David Kastrup
  2005-11-02 10:27     ` Richard M. Stallman
  1 sibling, 2 replies; 31+ messages in thread
From: Juri Linkov @ 2005-11-01  9:15 UTC (permalink / raw)
  Cc: emacs-devel

> What's a bit unfortunate is that the name `set-variable' is already
> taken (it really means `set-user-option').  `set-any-variable'?

What about adding an interactive spec for `setq' which works for
any variable:

    M-x setq RET variable RET value RET

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

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

* Re: Defaults for set-variable
  2005-10-31 23:17       ` Miles Bader
  2005-11-01  0:49         ` Drew Adams
@ 2005-11-01 11:29         ` Kim F. Storm
  1 sibling, 0 replies; 31+ messages in thread
From: Kim F. Storm @ 2005-11-01 11:29 UTC (permalink / raw)
  Cc: emacs-devel, Drew Adams, miles

Miles Bader <snogglethorpe@gmail.com> writes:

>> Which do you find more convenient for setting user options - setq or
>> set-variable? That is, you can use `M-: (setq foo '...)' today for user
>> options.  Do you, or do you use `M-x set-variable foo ...'?
>
> I use setq.
>
> `set-variable' doesn't offer much different really.  It's mainly
> useful as a gentle introduction for those who might be confused by
> lisp syntax and the presence of internal variables.

With my (rejected) support for making built-in functions 
interactive, you could make `set' interactive like this:

(put 'set 'interactive
  "vSet variable: \nXExpression: ")

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: Defaults for set-variable
  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
  1 sibling, 1 reply; 31+ messages in thread
From: David Kastrup @ 2005-11-01 13:35 UTC (permalink / raw)
  Cc: Drew Adams, emacs-devel

Juri Linkov <juri@jurta.org> writes:

>> What's a bit unfortunate is that the name `set-variable' is already
>> taken (it really means `set-user-option').  `set-any-variable'?
>
> What about adding an interactive spec for `setq' which works for
> any variable:
>
>     M-x setq RET variable RET value RET

That would be a mistake, since "q", the need for quoting, is a feature
of the Lisp evaluator, not of the function.  So the right function to
give an interactive spec would be "set", not "setq".

And I am uneasy about giving a low level primitive this sort of
accessibility.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Defaults for set-variable
  2005-11-01 13:35     ` David Kastrup
@ 2005-11-01 14:05       ` Miles Bader
  0 siblings, 0 replies; 31+ messages in thread
From: Miles Bader @ 2005-11-01 14:05 UTC (permalink / raw)
  Cc: Juri Linkov, Drew Adams, emacs-devel

2005/11/1, David Kastrup <dak@gnu.org>:
> And I am uneasy about giving a low level primitive this sort of
> accessibility.

Especially since the name "set" would be so tempting for users (and
familiar from other programs) -- I can imagine new users always using
"M-x set" instead of set-variable (not even realizing the latter
exists) simply because it's the first thing that gets completed to,
and then being annoyed at the presence of all those obscure and
useless variable names that completion shows them...

-miles
--
Do not taunt Happy Fun Ball.

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

* Re: Defaults for set-variable
  2005-11-01  9:15   ` Juri Linkov
  2005-11-01 13:35     ` David Kastrup
@ 2005-11-02 10:27     ` Richard M. Stallman
  2005-11-02 16:22       ` Drew Adams
  1 sibling, 1 reply; 31+ messages in thread
From: Richard M. Stallman @ 2005-11-02 10:27 UTC (permalink / raw)
  Cc: drew.adams, emacs-devel

    What about adding an interactive spec for `setq' which works for
    any variable:

	M-x setq RET variable RET value RET

I don't like the idea of encouraging Emacs users to set variables
that are not user options.

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

* RE: Defaults for set-variable
  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 13:51         ` Richard M. Stallman
  0 siblings, 2 replies; 31+ messages in thread
From: Drew Adams @ 2005-11-02 16:22 UTC (permalink / raw)


    I don't like the idea of encouraging Emacs users to set variables
    that are not user options.

Me neither.  I intended it as a convenience for Lisp programmers.

What about creating a new command `set-any-variable', and disabling it, by
default: (put 'set-any-variable 'disabled t)?  People who want to set non
user-option variables can enable the command.

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

* Re: Defaults for set-variable
  2005-11-02 16:22       ` Drew Adams
@ 2005-11-02 20:41         ` Sascha Wilde
  2005-11-03  7:52           ` Juri Linkov
  2005-11-03 13:51         ` Richard M. Stallman
  1 sibling, 1 reply; 31+ messages in thread
From: Sascha Wilde @ 2005-11-02 20:41 UTC (permalink / raw)
  Cc: emacs-devel

"Drew Adams" <drew.adams@oracle.com> wrote:

>     I don't like the idea of encouraging Emacs users to set variables
>     that are not user options.
>
> Me neither.  I intended it as a convenience for Lisp programmers.

Any Lisp programmer should be able to use M-: or build his own
interactive setq function.  

cheers
sascha
-- 
Sascha Wilde : "GUIs normally make it simple to accomplish simple 
             : actions and impossible to accomplish complex actions."
             : (Doug Gwyn - 22/Jun/91 in comp.unix.wizards)

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

* Re: Defaults for set-variable
  2005-11-02 20:41         ` Sascha Wilde
@ 2005-11-03  7:52           ` Juri Linkov
  2005-11-03  8:53             ` Sascha Wilde
  0 siblings, 1 reply; 31+ messages in thread
From: Juri Linkov @ 2005-11-03  7:52 UTC (permalink / raw)
  Cc: drew.adams, emacs-devel

>>     I don't like the idea of encouraging Emacs users to set variables
>>     that are not user options.
>>
>> Me neither.  I intended it as a convenience for Lisp programmers.
>
> Any Lisp programmer should be able to use M-:

M-: is not convenient as this new command.  It doesn't provide variable
name completion, default values and setting local variables.

> or build his own interactive setq function.

The goal of adding it to Emacs is to share this useful command among
Lisp programmers.

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

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

* Re: Defaults for set-variable
  2005-11-03  7:52           ` Juri Linkov
@ 2005-11-03  8:53             ` Sascha Wilde
  2005-11-03 16:08               ` Drew Adams
  0 siblings, 1 reply; 31+ messages in thread
From: Sascha Wilde @ 2005-11-03  8:53 UTC (permalink / raw)
  Cc: drew.adams, emacs-devel

Juri Linkov <juri@jurta.org> wrote:

>>>     I don't like the idea of encouraging Emacs users to set variables
>>>     that are not user options.
>>>
>>> Me neither.  I intended it as a convenience for Lisp programmers.
>>
>> Any Lisp programmer should be able to use M-:
>
> M-: is not convenient as this new command.  It doesn't provide variable
> name completion,

well, it does, using M-TAB

> default values and setting local variables.

ack

>> or build his own interactive setq function.
>
> The goal of adding it to Emacs is to share this useful command among
> Lisp programmers.

You convinced me, being a quite convenient function, this might be a
good Idea.  But I also agree with Drew, that there should be no
default key-binding and it should be disabled.

cheers
sascha
-- 
Sascha Wilde
Wer HTML postet oder gepostetes HTML quotet oder sich gepostetes oder
gequotetes HTML beschafft, um es in Verkehr zu bringen, wird geplonkt.

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

* Re: Defaults for set-variable
  2005-11-02 16:22       ` Drew Adams
  2005-11-02 20:41         ` Sascha Wilde
@ 2005-11-03 13:51         ` Richard M. Stallman
  1 sibling, 0 replies; 31+ messages in thread
From: Richard M. Stallman @ 2005-11-03 13:51 UTC (permalink / raw)
  Cc: emacs-devel

    What about creating a new command `set-any-variable', and disabling it, by
    default: (put 'set-any-variable 'disabled t)?  People who want to set non
    user-option variables can enable the command.

I prefer a different option: just doing nothing about this.

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

* RE: Defaults for set-variable
  2005-11-03  8:53             ` Sascha Wilde
@ 2005-11-03 16:08               ` Drew Adams
  2005-11-04  1:46                 ` Miles Bader
  0 siblings, 1 reply; 31+ messages in thread
From: Drew Adams @ 2005-11-03 16:08 UTC (permalink / raw)


    > M-: is not convenient as this new command.  It doesn't
    > provide variable name completion,

    well, it does, using M-TAB

No.  We've been through this loop before...  M-TAB completion completes
_any Lisp symbol_  name. What we're talking about here is completing only
_variable_  names - and not just  _user-option_  names.

    You convinced me, being a quite convenient function, this might be a
    good Idea.  But I also agree with Drew, that there should be no
    default key-binding and it should be disabled.

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

* Re: Defaults for set-variable
  2005-11-03 16:08               ` Drew Adams
@ 2005-11-04  1:46                 ` Miles Bader
  2005-11-04 12:07                   ` Juri Linkov
  0 siblings, 1 reply; 31+ messages in thread
From: Miles Bader @ 2005-11-04  1:46 UTC (permalink / raw)
  Cc: emacs-devel

2005/11/4, Drew Adams <drew.adams@oracle.com>:
>     > M-: is not convenient as this new command.  It doesn't
>     > provide variable name completion,
>
>     well, it does, using M-TAB
>
> No.  We've been through this loop before...  M-TAB completion completes
> _any Lisp symbol_  name. What we're talking about here is completing only
> _variable_  names - and not just  _user-option_  names.

Yes.  What you haven't shown is whether this is a compelling issue or not.

It's clear that there are infinite numbers of "convenience" functions
one could write, to optimize usage for particular special cases. 
However we obviously can't create _all_ convenience functions, because
the resulting code and (especially) namespace bloat have a bigger
downside that the small convenience offered, multiplied by the rare
instance of use.

>From my personal experience, I claim that the frequency with which one
sets variables by hand which _aren't_ "user variables" is very low --
and as an Emacs hacker, I probably do so more often than an average
user.  Thus, given that the proposed function offers at best, a rather
minor increase in convenience, and will be used very rarely, it simply
isn't worth the code/namespace bloat; existing more general functions
as M-: are "convenient enough", and used much more often.

Morever, if there's a particular non-user variable you find yourself
often setting, that's more likely to be an argument for making that
variable a user-variable than an argument for making setting
non-user-variables easier.

-miles
--
Do not taunt Happy Fun Ball.

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

* Re: Defaults for set-variable
  2005-11-04  1:46                 ` Miles Bader
@ 2005-11-04 12:07                   ` Juri Linkov
  2005-11-04 12:35                     ` David Kastrup
  0 siblings, 1 reply; 31+ messages in thread
From: Juri Linkov @ 2005-11-04 12:07 UTC (permalink / raw)
  Cc: emacs-devel, drew.adams, miles

> From my personal experience, I claim that the frequency with which one
> sets variables by hand which _aren't_ "user variables" is very low --
> and as an Emacs hacker, I probably do so more often than an average
> user.  Thus, given that the proposed function offers at best, a rather
> minor increase in convenience, and will be used very rarely, it simply
> isn't worth the code/namespace bloat; existing more general functions
> as M-: are "convenient enough", and used much more often.

When I need to set a variable value, first I use `M-x set-variable RET'
(for its completion and default values), then if for some reason the
documentation string misses the star, I have to type C-g, and either
to type the variable name after `M-: setq ...' (this is too error-prone),
or to type `C-h v variable' (with completion) and to copy its name
from the *Help* buffer to the `M-: setq ...' minibuffer.  This is
very inconvenient.

> Morever, if there's a particular non-user variable you find yourself
> often setting, that's more likely to be an argument for making that
> variable a user-variable than an argument for making setting
> non-user-variables easier.

The current state of affairs in regard to this is quite confusing.
Neither the Emacs manual nor the Emacs Lisp manual define the term
"user variable", but at the same `user-variable-p' is the function
that is used by `set-variable' to restrict the set of variables
available for this function.  OTOH, the Emacs manual defines the term
"user option" as a variable that the user can customize with the
Customization interface.

So there are only two layers: variables (defined by `defvar') and
user options (defined by `defcustom').  An additional layer of
variables marked with a funny * in the documentation string seems
unnecessary.

With this clear distinction between variables and user options
it makes sense to have two commands:

1. `set-variable' as a convenient replacement of M-: (setq variable ...)
that can set any variable.

2. `set-user-option' as a fast but limited replacement of Customize
for setting user options in the minibuffer.

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

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

* Re: Defaults for set-variable
  2005-11-04 12:07                   ` Juri Linkov
@ 2005-11-04 12:35                     ` David Kastrup
  2005-11-05  9:44                       ` Juri Linkov
  0 siblings, 1 reply; 31+ messages in thread
From: David Kastrup @ 2005-11-04 12:35 UTC (permalink / raw)
  Cc: miles, snogglethorpe, drew.adams, emacs-devel

Juri Linkov <juri@jurta.org> writes:

> So there are only two layers: variables (defined by `defvar') and
> user options (defined by `defcustom').  An additional layer of
> variables marked with a funny * in the documentation string seems
> unnecessary.

I disagree.  For example, variables that are intended to be let-bound
are defined with defvar, but should certainly not set with
set-variable.  Then there are variables that are intended for internal
purposes in a package.  Those should also not be set with
set-variable.

Customized variables make only sense where we are talking about a
state that is intended to be preserved across sessions.  For example,
buffer-local variables would not make sense to put into customize.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Defaults for set-variable
  2005-11-04 12:35                     ` David Kastrup
@ 2005-11-05  9:44                       ` Juri Linkov
  2005-11-08 19:45                         ` Kevin Rodgers
  0 siblings, 1 reply; 31+ messages in thread
From: Juri Linkov @ 2005-11-05  9:44 UTC (permalink / raw)
  Cc: miles, snogglethorpe, drew.adams, emacs-devel

> Customized variables make only sense where we are talking about a
> state that is intended to be preserved across sessions.  For example,
> buffer-local variables would not make sense to put into customize.

I completely agree with the Emacs Lisp manual where it says that
programmers should nearly always use `defcustom' instead of `defvar'
to define user options.  Perhaps Customize should support cases
you mentioned (buffer-local user options) with using a special
tag in `defcustom', for the sake of marking such variable as
user options (instead of the clumsy * in the documentation string),
and possibly also providing a special user interface for changing them.

In regard to `set-variable', the Emacs manual contains in the node
(info "(emacs)Examining"):

  `C-h v VAR <RET>'
       Display the value and documentation of variable VAR
       (`describe-variable').

  `M-x set-variable <RET> VAR <RET> VALUE <RET>'
       Change the value of variable VAR to VALUE.

This clearly indicates that these commands are complementary:
`describe-variable' displays the value of any variable, and
`set-variable' changes its value.  It unambiguously says that
it changes a variable, not an user option.

The current implementation contradicts the command name `set-variable'
and its documentation.

I see only one way to avoid this inconsistency - to have two commands:
`set-variable' for setting variables, and `set-user-option' for setting
user options.

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

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

* Re: Defaults for set-variable
  2005-11-05  9:44                       ` Juri Linkov
@ 2005-11-08 19:45                         ` Kevin Rodgers
  2005-11-08 22:05                           ` Drew Adams
  0 siblings, 1 reply; 31+ messages in thread
From: Kevin Rodgers @ 2005-11-08 19:45 UTC (permalink / raw)


Juri Linkov wrote:
 > In regard to `set-variable', the Emacs manual contains in the node
 > (info "(emacs)Examining"):
 >
 >   `C-h v VAR <RET>'
 >        Display the value and documentation of variable VAR
 >        (`describe-variable').
 >
 >   `M-x set-variable <RET> VAR <RET> VALUE <RET>'
 >        Change the value of variable VAR to VALUE.
 >
 > This clearly indicates that these commands are complementary:
 > `describe-variable' displays the value of any variable, and
 > `set-variable' changes its value.  It unambiguously says that
 > it changes a variable, not an user option.
 >
 > The current implementation contradicts the command name `set-variable'
 > and its documentation.
 >
 > I see only one way to avoid this inconsistency - to have two commands:
 > `set-variable' for setting variables, and `set-user-option' for setting
 > user options.

Why not `C-u M-x set-variable' to set any variable (not just user
options), just like `C-u M-x apropos-variable' shows all variables.

-- 
Kevin Rodgers

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

* RE: Defaults for set-variable
  2005-11-08 19:45                         ` Kevin Rodgers
@ 2005-11-08 22:05                           ` Drew Adams
  2005-11-09  9:34                             ` Juri Linkov
  0 siblings, 1 reply; 31+ messages in thread
From: Drew Adams @ 2005-11-08 22:05 UTC (permalink / raw)


     > In regard to `set-variable', the Emacs manual contains in the node
     > (info "(emacs)Examining"):
     >
     >   `C-h v VAR <RET>'
     >        Display the value and documentation of variable VAR
     >        (`describe-variable').
     >
     >   `M-x set-variable <RET> VAR <RET> VALUE <RET>'
     >        Change the value of variable VAR to VALUE.
     >
     > This clearly indicates that these commands are complementary:
     > `describe-variable' displays the value of any variable, and
     > `set-variable' changes its value.  It unambiguously says that
     > it changes a variable, not an user option.
     >
     > The current implementation contradicts the command name
    `set-variable'
     > and its documentation.
     >
     > I see only one way to avoid this inconsistency - to have two
     > commands:
     > `set-variable' for setting variables, and `set-user-option'
     > for setting user options.

    Why not `C-u M-x set-variable' to set any variable (not just user
    options), just like `C-u M-x apropos-variable' shows all variables.

I would have proposed that long ago, but `C-u' is already defined to set the
variable buffer locally. - Drew

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

* Re: Defaults for set-variable
  2005-11-08 22:05                           ` Drew Adams
@ 2005-11-09  9:34                             ` Juri Linkov
  2005-11-09 13:17                               ` Kim F. Storm
  2005-11-10  2:09                               ` Richard M. Stallman
  0 siblings, 2 replies; 31+ messages in thread
From: Juri Linkov @ 2005-11-09  9:34 UTC (permalink / raw)
  Cc: emacs-devel

>      > I see only one way to avoid this inconsistency - to have two
>      > commands: `set-variable' for setting variables, and
>      > `set-user-option' for setting user options.
>
>     Why not `C-u M-x set-variable' to set any variable (not just user
>     options), just like `C-u M-x apropos-variable' shows all variables.
>
> I would have proposed that long ago, but `C-u' is already defined to
> set the variable buffer locally.

`C-u C-u M-x set-variable'?

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

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

* Re: Defaults for set-variable
  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
  1 sibling, 1 reply; 31+ messages in thread
From: Kim F. Storm @ 2005-11-09 13:17 UTC (permalink / raw)
  Cc: Drew Adams, emacs-devel

Juri Linkov <juri@jurta.org> writes:

>>      > I see only one way to avoid this inconsistency - to have two
>>      > commands: `set-variable' for setting variables, and
>>      > `set-user-option' for setting user options.
>>
>>     Why not `C-u M-x set-variable' to set any variable (not just user
>>     options), just like `C-u M-x apropos-variable' shows all variables.
>>
>> I would have proposed that long ago, but `C-u' is already defined to
>> set the variable buffer locally.
>
> `C-u C-u M-x set-variable'?

And `C-u C-u C-u M-x set-variable' 
is used to set the buffer-local value of any variable... 

1/2 :-)


I would rather reserve C-u M-x set-variable for set any
variable, and make a new command

  M-x set-variable-buffer-local

to set the buffer local value.  It would also have a C-u prefix to
allow setting any variable.


However, if we _don't_ change this, I think it would make a lot
of sense if C-u M-x set-variable changed to prompt from
"Set variable" to "Set variable in <buffer>".


-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: Defaults for set-variable
  2005-11-09 13:17                               ` Kim F. Storm
@ 2005-11-09 17:54                                 ` Juri Linkov
  0 siblings, 0 replies; 31+ messages in thread
From: Juri Linkov @ 2005-11-09 17:54 UTC (permalink / raw)
  Cc: drew.adams, emacs-devel

> I would rather reserve C-u M-x set-variable for set any
> variable, and make a new command
>
>   M-x set-variable-buffer-local
>
> to set the buffer local value.  It would also have a C-u prefix to
> allow setting any variable.

Good!  This is consistent with other commands and convenient as well.

And perhaps like for `apropos-variable' there should be an user option
like `apropos-do-all' to set this permanently. i.e. after
(setq set-variable-do-all t) `set-variable' and `set-variable-buffer-local'
won't require a C-u prefix for setting any variable.

> However, if we _don't_ change this, I think it would make a lot
> of sense if C-u M-x set-variable changed to prompt from
> "Set variable" to "Set variable in <buffer>".

Currently for the second prompt (i.e. reading a variable value)
`set-variable' appends "buffer-locally" or "(buffer-local)".
I think it should append the same text to the first prompt too.

So after typing `M-x set-variable-buffer-local RET'
(or with the current unchanged command: `C-u M-x set-variable RET')
the prompt would be:

  Set variable buffer-locally:

and after the user enters a variable name (e.g. `indent-tabs-mode'),
for the user the second prompt will look like the first prompt
where the string "variable" is replaced with just entered variable name
and the string "to value" appended to the prompt:

  Set indent-tabs-mode buffer-locally to value:

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

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

* Re: Defaults for set-variable
  2005-11-09  9:34                             ` Juri Linkov
  2005-11-09 13:17                               ` Kim F. Storm
@ 2005-11-10  2:09                               ` Richard M. Stallman
  1 sibling, 0 replies; 31+ messages in thread
From: Richard M. Stallman @ 2005-11-10  2:09 UTC (permalink / raw)
  Cc: drew.adams, emacs-devel

    > I would have proposed that long ago, but `C-u' is already defined to
    > set the variable buffer locally.

    `C-u C-u M-x set-variable'?

Please let's drop this issue.  I do not want any such feature.

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