From: Juri Linkov <juri@linkov.net>
To: 57813@debbugs.gnu.org
Subject: bug#57813: Icon images are non-functional
Date: Wed, 19 Oct 2022 09:44:21 +0300 [thread overview]
Message-ID: <86tu40z516.fsf@mail.linkov.net> (raw)
In-Reply-To: <86r0z5x9ng.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 18 Oct 2022 21:35:15 +0300")
[-- Attachment #1: Type: text/plain, Size: 449 bytes --]
> So shouldn't outline-minor-mode-use-buttons be just a buffer-local
> variable like all other variables that affect outline-minor-mode?
> Then it could be set in mode hooks like other variables:
>
> (add-hook 'ruby-mode-hook
> (lambda ()
> (setq-local outline-default-state 2
> outline-minor-mode-use-buttons t)
> (outline-minor-mode)))
Here is a patch for this simplification:
[-- Attachment #2: outline-minor-mode-use-buttons.patch --]
[-- Type: text/x-diff, Size: 10778 bytes --]
diff --git a/lisp/help.el b/lisp/help.el
index 0f5342b77d..d48b866938 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -745,7 +745,7 @@ describe-bindings
(setq-local outline-level (lambda () 1))
(setq-local outline-minor-mode-cycle t
outline-minor-mode-highlight t
- outline-minor-mode-insert-buttons t)
+ outline-minor-mode-use-buttons 'insert)
(outline-minor-mode 1)
(save-excursion
(goto-char (point-min))
diff --git a/lisp/textmodes/emacs-news-mode.el b/lisp/textmodes/emacs-news-mode.el
index d57d053a7a..ebb31da9cf 100644
--- a/lisp/textmodes/emacs-news-mode.el
+++ b/lisp/textmodes/emacs-news-mode.el
@@ -75,7 +75,7 @@ emacs-news--mode-common
(setq-local font-lock-defaults '(emacs-news-mode-font-lock-keywords t))
(setq-local outline-minor-mode-cycle t
outline-minor-mode-highlight 'append
- outline-minor-mode-use-margins t)
+ outline-minor-mode-use-buttons 'in-margins)
(outline-minor-mode)
(setq-local imenu-generic-expression outline-imenu-generic-expression)
(emacs-etc--hide-local-variables))
diff --git a/lisp/outline.el b/lisp/outline.el
index 2209964577..384ad6f2e7 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -281,40 +281,22 @@ outline-font-lock-faces
[outline-1 outline-2 outline-3 outline-4
outline-5 outline-6 outline-7 outline-8])
-(defcustom outline-minor-mode-use-buttons '(derived-mode . help-mode)
+(defvar-local outline-minor-mode-use-buttons nil
"Whether to display clickable buttons on the headings.
-The value should be a `buffer-match-p' condition.
-
These buttons can be used to hide and show the body under the heading.
-Note that this feature is not meant to be used in editing
-buffers (yet) -- that will be amended in a future version."
- :type 'buffer-predicate
- :safe #'booleanp
- :version "29.1")
-
-(defvar-local outline--use-buttons nil
- "Non-nil when buffer displays clickable buttons on the headings.")
-
-(defvar-local outline-minor-mode-insert-buttons nil
- "Non-nil when it's allowed to modify buffer to insert buttons.")
+When the value is `insert', additional placeholders for buttons are
+inserted to the buffer, so buttons are not only clickable,
+but also typing `RET' on them can hide and show the body.
+When the value is `in-margins', then clickable buttons are
+displayed in the margins before the headings.
+When the value is `t', clickable buttons are displayed
+in the buffer before the headings. The values `t' and
+`in-margins' can be used in editing buffers because they
+don't modify the buffer.")
(defvar-local outline--use-rtl nil
"Non-nil when direction of clickable buttons is right-to-left.")
-(defcustom outline-minor-mode-use-margins '(and (derived-mode . special-mode)
- (not (derived-mode . help-mode)))
- "Whether to display clickable buttons in the margins.
-The value should be a `buffer-match-p' condition.
-
-These buttons can be used to hide and show the body under the heading.
-Note that this feature is meant to be used in editing buffers."
- :type 'buffer-predicate
- :safe #'booleanp
- :version "29.1")
-
-(defvar-local outline--use-margins nil
- "Non-nil when buffer displays clickable buttons in the margins.")
-
(define-icon outline-open nil
'((image "outline-open.svg" "outline-open.pbm" :height (0.8 . em))
(emoji "🔽")
@@ -487,7 +469,7 @@ outline-minor-mode-highlight-buffer
(let ((regexp (concat "^\\(?:" outline-regexp "\\).*$")))
(while (re-search-forward regexp nil t)
(let ((overlay (make-overlay (match-beginning 0) (match-end 0))))
- (overlay-put overlay 'outline-overlay t)
+ (overlay-put overlay 'outline-highlight t)
;; FIXME: Is it possible to override all underlying face attributes?
(when (or (memq outline-minor-mode-highlight '(append override))
(and (eq outline-minor-mode-highlight t)
@@ -511,25 +493,19 @@ outline-minor-mode
(key-description outline-minor-mode-prefix) outline-mode-prefix-map)
(if outline-minor-mode
(progn
- (cond
- ((buffer-match-p outline-minor-mode-use-margins (current-buffer))
- (setq-local outline--use-margins t))
- ((buffer-match-p outline-minor-mode-use-buttons (current-buffer))
- (setq-local outline--use-buttons t)))
- (when (and (or outline--use-buttons outline--use-margins)
- (eq (current-bidi-paragraph-direction) 'right-to-left))
- (setq-local outline--use-rtl t))
- (when outline--use-margins
- (if outline--use-rtl
- (setq-local right-margin-width (1+ right-margin-width))
- (setq-local left-margin-width (1+ left-margin-width)))
- (setq-local fringes-outside-margins t)
- ;; Force display of margins
- (when (eq (current-buffer) (window-buffer))
- (set-window-buffer nil (window-buffer))))
- (when (or outline--use-buttons outline--use-margins)
+ (when outline-minor-mode-use-buttons
(add-hook 'after-change-functions
- #'outline--fix-buttons-after-change nil t))
+ #'outline--fix-buttons-after-change nil t)
+ (when (eq (current-bidi-paragraph-direction) 'right-to-left)
+ (setq-local outline--use-rtl t))
+ (when (eq outline-minor-mode-use-buttons 'in-margins)
+ (if outline--use-rtl
+ (setq-local right-margin-width (1+ right-margin-width))
+ (setq-local left-margin-width (1+ left-margin-width)))
+ (setq-local fringes-outside-margins t)
+ ;; Force display of margins
+ (when (eq (current-buffer) (window-buffer))
+ (set-window-buffer nil (window-buffer)))))
(when outline-minor-mode-highlight
(if (and global-font-lock-mode (font-lock-specified-p major-mode))
(progn
@@ -554,18 +530,18 @@ outline-minor-mode
(if font-lock-fontified
(font-lock-remove-keywords nil outline-font-lock-keywords))
(font-lock-flush)
- (remove-overlays nil nil 'outline-overlay t))
- (when outline--use-buttons
- (remove-overlays nil nil 'outline-button t))
- (when outline--use-margins
- (remove-overlays nil nil 'outline-margin t)
- (if outline--use-rtl
- (setq-local right-margin-width (1- right-margin-width))
- (setq-local left-margin-width (1- left-margin-width)))
- (setq-local fringes-outside-margins nil)
- ;; Force removal of margins
- (when (eq (current-buffer) (window-buffer))
- (set-window-buffer nil (window-buffer))))))
+ (remove-overlays nil nil 'outline-highlight t))
+ (when outline-minor-mode-use-buttons
+ (if (not (eq outline-minor-mode-use-buttons 'in-margins))
+ (remove-overlays nil nil 'outline-button t)
+ (remove-overlays nil nil 'outline-margin t)
+ (if outline--use-rtl
+ (setq-local right-margin-width (1- right-margin-width))
+ (setq-local left-margin-width (1- left-margin-width)))
+ (setq-local fringes-outside-margins nil)
+ ;; Force removal of margins
+ (when (eq (current-buffer) (window-buffer))
+ (set-window-buffer nil (window-buffer)))))))
(defvar-local outline-heading-alist ()
"Alist associating a heading for every possible level.
@@ -1675,7 +1651,7 @@ outline--make-button-overlay
;; In editing buffers we use overlays only, but in other buffers
;; we use a mix of text properties, text and overlays to make
;; movement commands work more logically.
- (if outline-minor-mode-insert-buttons
+ (if (eq outline-minor-mode-use-buttons 'insert)
(let ((inhibit-read-only t))
(put-text-property (point) (1+ (point)) 'face (plist-get icon 'face))
(if-let ((image (plist-get icon 'image)))
@@ -1713,13 +1689,13 @@ outline--make-margin-overlay
(plist-get icon 'string))))))
o))
-(defun outline--insert-open-button (&optional use-margins)
+(defun outline--insert-open-button (&optional in-margins)
(with-silent-modifications
(save-excursion
(beginning-of-line)
- (if use-margins
+ (if in-margins
(outline--make-margin-overlay 'open)
- (when outline-minor-mode-insert-buttons
+ (when (eq outline-minor-mode-use-buttons 'insert)
(let ((inhibit-read-only t))
(insert " ")
(beginning-of-line)))
@@ -1730,13 +1706,13 @@ outline--insert-open-button
"RET" #'outline-hide-subtree
"<mouse-2>" #'outline-hide-subtree)))))))
-(defun outline--insert-close-button (&optional use-margins)
+(defun outline--insert-close-button (&optional in-margins)
(with-silent-modifications
(save-excursion
(beginning-of-line)
- (if use-margins
+ (if in-margins
(outline--make-margin-overlay 'close)
- (when outline-minor-mode-insert-buttons
+ (when (eq outline-minor-mode-use-buttons 'insert)
(let ((inhibit-read-only t))
(insert " ")
(beginning-of-line)))
@@ -1748,7 +1724,7 @@ outline--insert-close-button
"<mouse-2>" #'outline-show-subtree)))))))
(defun outline--fix-up-all-buttons (&optional from to)
- (when (or outline--use-buttons outline--use-margins)
+ (when outline-minor-mode-use-buttons
(when from
(save-excursion
(goto-char from)
@@ -1759,17 +1735,16 @@ outline--fix-up-all-buttons
(outline-end-of-heading)
(seq-some (lambda (o) (eq (overlay-get o 'invisible) 'outline))
(overlays-at (point))))
- (outline--insert-close-button outline--use-margins)
- (outline--insert-open-button outline--use-margins)))
+ (outline--insert-close-button (eq outline-minor-mode-use-buttons 'in-margins))
+ (outline--insert-open-button (eq outline-minor-mode-use-buttons 'in-margins))))
(or from (point-min)) (or to (point-max)))))
(defun outline--fix-buttons-after-change (beg end _len)
;; Handle whole lines
(save-excursion (goto-char beg) (setq beg (pos-bol)))
(save-excursion (goto-char end) (setq end (pos-eol)))
- (when outline--use-buttons
- (remove-overlays beg end 'outline-button t))
- (when outline--use-margins
+ (if (not (eq outline-minor-mode-use-buttons 'in-margins))
+ (remove-overlays beg end 'outline-button t)
(remove-overlays beg end 'outline-margin t))
(outline--fix-up-all-buttons beg end))
next prev parent reply other threads:[~2022-10-19 6:44 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 19:40 bug#57813: Icon images are non-functional Juri Linkov
2022-09-15 16:30 ` Juri Linkov
2022-09-15 16:36 ` Juri Linkov
2022-09-15 16:53 ` Eli Zaretskii
2022-09-15 17:35 ` Juri Linkov
2022-09-15 18:32 ` Eli Zaretskii
2022-09-15 19:46 ` Juri Linkov
2022-09-16 16:16 ` Juri Linkov
2022-09-15 19:53 ` Juri Linkov
2022-09-16 5:29 ` Eli Zaretskii
2022-09-16 7:09 ` Juri Linkov
2022-09-17 19:37 ` Juri Linkov
2022-09-18 5:08 ` Eli Zaretskii
2022-09-18 18:46 ` Juri Linkov
2022-09-18 5:17 ` Eli Zaretskii
2022-09-18 19:06 ` Juri Linkov
2022-09-19 12:12 ` Eli Zaretskii
2022-09-19 19:37 ` Juri Linkov
2022-09-20 11:31 ` Eli Zaretskii
2022-09-20 16:12 ` Juri Linkov
2022-09-23 15:48 ` Juri Linkov
2022-09-23 16:26 ` Lars Ingebrigtsen
2022-09-24 17:17 ` Juri Linkov
2022-10-12 14:42 ` Max Brieiev
2022-10-12 18:55 ` Juri Linkov
2022-10-23 16:55 ` Juri Linkov
2022-10-13 7:51 ` Juri Linkov
2022-10-18 18:14 ` Juri Linkov
2022-10-18 18:35 ` Juri Linkov
2022-10-19 6:44 ` Juri Linkov [this message]
2022-10-22 18:38 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86tu40z516.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=57813@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).