unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#73175: 30.0.60; toggling emacs-news-view-mode doesn't remove buttons
@ 2024-09-11  9:42 Robert Pluim
  2024-09-20  6:52 ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: Robert Pluim @ 2024-09-11  9:42 UTC (permalink / raw)
  To: 73175


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
-- 





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#73175: 30.0.60; toggling emacs-news-view-mode doesn't remove buttons
  2024-09-11  9:42 bug#73175: 30.0.60; toggling emacs-news-view-mode doesn't remove buttons Robert Pluim
@ 2024-09-20  6:52 ` Juri Linkov
  2024-09-20  8:57   ` Robert Pluim
  0 siblings, 1 reply; 3+ messages in thread
From: Juri Linkov @ 2024-09-20  6:52 UTC (permalink / raw)
  To: Robert Pluim; +Cc: 73175

> 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.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#73175: 30.0.60; toggling emacs-news-view-mode doesn't remove buttons
  2024-09-20  6:52 ` Juri Linkov
@ 2024-09-20  8:57   ` Robert Pluim
  0 siblings, 0 replies; 3+ messages in thread
From: Robert Pluim @ 2024-09-20  8:57 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 73175

>>>>> On Fri, 20 Sep 2024 09:52:25 +0300, Juri Linkov <juri@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
-- 





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-20  8:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-11  9:42 bug#73175: 30.0.60; toggling emacs-news-view-mode doesn't remove buttons Robert Pluim
2024-09-20  6:52 ` Juri Linkov
2024-09-20  8:57   ` Robert Pluim

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).