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

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

bug#52980: elide-head and revert-buffer interaction stops elide-head-sho


From: jakanakaevangeli
Subject: bug#52980: elide-head and revert-buffer interaction stops elide-head-show from working
Date: Tue, 04 Jan 2022 18:08:37 +0100

Just one minor suggestion from me:

Stefan Kangas <stefan@marxist.se> writes:

> tags 52980 + patch
> thanks
>
> Stefan Kangas <stefan@marxist.se> writes:
>
>> I started looking into a solution with {before,after}-revert-hook, but
>> that just seems duplicate what we would get from just using a minor
>> mode.  So I'm starting to think that `elide-head' and `elide-head-show'
>> should be obsoleted in favor of a new local minor mode
>> `elide-head-mode'.
>>
>> That would also save me from having to add a third command
>> `elide-head-toggle' to toggle the hiding on or off.
>
> Here's a patch.
> [...]
> 
> +;;;###autoload
> +(define-minor-mode elide-head-mode
> +  "Toggle eliding (hiding) header material in the current buffer.
> +
> +When Elide Header mode is enabled, headers are hidden according
> +to `elide-head-headers-to-hide'.
> +
> +This is suitable as an entry on `find-file-hook' or appropriate
> +mode hooks."
> +  :group 'elide-head
> +  (if elide-head-mode
> +      (progn
> +        (elide-head--hide)
> +        (add-hook 'before-revert-hook 'elide-head--delete-overlay nil 
> 'local))
> +    (elide-head--show)
> +    (remove-hook 'before-revert-hook 'elide-head--delete-overlay 'local)))

Perhaps change-major-mode-hook would be more appropriate as suggested by
"(elisp) Creating Buffer-Local". That would make the minor mode clean up
its overlay if the user executes M-x normal-mode in addition to M-x
revert-buffer.

> [...]

Best regards.





reply via email to

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