GNU bug report logs -
#73175
30.0.60; toggling emacs-news-view-mode doesn't remove buttons
Previous Next
Reported by: Robert Pluim <rpluim <at> gmail.com>
Date: Wed, 11 Sep 2024 09:43:02 UTC
Severity: normal
Tags: fixed
Found in version 30.0.60
Fixed in version 31.1
Done: Robert Pluim <rpluim <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 73175 in the body.
You can then email your comments to 73175 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73175
; Package
emacs
.
(Wed, 11 Sep 2024 09:43:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Robert Pluim <rpluim <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 11 Sep 2024 09:43:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
src/emacs -Q etc/NEWS
C-x C-q ; buttons appear
C-x C-q ; buttons donʼt disappear
(personally I donʼt mind the buttons, but the intent of faf1f037987c
was to make them disappear).
I came up with the following, but I can never remember all the details
of text property removal (maybe we need a `button-debuttonize-region'?)
diff --git a/lisp/textmodes/emacs-news-mode.el b/lisp/textmodes/emacs-news-mode.el
index edeb1540feb..2cca63071b5 100644
--- a/lisp/textmodes/emacs-news-mode.el
+++ b/lisp/textmodes/emacs-news-mode.el
@@ -112,10 +112,17 @@ emacs-news--mode-common
(define-derived-mode emacs-news-mode text-mode "NEWS"
"Major mode for editing the Emacs NEWS file."
;; Disable buttons.
- (button-mode nil)
+ (button-mode -1)
;; And make the buffer writable. This is used when toggling
;; emacs-news-mode.
(setq buffer-read-only nil)
+ (save-excursion
+ (with-silent-modifications
+ (widen)
+ (remove-text-properties (point-min) (point-max)
+ (button--properties nil nil nil))
+ (add-face-text-property (point-min) (point-max)
+ 'button nil)))
(setq-local fill-paragraph-function #'emacs-news--fill-paragraph)
(emacs-news--mode-common))
In GNU Emacs 30.0.60 (build 4, x86_64-pc-linux-gnu, GTK+ Version
3.24.38, cairo version 1.16.0) of 2024-09-05 built on rltb
Repository revision: fc7581ae2ee9db1e3189b76c66be9cd13f72f004
Repository branch: emacs-30
System Description: Debian GNU/Linux 12 (bookworm)
Robert
--
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73175
; Package
emacs
.
(Fri, 20 Sep 2024 06:54:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 73175 <at> debbugs.gnu.org (full text, mbox):
> src/emacs -Q etc/NEWS
> C-x C-q ; buttons appear
> C-x C-q ; buttons donʼt disappear
>
> (personally I donʼt mind the buttons, but the intent of faf1f037987c
> was to make them disappear).
>
> I came up with the following, but I can never remember all the details
> of text property removal (maybe we need a `button-debuttonize-region'?)
Or `button-unbuttonize-region' (like in `gnus-unbuttonized-mime-types').
> (define-derived-mode emacs-news-mode text-mode "NEWS"
> "Major mode for editing the Emacs NEWS file."
> ;; Disable buttons.
> - (button-mode nil)
> + (button-mode -1)
> ;; And make the buffer writable. This is used when toggling
> ;; emacs-news-mode.
> (setq buffer-read-only nil)
> + (save-excursion
> + (with-silent-modifications
> + (widen)
> + (remove-text-properties (point-min) (point-max)
> + (button--properties nil nil nil))
> + (add-face-text-property (point-min) (point-max)
> + 'button nil)))
Probably it would be the right thing to move this code to `button-mode'
to remove properties when it's disabled.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73175
; Package
emacs
.
(Fri, 20 Sep 2024 09:00:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 73175 <at> debbugs.gnu.org (full text, mbox):
>>>>> On Fri, 20 Sep 2024 09:52:25 +0300, Juri Linkov <juri <at> linkov.net> said:
>> src/emacs -Q etc/NEWS
>> C-x C-q ; buttons appear
>> C-x C-q ; buttons donʼt disappear
>>
>> (personally I donʼt mind the buttons, but the intent of faf1f037987c
>> was to make them disappear).
>>
>> I came up with the following, but I can never remember all the details
>> of text property removal (maybe we need a `button-debuttonize-region'?)
Juri> Or `button-unbuttonize-region' (like in `gnus-unbuttonized-mime-types').
Sure.
>> (define-derived-mode emacs-news-mode text-mode "NEWS"
>> "Major mode for editing the Emacs NEWS file."
>> ;; Disable buttons.
>> - (button-mode nil)
>> + (button-mode -1)
>> ;; And make the buffer writable. This is used when toggling
>> ;; emacs-news-mode.
>> (setq buffer-read-only nil)
>> + (save-excursion
>> + (with-silent-modifications
>> + (widen)
>> + (remove-text-properties (point-min) (point-max)
>> + (button--properties nil nil nil))
>> + (add-face-text-property (point-min) (point-max)
>> + 'button nil)))
Juri> Probably it would be the right thing to move this code to `button-mode'
Juri> to remove properties when it's disabled.
That would be best (assuming Iʼve got the incantation right ;-))
Robert
--
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73175
; Package
emacs
.
(Fri, 20 Sep 2024 12:51:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 73175 <at> debbugs.gnu.org (full text, mbox):
>>>>> On Fri, 20 Sep 2024 10:57:53 +0200, Robert Pluim <rpluim <at> gmail.com> said:
Juri> Probably it would be the right thing to move this code to `button-mode'
Juri> to remove properties when it's disabled.
Robert> That would be best (assuming Iʼve got the incantation right ;-))
Although `button-mode' is described as a mode for button
*navigation*, so changing its behaviour might annoy people. Weʼll let the
maintainers decide that one ☺️
Robert
--
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73175
; Package
emacs
.
(Tue, 24 Sep 2024 06:55:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 73175 <at> debbugs.gnu.org (full text, mbox):
> Juri> Probably it would be the right thing to move this code to `button-mode'
> Juri> to remove properties when it's disabled.
>
> Robert> That would be best (assuming Iʼve got the incantation right ;-))
>
> Although `button-mode' is described as a mode for button
> *navigation*, so changing its behaviour might annoy people. Weʼll let the
> maintainers decide that one ☺️
The change will fix its behaviour only for disabling with
(button-mode -1). I don't see how this might annoy people.
It's the standard thing for a mode to clean up after itself.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73175
; Package
emacs
.
(Tue, 24 Sep 2024 09:32:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 73175 <at> debbugs.gnu.org (full text, mbox):
>>>>> On Tue, 24 Sep 2024 09:39:53 +0300, Juri Linkov <juri <at> linkov.net> said:
Juri> Probably it would be the right thing to move this code to `button-mode'
Juri> to remove properties when it's disabled.
>>
Robert> That would be best (assuming Iʼve got the incantation right ;-))
>>
>> Although `button-mode' is described as a mode for button
>> *navigation*, so changing its behaviour might annoy people. Weʼll let the
>> maintainers decide that one ☺️
Juri> The change will fix its behaviour only for disabling with
Juri> (button-mode -1). I don't see how this might annoy people.
Juri> It's the standard thing for a mode to clean up after itself.
OK. Are we agreed that `unbuttonize-region' is a good name before I
update the manual?
(Hmm, `buttonize-region' isnʼt in the elisp manual. Iʼm assuming
emacs-30 is still open for documentation changes, if not I can fix
that on master.)
Robert
--
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73175
; Package
emacs
.
(Tue, 24 Sep 2024 12:27:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 73175 <at> debbugs.gnu.org (full text, mbox):
> Cc: 73175 <at> debbugs.gnu.org
> From: Robert Pluim <rpluim <at> gmail.com>
> Date: Tue, 24 Sep 2024 11:29:45 +0200
>
> Hmm, `buttonize-region' isnʼt in the elisp manual. Iʼm assuming
> emacs-30 is still open for documentation changes
Yes, thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73175
; Package
emacs
.
(Tue, 24 Sep 2024 16:11:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 73175 <at> debbugs.gnu.org (full text, mbox):
>>>>> On Tue, 24 Sep 2024 15:25:14 +0300, Eli Zaretskii <eliz <at> gnu.org> said:
>> Cc: 73175 <at> debbugs.gnu.org
>> From: Robert Pluim <rpluim <at> gmail.com>
>> Date: Tue, 24 Sep 2024 11:29:45 +0200
>>
>> Hmm, `buttonize-region' isnʼt in the elisp manual. Iʼm assuming
>> emacs-30 is still open for documentation changes
Eli> Yes, thanks.
OK. Done.
Iʼve just remembered that button.el can use either overlays or text
properties to make buttons, so `unbuttonize-region' should look like
this:
(defun unbuttonize-region (start end)
"Remove all the buttons between START and END.
This removes both text-property and overlay based buttons."
(dolist (o (overlays-in start end))
(when (overlay-get o 'button)
(delete-overlay o)))
(with-silent-modifications
(remove-text-properties start end
(button--properties nil nil nil))
(add-face-text-property start end
'button nil)))
Robert
--
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#73175
; Package
emacs
.
(Fri, 11 Oct 2024 10:20:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 73175 <at> debbugs.gnu.org (full text, mbox):
tags 73175 fixed
close 73175 31.1
quit
Closing.
Committed as e631a3f3067
Robert
--
Added tag(s) fixed.
Request was from
Robert Pluim <rpluim <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Fri, 11 Oct 2024 10:20:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 31.1, send any further explanations to
73175 <at> debbugs.gnu.org and Robert Pluim <rpluim <at> gmail.com>
Request was from
Robert Pluim <rpluim <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Fri, 11 Oct 2024 10:20:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 08 Nov 2024 12:24:12 GMT)
Full text and
rfc822 format available.
This bug report was last modified 224 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.