unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* default-fill-column
@ 2003-11-15 16:37 Luc Teirlinck
  2003-11-16 22:58 ` default-fill-column Stefan Monnier
  2003-12-27  4:13 ` default-fill-column Richard Stallman
  0 siblings, 2 replies; 5+ messages in thread
From: Luc Teirlinck @ 2003-11-15 16:37 UTC (permalink / raw)


I use `default-fill-column' as an example, but the remarks below seem to
apply to all variables of the type `default-some-buffer-local-variable'.

Ielm run:

*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (local-variable-p 'fill-column)
nil
ELISP> fill-column
70
ELISP> (setq default-fill-column 75)
75
ELISP> fill-column
70
ELISP> (local-variable-p 'fill-column)
nil
ELISP> (default-value 'fill-column)
75
ELISP> (buffer-local-value 'fill-column (current-buffer))
75
ELISP> fill-column
70

Now fill-column has two values in *ielm*:
The updated default-value accessed by `buffer-local-value' and the old
default-value, accessed by ordinary evaluation.

For instance,`describe-variable' which uses `buffer-local-value' says
that the value is 75.

It seems hard to consider this a "feature".  At the very least, the
fact that C-h v returns a value different from the value returned by
evaluation has to be considered a bug.

Again, `fill-column' is just an example.  There are plenty of similar
variables in Emacs and they all seem to behave this way.

Final remark (continuation of Ielm run):

ELISP> (setq-default fill-column (default-value 'fill-column))
75
ELISP> fill-column
75
ELISP> 

Sincerely,

Luc.

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

* Re: default-fill-column
  2003-11-15 16:37 default-fill-column Luc Teirlinck
@ 2003-11-16 22:58 ` Stefan Monnier
  2003-11-22 21:23   ` default-fill-column Luc Teirlinck
  2003-12-27  4:13 ` default-fill-column Richard Stallman
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2003-11-16 22:58 UTC (permalink / raw)
  Cc: emacs-devel

> I use `default-fill-column' as an example, but the remarks below seem to
> apply to all variables of the type `default-some-buffer-local-variable'.

Looks like a plain bug indeed.
Could we just declare those `default-*' variables obsolete and tell
people to use `setq-default' and `default-value' instead so we can
slowly hope to get rid of those things ?
If Luc's bugs were already present in Emacs-20 and Emacs-21, then we
wouldn't even have to fix them.


        Stefan

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

* Re: default-fill-column
  2003-11-16 22:58 ` default-fill-column Stefan Monnier
@ 2003-11-22 21:23   ` Luc Teirlinck
  2003-11-24 16:23     ` default-fill-column Richard Stallman
  0 siblings, 1 reply; 5+ messages in thread
From: Luc Teirlinck @ 2003-11-22 21:23 UTC (permalink / raw)
  Cc: emacs-devel

First, a reminder of the behavior:

===File ~/nov22ielm=========================================
*** Welcome to IELM ***  Type (describe-mode) for help.
ELISP> (emacs-version)
"GNU Emacs 21.3.50.1 (i686-pc-linux-gnu, X toolkit)\n of 2003-11-22 on swt40.swt.com"
ELISP> (local-variable-p 'fill-column)
nil
ELISP> fill-column
70
ELISP> (setq default-fill-column 75)
75
ELISP> fill-column
70
ELISP> (local-variable-p 'fill-column)
nil
ELISP> (default-value 'fill-column)
75
ELISP> (buffer-local-value 'fill-column (current-buffer))
75
ELISP> fill-column
70
ELISP> (setq-default fill-column (default-value 'fill-column))
75
ELISP> fill-column
75
ELISP> 
============================================================

`default-fill-column' is just an example.  The same holds for other
variables of the same type.

Reminder of Stefan's response:

   Looks like a plain bug indeed.
   Could we just declare those `default-*' variables obsolete and tell
   people to use `setq-default' and `default-value' instead so we can
   slowly hope to get rid of those things ?
   If Luc's bugs were already present in Emacs-20 and Emacs-21, then we
   wouldn't even have to fix them.

That would, according to me, be a satisfactory solution.  There could
be one problem, however.  Indeed, the functionality of these variables
is not equivalent with `setq-default'.  `setq-default' changes the
value in all buffers without buffer-local binding, whereas
(setq default-fill-column 75) only affects the value in newly created
buffers.  This is achieved in a very precarious way, however, because
both the preserved value itself and its type (buffer-local versus
default) are ambiguous and unstable.  If one wants to make new
defaults for these variables apply only to newly created buffers,
either automatically or as an option, then I see at least three
possibilities:

1.  Make all these variables behave like enable-multibyte-characters
    and default-enable-multibyte-characters.  For those, there is no
    problem, because enable-multibyte-characters is always
    buffer-local, even if the user never set it, and
    kill-local-variable has no effect on it.  Thus the default value
    always only affects newly created buffers and the problem in the
    above *ielm* run never occurs for them.

2.  Make setq-default and set-default, for these variables, scan
    through the buffer-list and make all current global values
    buffer-local before resetting the default.

3.  Leave setq-default and set-default alone, but define a new
    function set-default-new-buffers (or whatever) that would behave
    as described in (2), not just for the variables we are talking
    about, but for all variables.  It seems to me that this function
    could be written in Lisp and that this would not be too difficult.
    Could be useful for other variables too.

(2) and (3) still would require making the default-* variables
obsolete (but without loosing their functionality), whereas (1) would
get rid of the problem without a need to slowly get rid of them.

Sincerely,

Luc.

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

* Re: default-fill-column
  2003-11-22 21:23   ` default-fill-column Luc Teirlinck
@ 2003-11-24 16:23     ` Richard Stallman
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Stallman @ 2003-11-24 16:23 UTC (permalink / raw)
  Cc: monnier, emacs-devel

      Indeed, the functionality of these variables
    is not equivalent with `setq-default'.  `setq-default' changes the
    value in all buffers without buffer-local binding, whereas
    (setq default-fill-column 75) only affects the value in newly created
    buffers.

This is a bug; setting default-fill-column was supposed to be
equivalent to using setq-default on fill-column.
The doc string of default-fill-column says so explicitly.

      If one wants to make new
    defaults for these variables apply only to newly created buffers,

We don't want that--that's the bug.

I think the correct solution to implement a new kind of internally magic
variable which stands for the default value of some other variable.
Then default-fill-column can be implemented that way.  It would
be fairly clean and not that hard.

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

* Re: default-fill-column
  2003-11-15 16:37 default-fill-column Luc Teirlinck
  2003-11-16 22:58 ` default-fill-column Stefan Monnier
@ 2003-12-27  4:13 ` Richard Stallman
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Stallman @ 2003-12-27  4:13 UTC (permalink / raw)
  Cc: emacs-devel

I will fix this.

    I use `default-fill-column' as an example, but the remarks below seem to
    apply to all variables of the type `default-some-buffer-local-variable'.

    Ielm run:

    *** Welcome to IELM ***  Type (describe-mode) for help.
    ELISP> (local-variable-p 'fill-column)
    nil
    ELISP> fill-column
    70
    ELISP> (setq default-fill-column 75)
    75
    ELISP> fill-column
    70

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

end of thread, other threads:[~2003-12-27  4:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-15 16:37 default-fill-column Luc Teirlinck
2003-11-16 22:58 ` default-fill-column Stefan Monnier
2003-11-22 21:23   ` default-fill-column Luc Teirlinck
2003-11-24 16:23     ` default-fill-column Richard Stallman
2003-12-27  4:13 ` default-fill-column Richard 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).