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: Thu, 13 Oct 2022 10:51:35 +0300 Organization: LINKOV.NET Message-ID: <86sfjstan4.fsf@mail.linkov.net> References: <86pmfxlp7s.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="38637"; 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 Thu Oct 13 10:44:55 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 1oitpn-0009pi-JA for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Oct 2022 10:44:55 +0200 Original-Received: from localhost ([::1]:50146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oitpm-00085C-2k for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Oct 2022 04:44:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oitJ0-0002rR-1I for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 04:11:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60322) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oitIz-0001a8-Ps for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 04:11:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oitIz-0006NZ-KN for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 04:11:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 Oct 2022 08:11:01 +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.166564861724453 (code B ref 57813); Thu, 13 Oct 2022 08:11:01 +0000 Original-Received: (at 57813) by debbugs.gnu.org; 13 Oct 2022 08:10:17 +0000 Original-Received: from localhost ([127.0.0.1]:59400 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oitIH-0006ML-73 for submit@debbugs.gnu.org; Thu, 13 Oct 2022 04:10:17 -0400 Original-Received: from relay8-d.mail.gandi.net ([217.70.183.201]:59677) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oitIE-0006Lw-Mq for 57813@debbugs.gnu.org; Thu, 13 Oct 2022 04:10:15 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id C81AD1BF203 for <57813@debbugs.gnu.org>; Thu, 13 Oct 2022 08:10:07 +0000 (UTC) In-Reply-To: <86pmfxlp7s.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 14 Sep 2022 22:40:07 +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:245276 Archived-At: --=-=-= Content-Type: text/plain This patch distinguishes two cases of using buttons in outline-minor-mode: 1. when buttons can be inserted to a read-only buffer, then it's possible to move point to the inserted button and use it by keyboard; 2. when the buffer is editable and should not be modified to insert buttons, when the only way to display buttons is with a before-string overlay. The disadvantage is that buttons can be used only by clicking mouse. A new variable 'outline-read-only' is added here to allow setting it explicitly in buffers that can be modified to insert buttons like the Help buffer: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=outline-read-only.patch diff --git a/lisp/help.el b/lisp/help.el index b4b9120da3..713467c9b2 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -608,13 +608,8 @@ describe-bindings (setq-local outline-heading-end-regexp ":\n") (setq-local outline-level (lambda () 1)) (setq-local outline-minor-mode-cycle t - outline-minor-mode-highlight t) + outline-minor-mode-highlight t + outline-read-only t) (outline-minor-mode 1) (save-excursion (goto-char (point-min)) diff --git a/lisp/outline.el b/lisp/outline.el index b87d3ac5e7..5a65c6c8e5 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -295,6 +295,9 @@ outline-minor-mode-use-buttons (defvar-local outline--use-buttons nil "Non-nil when buffer displays clickable buttons on the headings.") +(defvar-local outline-read-only nil + "Non-nil when it's allowed to modify buffer to insert buttons.") + (defvar-local outline--use-rtl nil "Non-nil when direction of clickable buttons is right-to-left.") @@ -1652,18 +1655,24 @@ outline--make-button-overlay (if outline--use-rtl 'outline-close-rtl 'outline-close) - 'outline-open))) - (inhibit-read-only t)) + 'outline-open)))) ;; 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. - (when (derived-mode-p 'special-mode) - (put-text-property (point) (1+ (point)) 'face (plist-get icon 'face))) - (if-let ((image (plist-get icon 'image))) - (overlay-put o 'display image) - (overlay-put o 'display (concat (plist-get icon 'string) - (string (char-after (point))))) - (overlay-put o 'face (plist-get icon 'face)))) + (if outline-read-only + (let ((inhibit-read-only t)) + (put-text-property (point) (1+ (point)) 'face (plist-get icon 'face)) + (if-let ((image (plist-get icon 'image))) + (overlay-put o 'display image) + (overlay-put o 'display (concat (plist-get icon 'string) + (string (char-after (point))))) + (overlay-put o 'face (plist-get icon 'face)))) + (overlay-put + o 'before-string + (propertize " " + 'display + (or (plist-get icon 'image) + (plist-get icon 'string)))))) o)) (defun outline--make-margin-overlay (type) @@ -1699,7 +1713,7 @@ outline--insert-open-button (beginning-of-line) (if use-margins (outline--make-margin-overlay 'open) - (when (derived-mode-p 'special-mode) + (when outline-read-only (let ((inhibit-read-only t)) (insert " ") (beginning-of-line))) @@ -1716,7 +1730,7 @@ outline--insert-close-button (beginning-of-line) (if use-margins (outline--make-margin-overlay 'close) - (when (derived-mode-p 'special-mode) + (when outline-read-only (let ((inhibit-read-only t)) (insert " ") (beginning-of-line))) diff --git a/lisp/textmodes/emacs-news-mode.el b/lisp/textmodes/emacs-news-mode.el index d9decae4df..f7f56eb047 100644 --- a/lisp/textmodes/emacs-news-mode.el +++ b/lisp/textmodes/emacs-news-mode.el @@ -73,11 +73,7 @@ emacs-news-mode-font-lock-keywords (defun emacs-news--mode-common () (setq-local font-lock-defaults '(emacs-news-mode-font-lock-keywords t)) - ;; This `outline-regexp' matches leading spaces inserted - ;; by the current implementation of `outline-minor-mode-use-buttons'. - (setq-local outline-regexp "\\(?: +\\)?\\(\\*+\\) " - outline-level (lambda () (length (match-string 1))) - outline-minor-mode-cycle t + (setq-local outline-minor-mode-cycle t outline-minor-mode-highlight 'append) (outline-minor-mode) (setq-local imenu-generic-expression outline-imenu-generic-expression) --=-=-=--