* bug#51580: hl-line-mode doesn't override global-hl-line-mode in current buffer
@ 2021-11-03 6:47 Stefan Kangas
2021-11-03 10:06 ` Gregory Heytings
2022-09-20 11:55 ` Lars Ingebrigtsen
0 siblings, 2 replies; 9+ messages in thread
From: Stefan Kangas @ 2021-11-03 6:47 UTC (permalink / raw)
To: 51580
It seems like there is currently no way to use `global-hl-line-mode'
while disabling it for individual buffers.
Steps to reproduce:
0. emacs -Q
1. M-x global-hl-line-mode
2. M-x hl-line-mode
Now, `global-hl-line-mode' is still in effect, and lines are still
highlighted. I expect that running `hl-line-mode' turns off line
highlighting.
There is a comment in hl-line.el saying:
;; You could make variable `global-hl-line-mode' buffer-local and set
;; it to nil to avoid highlighting specific buffers, when the global
;; mode is used.
However, if I say M-x global-hl-line-mode and then
M-: (setq-default global-hl-line-mode nil)
the highlighting overlay is left on the current line.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#51580: hl-line-mode doesn't override global-hl-line-mode in current buffer
2021-11-03 6:47 bug#51580: hl-line-mode doesn't override global-hl-line-mode in current buffer Stefan Kangas
@ 2021-11-03 10:06 ` Gregory Heytings
2021-11-03 11:28 ` Stefan Kangas
2022-09-20 11:55 ` Lars Ingebrigtsen
1 sibling, 1 reply; 9+ messages in thread
From: Gregory Heytings @ 2021-11-03 10:06 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 51580
>
> It seems like there is currently no way to use `global-hl-line-mode'
> while disabling it for individual buffers.
>
There is one: (setq-local global-hl-line-mode nil).
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#51580: hl-line-mode doesn't override global-hl-line-mode in current buffer
2021-11-03 10:06 ` Gregory Heytings
@ 2021-11-03 11:28 ` Stefan Kangas
2021-11-03 11:42 ` Gregory Heytings
0 siblings, 1 reply; 9+ messages in thread
From: Stefan Kangas @ 2021-11-03 11:28 UTC (permalink / raw)
To: Gregory Heytings; +Cc: 51580
Gregory Heytings <gregory@heytings.org> writes:
> > It seems like there is currently no way to use `global-hl-line-mode'
> > while disabling it for individual buffers.
>
> There is one: (setq-local global-hl-line-mode nil).
Here, that leaves an overlay in the buffer. Does it not do that for you?
[You didn't quote it, but I wrote "(setq-default global-hl-line-mode
nil)" in the bug report. That was a typo. I meant to write
"(setq-local global-hl-line-mode nil)".]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#51580: hl-line-mode doesn't override global-hl-line-mode in current buffer
2021-11-03 11:28 ` Stefan Kangas
@ 2021-11-03 11:42 ` Gregory Heytings
2021-11-03 11:51 ` Gregory Heytings
2021-11-04 0:06 ` Stefan Kangas
0 siblings, 2 replies; 9+ messages in thread
From: Gregory Heytings @ 2021-11-03 11:42 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 51580
>>> It seems like there is currently no way to use `global-hl-line-mode'
>>> while disabling it for individual buffers.
>>
>> There is one: (setq-local global-hl-line-mode nil).
>
> Here, that leaves an overlay in the buffer. Does it not do that for
> you?
>
> [You didn't quote it, but I wrote "(setq-default global-hl-line-mode
> nil)" in the bug report. That was a typo. I meant to write
> "(setq-local global-hl-line-mode nil)".]
>
Oh, now I see what you mean. Indeed I had seen your setq-default, but did
not guess it meant setq-local. Indeed, M-: (setq-local
global-hl-line-mode nil) leaves an overlay in the buffer. I use this in
buffer setup hooks, so the overlay is not created. If you want to remove
that overlay, you also need to call global-hl-line-unhighlight:
(defun buffer-deactivate-global-hl-line-mode ()
(interactive)
(global-hl-line-unhighlight)
(setq-local global-hl-line-mode nil))
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#51580: hl-line-mode doesn't override global-hl-line-mode in current buffer
2021-11-03 11:42 ` Gregory Heytings
@ 2021-11-03 11:51 ` Gregory Heytings
2021-11-03 13:11 ` Gregory Heytings
2021-11-04 0:06 ` Stefan Kangas
1 sibling, 1 reply; 9+ messages in thread
From: Gregory Heytings @ 2021-11-03 11:51 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 51580
And of course this could become a command:
(defun buffer-toggle-global-hl-line-mode ()
(interactive)
(make-variable-buffer-local 'global-hl-line-mode)
(if global-hl-line-mode
(global-hl-line-unhighlight)
(global-hl-line-highlight))
(setq global-hl-line-mode (not global-hl-line-mode)))
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#51580: hl-line-mode doesn't override global-hl-line-mode in current buffer
2021-11-03 11:42 ` Gregory Heytings
2021-11-03 11:51 ` Gregory Heytings
@ 2021-11-04 0:06 ` Stefan Kangas
2021-11-04 18:09 ` Lars Ingebrigtsen
1 sibling, 1 reply; 9+ messages in thread
From: Stefan Kangas @ 2021-11-04 0:06 UTC (permalink / raw)
To: Gregory Heytings; +Cc: 51580
Gregory Heytings <gregory@heytings.org> writes:
>>>> It seems like there is currently no way to use `global-hl-line-mode' while
>>>> disabling it for individual buffers.
>>>
>>> There is one: (setq-local global-hl-line-mode nil).
>>
>> Here, that leaves an overlay in the buffer. Does it not do that for you?
>>
>> [You didn't quote it, but I wrote "(setq-default global-hl-line-mode nil)" in
>> the bug report. That was a typo. I meant to write "(setq-local
>> global-hl-line-mode nil)".]
>>
>
> Oh, now I see what you mean. Indeed I had seen your setq-default, but did not
> guess it meant setq-local. Indeed, M-: (setq-local global-hl-line-mode nil)
> leaves an overlay in the buffer. I use this in buffer setup hooks, so the
> overlay is not created. If you want to remove that overlay, you also need to
> call global-hl-line-unhighlight:
>
> (defun buffer-deactivate-global-hl-line-mode ()
> (interactive)
> (global-hl-line-unhighlight)
> (setq-local global-hl-line-mode nil))
My understanding is that our convention for minor modes that provide
both a global and local variant is that calling the local mode should
disable the global mode in the current buffer.
See for example `show-paren-mode' and `show-paren-local-mode'.
So in line with this convention, I expect that no new command is needed:
I should just be able call `M-x hl-line-mode' to disable it.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#51580: hl-line-mode doesn't override global-hl-line-mode in current buffer
2021-11-03 6:47 bug#51580: hl-line-mode doesn't override global-hl-line-mode in current buffer Stefan Kangas
2021-11-03 10:06 ` Gregory Heytings
@ 2022-09-20 11:55 ` Lars Ingebrigtsen
1 sibling, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2022-09-20 11:55 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 51580
Stefan Kangas <stefan@marxist.se> writes:
> It seems like there is currently no way to use `global-hl-line-mode'
> while disabling it for individual buffers.
>
> Steps to reproduce:
>
> 0. emacs -Q
> 1. M-x global-hl-line-mode
> 2. M-x hl-line-mode
>
> Now, `global-hl-line-mode' is still in effect, and lines are still
> highlighted. I expect that running `hl-line-mode' turns off line
> highlighting.
I've now fixed this in Emacs 29.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-09-20 11:55 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-03 6:47 bug#51580: hl-line-mode doesn't override global-hl-line-mode in current buffer Stefan Kangas
2021-11-03 10:06 ` Gregory Heytings
2021-11-03 11:28 ` Stefan Kangas
2021-11-03 11:42 ` Gregory Heytings
2021-11-03 11:51 ` Gregory Heytings
2021-11-03 13:11 ` Gregory Heytings
2021-11-04 0:06 ` Stefan Kangas
2021-11-04 18:09 ` Lars Ingebrigtsen
2022-09-20 11:55 ` Lars Ingebrigtsen
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.