* Major mode weirdness. @ 2011-07-13 15:25 R. Clayton 2011-07-13 17:15 ` Daniel Schoepe ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: R. Clayton @ 2011-07-13 15:25 UTC (permalink / raw) To: help-gnu-emacs I am running GNU Emacs 23.3.1 (i486-pc-linux-gnu, GTK+ Version 2.24.3) of 2011-04-10 on raven, modified by Debian on a debian testing system updated weekly. I have noticed that the initial scratch buffer, the one you get when you just run emacs with no command-line arguments, is in fundamental mode, even though .emacs contains, in custom-set-variables, '(initial-major-mode (quote text-mode)) and help-variable in *scratch* reports initial-major-mode's value is text-mode. What is the error I'm making in trying to get the initial buffer to be in text mode? I have also noticed that doing (setq major-mode 'text-mode) in .emacs has no effect: new buffers are set to fundamental mode rather than text mode. The help-variable documentation for major-mode indicates that setting help-mode makes it buffer local, which seems like strange behavior for a variable that's supposed to provide a global value. Setting major-mode in custom-set-variables works as expected. Although I expect I know the answer to this one, I'll ask it anyway: why is it that a "top-level" setq on major-mode in .emacs doesn't work? Also, top-level setqs on initial-major-mode and major-mode used to work as expected up until a few weeks ago. What has changed since then? Searching around in the /usr/share/doc/emacs23 change files doesn't produce anything I can recognize as an explanation. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Major mode weirdness. 2011-07-13 15:25 Major mode weirdness R. Clayton @ 2011-07-13 17:15 ` Daniel Schoepe 2011-07-13 18:37 ` Valentin Plechinger 2011-07-13 19:42 ` PJ Weisberg 2 siblings, 0 replies; 9+ messages in thread From: Daniel Schoepe @ 2011-07-13 17:15 UTC (permalink / raw) To: R. Clayton, help-gnu-emacs [-- Attachment #1: Type: text/plain, Size: 3146 bytes --] On Wed, 13 Jul 2011 11:25:10 -0400, rvclayton@verizon.net (R. Clayton) wrote: > I am running GNU Emacs 23.3.1 (i486-pc-linux-gnu, GTK+ Version 2.24.3) of > 2011-04-10 on raven, modified by Debian on a debian testing system updated > weekly. > > I have noticed that the initial scratch buffer, the one you get when you just > run emacs with no command-line arguments, is in fundamental mode, even though > .emacs contains, in custom-set-variables, '(initial-major-mode (quote > text-mode)) and help-variable in *scratch* reports initial-major-mode's value > is text-mode. For me, using a ~/.emacs containing only this, works as expected: (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(initial-major-mode (quote text-mode))) So, your problem might be caused by something else in your configuration. > I have also noticed that doing (setq major-mode 'text-mode) in .emacs has no > effect: new buffers are set to fundamental mode rather than text mode. The > help-variable documentation for major-mode indicates that setting help-mode > makes it buffer local, which seems like strange behavior for a variable that's > supposed to provide a global value. [..] major-mode is not supposed to provide a global value. The idea is that every buffer has its own major-mode, otherwise you couldn't have buffers open for both C and lisp files and have them highlighted differently for example. So it makes perfect sense for major-mode to be buffer-local. If you want to set a default for a buffer-local variable, you can use setq-default, like so: (setq-default major-mode 'text-mode) But because some functions that create a new buffers directly set the major-mode of the buffer (e.g. mail clients creating a buffer to display a message), it is doubtful what that line would actually accomplish. > > Although I expect I know the answer to this one, I'll ask it anyway: why is it > that a "top-level" setq on major-mode in .emacs doesn't work? Since major-mode is buffer-local, that only changes the major-mode for the currently selected buffer when that code is executed (depending on your configuration, that might be the Emacs welcome buffer). > Also, top-level setqs on initial-major-mode and major-mode used to work as > expected up until a few weeks ago. What has changed since then? Searching > around in the /usr/share/doc/emacs23 change files doesn't produce anything I > can recognize as an explanation. What exactly do you mean by work as expected? If you mean that (setq major-mode 'text-mode) used to set the major-mode for the scratch-buffer, then this only could have worked if *scratch* was the current buffer when .emacs was run. I think this is an implementation detail that you should not rely on anyway. About initial-major-mode not working: As I said, I can't reproduce that. (I'm also using Emacs 23.3.1, but from debian unstable). Cheers, Daniel [-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Major mode weirdness. 2011-07-13 15:25 Major mode weirdness R. Clayton 2011-07-13 17:15 ` Daniel Schoepe @ 2011-07-13 18:37 ` Valentin Plechinger 2011-07-13 20:41 ` R. Clayton 2011-07-13 19:42 ` PJ Weisberg 2 siblings, 1 reply; 9+ messages in thread From: Valentin Plechinger @ 2011-07-13 18:37 UTC (permalink / raw) To: Help-gnu-emacs use (setq default-major-mode 'text-mode) for all new buffers (initial *scratch* buffer is different though) R. Clayton wrote: > > I am running GNU Emacs 23.3.1 (i486-pc-linux-gnu, GTK+ Version 2.24.3) of > 2011-04-10 on raven, modified by Debian on a debian testing system updated > weekly. > > I have noticed that the initial scratch buffer, the one you get when you just > run emacs with no command-line arguments, is in fundamental mode, even though > .emacs contains, in custom-set-variables, '(initial-major-mode (quote > text-mode)) and help-variable in *scratch* reports initial-major-mode's value > is text-mode. > > What is the error I'm making in trying to get the initial buffer to be in text > mode? > > I have also noticed that doing (setq major-mode 'text-mode) in .emacs has no > effect: new buffers are set to fundamental mode rather than text mode. The > help-variable documentation for major-mode indicates that setting help-mode > makes it buffer local, which seems like strange behavior for a variable that's > supposed to provide a global value. Setting major-mode in custom-set-variables > works as expected. > > Although I expect I know the answer to this one, I'll ask it anyway: why is it > that a "top-level" setq on major-mode in .emacs doesn't work? > > Also, top-level setqs on initial-major-mode and major-mode used to work as > expected up until a few weeks ago. What has changed since then? Searching > around in the /usr/share/doc/emacs23 change files doesn't produce anything I > can recognize as an explanation. > > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Major mode weirdness. 2011-07-13 18:37 ` Valentin Plechinger @ 2011-07-13 20:41 ` R. Clayton 2011-07-13 21:07 ` Valentin Plechinger 0 siblings, 1 reply; 9+ messages in thread From: R. Clayton @ 2011-07-13 20:41 UTC (permalink / raw) To: help-gnu-emacs use (setq default-major-mode 'text-mode) for all new buffers (initial *scratch* buffer is different though) Ah, but that's what started the problem. I originally had that, but learned, via the help-variable documentation, that default-major-mode is obsolete, and should be replaced by major-mode: default-major-mode is a variable defined in `C source code'. Its value is fundamental-mode This variable is obsolete since 23.2; use `major-mode' instead. Documentation: *Value of `major-mode' for new buffers. Wishing to be up-do-date, I replaced default-major-mode with major-mode, and so began my problems (or at least one of them). ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Major mode weirdness. 2011-07-13 20:41 ` R. Clayton @ 2011-07-13 21:07 ` Valentin Plechinger 2011-07-13 21:20 ` Daniel Schoepe 0 siblings, 1 reply; 9+ messages in thread From: Valentin Plechinger @ 2011-07-13 21:07 UTC (permalink / raw) To: Help-gnu-emacs > This variable is obsolete since 23.2; > use `major-mode' instead. > > Documentation: > *Value of `major-mode' for new buffers. > > Wishing to be up-do-date, I replaced default-major-mode with major-mode, and > so began my problems (or at least one of them). Didn't know that, still if it works perfectly why change it? ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Major mode weirdness. 2011-07-13 21:07 ` Valentin Plechinger @ 2011-07-13 21:20 ` Daniel Schoepe 2011-07-13 21:37 ` Peter Münster 2011-07-13 21:59 ` PJ Weisberg 0 siblings, 2 replies; 9+ messages in thread From: Daniel Schoepe @ 2011-07-13 21:20 UTC (permalink / raw) To: Valentin Plechinger, Help-gnu-emacs [-- Attachment #1: Type: text/plain, Size: 565 bytes --] On Wed, 13 Jul 2011 23:07:52 +0200, Valentin Plechinger <v.plechinger@gmail.com> wrote: > Didn't know that, still if it works perfectly why change it? Because it won't, at some point in the future. By updating it when learning it's deprecated, he saves himself the trouble of figuring out why his configuration suddenly stopped working. (Which was still caused here, but by not checking if the change actually had the desired effect). At any rate, I guess the docstring for default-major-mode possibly should say more than just "use `major-mode' instead" though. [-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Major mode weirdness. 2011-07-13 21:20 ` Daniel Schoepe @ 2011-07-13 21:37 ` Peter Münster 2011-07-13 21:59 ` PJ Weisberg 1 sibling, 0 replies; 9+ messages in thread From: Peter Münster @ 2011-07-13 21:37 UTC (permalink / raw) To: help-gnu-emacs; +Cc: emacs-devel On Wed, Jul 13 2011, Daniel Schoepe wrote: > At any rate, I guess the docstring for default-major-mode possibly > should say more than just "use `major-mode' instead" though. Here a tiny patch (cross-post to emacs.devel): === modified file 'lisp/subr.el' --- lisp/subr.el 2011-07-02 04:27:41 +0000 +++ lisp/subr.el 2011-07-13 21:31:03 +0000 @@ -1174,7 +1174,8 @@ (make-obsolete-variable 'default-buffer-file-type 'buffer-file-type "23.2") (make-obsolete-variable 'default-cursor-in-non-selected-windows 'cursor-in-non-selected-windows "23.2") (make-obsolete-variable 'default-buffer-file-coding-system 'buffer-file-coding-system "23.2") -(make-obsolete-variable 'default-major-mode 'major-mode "23.2") +(make-obsolete-variable 'default-major-mode + "use (setq-default major-mode ...) instead" "23.2") (make-obsolete-variable 'default-enable-multibyte-characters "use enable-multibyte-characters or set-buffer-multibyte instead" "23.2") -- Peter ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Major mode weirdness. 2011-07-13 21:20 ` Daniel Schoepe 2011-07-13 21:37 ` Peter Münster @ 2011-07-13 21:59 ` PJ Weisberg 1 sibling, 0 replies; 9+ messages in thread From: PJ Weisberg @ 2011-07-13 21:59 UTC (permalink / raw) To: Daniel Schoepe; +Cc: Help-gnu-emacs On Wed, Jul 13, 2011 at 2:20 PM, Daniel Schoepe <daniel.schoepe@googlemail.com> wrote: > At any rate, I guess the docstring for default-major-mode possibly > should say more than just "use `major-mode' instead" though. Indeed. In fact, I'm not sure deprecating `default-major-mode' in favor of `major-mode' was a good idea at all. It seems weird to me that setting it's default value via `set-default' is meaningful, but setting it's local value isn't. As an aside, I try to set everything possible through Customize, just in case some things are set up to trigger side-effects. -PJ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Major mode weirdness. 2011-07-13 15:25 Major mode weirdness R. Clayton 2011-07-13 17:15 ` Daniel Schoepe 2011-07-13 18:37 ` Valentin Plechinger @ 2011-07-13 19:42 ` PJ Weisberg 2 siblings, 0 replies; 9+ messages in thread From: PJ Weisberg @ 2011-07-13 19:42 UTC (permalink / raw) To: help-gnu-emacs On Wed, Jul 13, 2011 at 8:25 AM, R. Clayton <rvclayton@verizon.net> wrote: > Although I expect I know the answer to this one, I'll ask it anyway: why is it > that a "top-level" setq on major-mode in .emacs doesn't work? Two reasons: 1) As has already been mentioned, setq sets the buffer-local value in the current buffer, which is *scratch*. I.e., it's not "top-level". 2) The `major-mode' variable gets set when you switch modes, but it doesn't work the other way around.* If you're in lisp interaction mode, and you set `major-mode' to `text-mode', now you're in lisp interaction mode with `major-mode' equal to `text-mode'. All that does is confuse any code that looks at that variable to see what the mode is. To switch to text mode, you have to call the function `text-mode'. *Emacs does use the global default value of `major-mode' to decide which mode to use for new buffers, though. As someone else already mentioned, you can do that with "(setq-default major-mode 'text-mode)". ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-07-13 21:59 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-07-13 15:25 Major mode weirdness R. Clayton 2011-07-13 17:15 ` Daniel Schoepe 2011-07-13 18:37 ` Valentin Plechinger 2011-07-13 20:41 ` R. Clayton 2011-07-13 21:07 ` Valentin Plechinger 2011-07-13 21:20 ` Daniel Schoepe 2011-07-13 21:37 ` Peter Münster 2011-07-13 21:59 ` PJ Weisberg 2011-07-13 19:42 ` PJ Weisberg
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).