From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#57813: Icon images are non-functional Date: Wed, 19 Oct 2022 09:44:21 +0300 Organization: LINKOV.NET Message-ID: <86tu40z516.fsf@mail.linkov.net> References: <86pmfxlp7s.fsf@mail.linkov.net> <86sfjstan4.fsf@mail.linkov.net> <86pmepyp66.fsf@mail.linkov.net> <86r0z5x9ng.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16570"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) To: 57813@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 19 08:48:23 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ol2sI-00044m-Bc for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 Oct 2022 08:48:22 +0200 Original-Received: from localhost ([::1]:39928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ol2sG-0005tF-RH for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 Oct 2022 02:48:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol2r2-0005qe-Ol for bug-gnu-emacs@gnu.org; Wed, 19 Oct 2022 02:47:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ol2r0-0002vv-Jb for bug-gnu-emacs@gnu.org; Wed, 19 Oct 2022 02:47:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ol2r0-0006Ny-DW for bug-gnu-emacs@gnu.org; Wed, 19 Oct 2022 02:47:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 Oct 2022 06:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57813 X-GNU-PR-Package: emacs Original-Received: via spool by 57813-submit@debbugs.gnu.org id=B57813.166616202124537 (code B ref 57813); Wed, 19 Oct 2022 06:47:02 +0000 Original-Received: (at 57813) by debbugs.gnu.org; 19 Oct 2022 06:47:01 +0000 Original-Received: from localhost ([127.0.0.1]:55643 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ol2qy-0006Ng-IQ for submit@debbugs.gnu.org; Wed, 19 Oct 2022 02:47:01 -0400 Original-Received: from relay1-d.mail.gandi.net ([217.70.183.193]:34569) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ol2qu-0006NP-8z for 57813@debbugs.gnu.org; Wed, 19 Oct 2022 02:46:59 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 84527240003 for <57813@debbugs.gnu.org>; Wed, 19 Oct 2022 06:46:46 +0000 (UTC) In-Reply-To: <86r0z5x9ng.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 18 Oct 2022 21:35:15 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:245846 Archived-At: --=-=-= Content-Type: text/plain > 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: --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=outline-minor-mode-use-buttons.patch Content-Transfer-Encoding: 8bit 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 "" #'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 "" #'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)) --=-=-=--