bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#4366: 23.1; Can't turn off visual-line-mode via html-mode-hook


From: Juanma Barranquero
Subject: bug#4366: 23.1; Can't turn off visual-line-mode via html-mode-hook
Date: Fri, 8 Jan 2010 05:12:16 +0100

On Mon, Sep 7, 2009 at 16:14, Allan Gottlieb <address@hidden> wrote:

> Start emacs -Q
> (load-file "/tmp/fun.el")
> (global-visual-line-mode)
> (add-hook 'html-mode-hook 'visual-off-fill-on)
> (find-file "/tmp/x.html")   ; non-existent file
>
> mode line shows fill as expected, but also shows wrap, the bug.
>
> However, if one does instead
>
> Start emacs -Q
> (load-file "/tmp/fun.el")
> (global-visual-line-mode)
> (find-file "/tmp/x.html")   ; non-existent file
> (visual-off-fill-on)
>
> then all is well (mode line shows fill and not wrap).

That is not a bug. When you do (global-visual-line-mode)  [which
should better be (global-visual-line-mode 1), BTW], the function adds
code to several hooks to check for new buffers (find-file-hook, etc.).

In your first case, the global mode is active (so the hooks are
active); when you run find-file, it creates the buffer, runs
html-mode-hook (disabling visual-line-mode), and finally a hook is run
which activates the mode.

In the second case, you activate the global mode, run find-file (and
the hooks check that visual mode is active, so do nothing), and
finally run visual-off-fill-on, deactivating the visual-line mode.

If you want to deactivate the mode automatically after find-file,
there are several ways, like an `after' advice for find-file, or
adding code to the relevant hooks, etc.

    Juanma






reply via email to

[Prev in Thread] Current Thread [Next in Thread]