* globalized minor modes - priority over mode hook?
@ 2010-04-25 23:42 David Reitter
2010-04-26 14:30 ` Stefan Monnier
0 siblings, 1 reply; 13+ messages in thread
From: David Reitter @ 2010-04-25 23:42 UTC (permalink / raw)
To: emacs-devel@gnu.org devel
`run-mode-hooks' runs the mode hooks first, then after-change-major-mode-hooks.
When a globalized major mode is enabled, then it will install itself in `after-change-major-mode-hooks' and override the more specific major mode hooks, which is not normally what one wants.
For instance, if I want global-visual-line-mode on, but turn off word-wrap in my `latex-mode-hook' in favor for auto-fill, I don't get the expected result. I don't know what happens when local variables are set when a file is loaded - these are specific for the file and should probably override the less-specific global minor mode.
Could globalized minor modes not be enabled earlier?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: globalized minor modes - priority over mode hook?
2010-04-25 23:42 globalized minor modes - priority over mode hook? David Reitter
@ 2010-04-26 14:30 ` Stefan Monnier
2010-04-26 15:41 ` David Reitter
0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2010-04-26 14:30 UTC (permalink / raw)
To: David Reitter; +Cc: emacs-devel@gnu.org devel
> `run-mode-hooks' runs the mode hooks first, then
> after-change-major-mode-hooks.
That would be a bug. Do you have a recipe to reproduce it?
Stefan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: globalized minor modes - priority over mode hook?
2010-04-26 14:30 ` Stefan Monnier
@ 2010-04-26 15:41 ` David Reitter
2010-04-26 16:28 ` Glenn Morris
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: David Reitter @ 2010-04-26 15:41 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel@gnu.org devel
On Apr 26, 2010, at 10:30 AM, Stefan Monnier wrote:
>> `run-mode-hooks' runs the mode hooks first, then
>> after-change-major-mode-hooks.
>
> That would be a bug. Do you have a recipe to reproduce it?
Yes, below.
Looking at the code of `after-find-file', I think file-local variables will similarly be overruled by the global minor mode.
I ended up implementing what I wanted below by setting defaults for `auto-fill-function', but that's more low-level than intended, obviously.
I'm bcc'ing the bug DB.
---
Emacs -Q
(add-hook 'text-mode-hook 'turn-on-word-wrap) ; turns OFF auto-fill
(defvaralias 'auto-fill-mode 'auto-fill-function) ; kludge
(define-globalized-minor-mode global-auto-fill-mode auto-fill-mode turn-on-auto-fill)
(defun turn-on-word-wrap ()
"Turn on Word Wrap mode in current buffer."
(turn-off-auto-fill)
(turn-on-visual-line-mode))
;; demo
(global-auto-fill-mode 1) ; set default
(text-mode)
;; result: auto-fill-mode is on, even though it is intended to be off
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: globalized minor modes - priority over mode hook?
2010-04-26 15:41 ` David Reitter
@ 2010-04-26 16:28 ` Glenn Morris
2010-04-26 17:56 ` Stefan Monnier
2011-10-06 19:34 ` bug#6040: " Glenn Morris
2 siblings, 0 replies; 13+ messages in thread
From: Glenn Morris @ 2010-04-26 16:28 UTC (permalink / raw)
To: David Reitter; +Cc: Stefan Monnier, emacs-devel@gnu.org devel
David Reitter wrote:
> I'm bcc'ing the bug DB.
BCC'ing the bug tracker doesn't work for creating new reports.
It has no idea what package to associate your report with, since it
relies on the To:/Cc: header to figure this out.
Hence 6040 got assigned to debbugs.gnu.org (the default) rather than
emacs.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: globalized minor modes - priority over mode hook?
2010-04-26 15:41 ` David Reitter
2010-04-26 16:28 ` Glenn Morris
@ 2010-04-26 17:56 ` Stefan Monnier
2010-04-26 22:45 ` Lennart Borgman
2010-04-28 2:35 ` Juanma Barranquero
2011-10-06 19:34 ` bug#6040: " Glenn Morris
2 siblings, 2 replies; 13+ messages in thread
From: Stefan Monnier @ 2010-04-26 17:56 UTC (permalink / raw)
To: David Reitter; +Cc: emacs-devel@gnu.org devel
>>> `run-mode-hooks' runs the mode hooks first, then
>>> after-change-major-mode-hooks.
>> That would be a bug. Do you have a recipe to reproduce it?
> Yes, below.
Oops, sorry, I misunderstood.
Yes, indeed, it will be run last. And it will also be run first if the
mode is written "properly" (by inheriting from some other mode).
We should maybe split this into two parts: fundamental-mode-hook and
after-change-major-mode-hook, the first is the one run before any other
mode hook and the second is run after all other mode hooks.
Stefan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: globalized minor modes - priority over mode hook?
2010-04-26 17:56 ` Stefan Monnier
@ 2010-04-26 22:45 ` Lennart Borgman
2010-04-28 2:35 ` Juanma Barranquero
1 sibling, 0 replies; 13+ messages in thread
From: Lennart Borgman @ 2010-04-26 22:45 UTC (permalink / raw)
To: Stefan Monnier; +Cc: David Reitter, emacs-devel@gnu.org devel
On Mon, Apr 26, 2010 at 7:56 PM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>>>> `run-mode-hooks' runs the mode hooks first, then
>>>> after-change-major-mode-hooks.
>>> That would be a bug. Do you have a recipe to reproduce it?
>> Yes, below.
>
> Oops, sorry, I misunderstood.
> Yes, indeed, it will be run last. And it will also be run first if the
> mode is written "properly" (by inheriting from some other mode).
> We should maybe split this into two parts: fundamental-mode-hook and
> after-change-major-mode-hook, the first is the one run before any other
> mode hook and the second is run after all other mode hooks.
Sounds great.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: globalized minor modes - priority over mode hook?
2010-04-26 17:56 ` Stefan Monnier
2010-04-26 22:45 ` Lennart Borgman
@ 2010-04-28 2:35 ` Juanma Barranquero
2010-04-28 14:41 ` Stefan Monnier
2010-04-28 21:53 ` Stefan Monnier
1 sibling, 2 replies; 13+ messages in thread
From: Juanma Barranquero @ 2010-04-28 2:35 UTC (permalink / raw)
To: Stefan Monnier; +Cc: David Reitter, emacs-devel@gnu.org devel
On Mon, Apr 26, 2010 at 19:56, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> Oops, sorry, I misunderstood.
> Yes, indeed, it will be run last. And it will also be run first if the
> mode is written "properly" (by inheriting from some other mode).
> We should maybe split this into two parts: fundamental-mode-hook and
> after-change-major-mode-hook, the first is the one run before any other
> mode hook and the second is run after all other mode hooks.
Has this been fixed by r100061?
Because, for example,
(add-hook 'completion-list-mode-hook (lambda () (linum-mode -1)))
(global-linum-mode 1)
still activates linum-mode in completion buffers.
Juanma
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: globalized minor modes - priority over mode hook?
2010-04-28 2:35 ` Juanma Barranquero
@ 2010-04-28 14:41 ` Stefan Monnier
2010-04-28 21:53 ` Stefan Monnier
1 sibling, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2010-04-28 14:41 UTC (permalink / raw)
To: Juanma Barranquero; +Cc: David Reitter, emacs-devel@gnu.org devel
>> Oops, sorry, I misunderstood.
>> Yes, indeed, it will be run last. And it will also be run first if the
>> mode is written "properly" (by inheriting from some other mode).
>> We should maybe split this into two parts: fundamental-mode-hook and
>> after-change-major-mode-hook, the first is the one run before any other
>> mode hook and the second is run after all other mode hooks.
> Has this been fixed by r100061?
Not yet, no.
Stefan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: globalized minor modes - priority over mode hook?
2010-04-28 2:35 ` Juanma Barranquero
2010-04-28 14:41 ` Stefan Monnier
@ 2010-04-28 21:53 ` Stefan Monnier
2010-04-28 22:10 ` Juanma Barranquero
1 sibling, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2010-04-28 21:53 UTC (permalink / raw)
To: Juanma Barranquero; +Cc: David Reitter, emacs-devel@gnu.org devel
> Because, for example,
> (add-hook 'completion-list-mode-hook (lambda () (linum-mode -1)))
> (global-linum-mode 1)
> still activates linum-mode in completion buffers.
I believe my last changes do make it work right in this case.
Stefan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: globalized minor modes - priority over mode hook?
2010-04-28 21:53 ` Stefan Monnier
@ 2010-04-28 22:10 ` Juanma Barranquero
2010-04-28 22:39 ` Stefan Monnier
0 siblings, 1 reply; 13+ messages in thread
From: Juanma Barranquero @ 2010-04-28 22:10 UTC (permalink / raw)
To: Stefan Monnier; +Cc: David Reitter, emacs-devel@gnu.org devel
On Wed, Apr 28, 2010 at 23:53, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> I believe my last changes do make it work right in this case.
Yes, they do.
As an aside, it would be good to have a simple way to say "I don't
want global mode X applied to buffers Y, Z and W." Otherwise,
disabling and reenabling the global-minor-mode turns it on again on
buffers that previously disabled it via the MODE-hook.
But that's a different problem that the one you just fixed.
Thanks,
Juanma
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: globalized minor modes - priority over mode hook?
2010-04-28 22:10 ` Juanma Barranquero
@ 2010-04-28 22:39 ` Stefan Monnier
2010-04-28 23:02 ` David Reitter
0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2010-04-28 22:39 UTC (permalink / raw)
To: Juanma Barranquero; +Cc: David Reitter, emacs-devel@gnu.org devel
>> I believe my last changes do make it work right in this case.
> Yes, they do.
Thanks for confirming.
> As an aside, it would be good to have a simple way to say "I don't
> want global mode X applied to buffers Y, Z and W."
Yes, that would be a welcome addition.
Stefan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: globalized minor modes - priority over mode hook?
2010-04-28 22:39 ` Stefan Monnier
@ 2010-04-28 23:02 ` David Reitter
0 siblings, 0 replies; 13+ messages in thread
From: David Reitter @ 2010-04-28 23:02 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Juanma Barranquero, emacs-devel@gnu.org devel
On Apr 28, 2010, at 6:39 PM, Stefan Monnier wrote:
>> As an aside, it would be good to have a simple way to say "I don't
>> want global mode X applied to buffers Y, Z and W."
>
> Yes, that would be a welcome addition.
I agree.
Please consider hand-crafting global minor modes in some cases.
Take `visual-line-mode': What it does is to configure a number of variables, most of which are buffer-local:
(line-move-visual truncate-lines truncate-partial-width-windows word-wrap fringe-indicator-alist)
The classic way to configure a default for these would be `set-default'. This seems cleaner and more efficient than automatically deriving a globalized version of the mode that runs (at least) at every major mode change and may then be turned off again by the mode hook.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#6040: globalized minor modes - priority over mode hook?
2010-04-26 15:41 ` David Reitter
2010-04-26 16:28 ` Glenn Morris
2010-04-26 17:56 ` Stefan Monnier
@ 2011-10-06 19:34 ` Glenn Morris
2 siblings, 0 replies; 13+ messages in thread
From: Glenn Morris @ 2011-10-06 19:34 UTC (permalink / raw)
To: 6040-done
Version: 24.1
David Reitter wrote:
> Emacs -Q
>
> (add-hook 'text-mode-hook 'turn-on-word-wrap) ; turns OFF auto-fill
>
> (defvaralias 'auto-fill-mode 'auto-fill-function) ; kludge
> (define-globalized-minor-mode global-auto-fill-mode auto-fill-mode turn-on-auto-fill)
>
> (defun turn-on-word-wrap ()
> "Turn on Word Wrap mode in current buffer."
> (turn-off-auto-fill)
> (turn-on-visual-line-mode))
>
> ;; demo
>
> (global-auto-fill-mode 1) ; set default
> (text-mode)
>
> ;; result: auto-fill-mode is on, even though it is intended to be off
I see this in 23.3 but not the current trunk, so it looks like this was
fixed.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2011-10-06 19:34 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-25 23:42 globalized minor modes - priority over mode hook? David Reitter
2010-04-26 14:30 ` Stefan Monnier
2010-04-26 15:41 ` David Reitter
2010-04-26 16:28 ` Glenn Morris
2010-04-26 17:56 ` Stefan Monnier
2010-04-26 22:45 ` Lennart Borgman
2010-04-28 2:35 ` Juanma Barranquero
2010-04-28 14:41 ` Stefan Monnier
2010-04-28 21:53 ` Stefan Monnier
2010-04-28 22:10 ` Juanma Barranquero
2010-04-28 22:39 ` Stefan Monnier
2010-04-28 23:02 ` David Reitter
2011-10-06 19:34 ` bug#6040: " Glenn Morris
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.