GNU bug report logs -
#36837
26.2; whitespace-mode: whitespace-line-column is not set to local fill-column
Previous Next
Reported by: tastytea <tastytea <at> tastytea.de>
Date: Mon, 29 Jul 2019 14:40:02 UTC
Severity: minor
Found in version 26.2
Fixed in version 28.1
Done: Noam Postavsky <npostavs <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On Mon, 29 Jul 2019 11:17:56 +0200
tastytea <at> tastytea.de wrote:
> whitespace-mode will highlight long lines starting at 70 characters
> instead of what fill-column is set to, if whitespace-line-column is set
> to nil.
>
> To reproduce:
>
> 1. Create the file test.cfg with this as the first line:
>
> # -*- fill-column: 200 -*-
>
> 2. Run emacs -Q
>
> 3. Execute the following commands:
>
> (setq whitespace-line-column nil)
> (add-hook 'conf-mode-hook
> (lambda () (whitespace-mode)))
>
> 4. Open test.cfg and type more than 70 characters
>
> After disabling whitespace-mode and enabling it again,
> whitespace-line-column is set correctly to 200.
Yes, unfortunately, file-local variables are only setup (via
`hack-local-variables') _after_ the mode hooks are run (cf.
`run-mode-hooks'), so `whitespace-color-on' still sees the original
`fill-column' the first time.
Intuitively this order seems backwards to me, but I assume there must be
a (good?) reason? I'd like to hear it, in any case.
You can work around this by hacking^W having `hack-local-variables' also
run in your hook function:
(add-hook 'conf-mode-hook
(lambda () (hack-local-variables) (whitespace-mode))
BTW, it's usually better (e.g. for debugging purposes,
removal/modification etc.) not to put lambdas into hooks. If you only
need a particular mode, i.e. a single function/command, the lambda is
redundant anyway:
(add-hook 'some-hook #'some-mode)
If you need more I suggest defining a named function.
HTH,
--
Štěpán
This bug report was last modified 5 years and 85 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.