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: Sun, 18 Sep 2022 22:06:56 +0300 Organization: LINKOV.NET Message-ID: <86bkrcijsf.fsf@mail.linkov.net> References: <86pmfxlp7s.fsf@mail.linkov.net> <861qsca9cn.fsf@mail.linkov.net> <867d2476u4.fsf@mail.linkov.net> <831qsb6g69.fsf@gnu.org> <86illnpzgh.fsf@mail.linkov.net> <86mtaxaj2l.fsf@mail.linkov.net> <83sfkpz2gb.fsf@gnu.org> 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="17563"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 57813@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 18 21:13:54 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 1oZzjl-0004Qo-Al for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Sep 2022 21:13:53 +0200 Original-Received: from localhost ([::1]:37848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oZzjk-0001uV-Bp for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Sep 2022 15:13:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oZziy-0001P7-Nd for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2022 15:13:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52255) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oZziy-0002aa-Fa for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2022 15:13:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oZzix-0007QQ-UT for bug-gnu-emacs@gnu.org; Sun, 18 Sep 2022 15:13:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Sep 2022 19:13:03 +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.166352836328503 (code B ref 57813); Sun, 18 Sep 2022 19:13:03 +0000 Original-Received: (at 57813) by debbugs.gnu.org; 18 Sep 2022 19:12:43 +0000 Original-Received: from localhost ([127.0.0.1]:51332 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oZzic-0007Pd-Ao for submit@debbugs.gnu.org; Sun, 18 Sep 2022 15:12:43 -0400 Original-Received: from relay7-d.mail.gandi.net ([217.70.183.200]:36191) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oZziY-0007PA-9q for 57813@debbugs.gnu.org; Sun, 18 Sep 2022 15:12:39 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 1AA0320004; Sun, 18 Sep 2022 19:12:28 +0000 (UTC) In-Reply-To: <83sfkpz2gb.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 18 Sep 2022 08:17:08 +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:243013 Archived-At: --=-=-= Content-Type: text/plain >> Here is a preliminary patch > > Thanks. I only quickly read the patch, and have one comment: the > hard-coded left-margin should depend on the value returned by > current-bidi-paragraph-direction, because text that is displayed > right-to-left should have the icons on the right margin, not left > margin. To not create a new mirrored image file for RTL arrow required a change in icons--create to support ':rotation 180' for the existing image file: (define-icon outline-close-rtl-in-margins outline-close '((image "outline-close.svg" "outline-close.pbm" :height 10 :ascent center :rotation 180)) "Icon used for buttons for closing a section in outline buffers." :version "29.1" :help-echo "Close this section") Then the right margin could be used with: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=outline-minor-mode-rtl-in-margins.patch diff --git a/lisp/emacs-lisp/icons.el b/lisp/emacs-lisp/icons.el index ff4f20c207..96f5ea6b08 100644 --- a/lisp/emacs-lisp/icons.el +++ b/lisp/emacs-lisp/icons.el @@ -202,7 +202,9 @@ icons--create :height (if (eq height 'line) (window-default-line-height) height) - :scale 1 :ascent 'center) + :scale 1 + :rotation (plist-get keywords :rotation) + :ascent (or (plist-get keywords :ascent) 'center)) (create-image file)))))) (cl-defmethod icons--create ((_type (eql 'emoji)) icon _keywords) diff --git a/lisp/outline.el b/lisp/outline.el index 25ef1616b9..32c5799814 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -292,6 +292,16 @@ outline-minor-mode-use-buttons :safe #'booleanp :version "29.1") +(defcustom outline-minor-mode-use-margins '(derived-mode . special-mode) + "Whether to display clickable buttons on 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") + (define-icon outline-open nil '((image "outline-open.svg" "outline-open.pbm" :height 15 :ascent center) @@ -312,6 +322,27 @@ outline-close :version "29.1" :help-echo "Close this section") +(define-icon outline-open-in-margins outline-open + '((image "outline-open.svg" "outline-open.pbm" + :height 10 :ascent center)) + "Icon used for buttons for opening a section in outline buffers." + :version "29.1" + :help-echo "Open this section") + +(define-icon outline-close-in-margins outline-close + '((image "outline-open.svg" "outline-open.pbm" + :height 10 :ascent center :rotation -90)) + "Icon used for buttons for closing a section in outline buffers." + :version "29.1" + :help-echo "Close this section") + +(define-icon outline-close-rtl-in-margins outline-close + '((image "outline-open.svg" "outline-open.pbm" + :height 10 :ascent center :rotation 90)) + "Icon used for buttons for closing a section in outline buffers." + :version "29.1" + :help-echo "Close this section") + (defvar outline-level #'outline-level "Function of no args to compute a header's nesting level in an outline. @@ -453,6 +486,11 @@ outline-minor-mode (key-description outline-minor-mode-prefix) outline-mode-prefix-map) (if outline-minor-mode (progn + (when (outline--use-margins-p) + (if (eq (current-bidi-paragraph-direction) 'right-to-left) + (setq-local right-margin-width (1+ right-margin-width)) + (setq-local left-margin-width (1+ left-margin-width))) + (setq-local fringes-outside-margins t)) (when outline-minor-mode-highlight (if (and global-font-lock-mode (font-lock-specified-p major-mode)) (progn @@ -473,6 +511,11 @@ outline-minor-mode (font-lock-remove-keywords nil outline-font-lock-keywords)) (remove-overlays nil nil 'outline-overlay t) (font-lock-flush)) + (when (outline--use-margins-p) + (if (eq (current-bidi-paragraph-direction) 'right-to-left) + (setq-local right-margin-width (1- right-margin-width)) + (setq-local left-margin-width (1- left-margin-width))) + (setq-local fringes-outside-margins nil)) (setq line-move-ignore-invisible nil) ;; Cause use of ellipses for invisible text. (remove-from-invisibility-spec '(outline . t)) @@ -483,6 +526,10 @@ outline--use-buttons-p (and outline-minor-mode (buffer-match-p outline-minor-mode-use-buttons (current-buffer)))) +(defun outline--use-margins-p () + (and outline-minor-mode + (buffer-match-p outline-minor-mode-use-margins (current-buffer)))) + (defvar-local outline-heading-alist () "Alist associating a heading for every possible level. Each entry is of the form (HEADING . LEVEL). @@ -1012,10 +1061,43 @@ outline--make-button-overlay (overlay-put o 'face (plist-get icon 'face)))) o)) -(defun outline--insert-open-button () +(defun outline--make-margin-overlay (type) + (let ((o (seq-find (lambda (o) + (overlay-get o 'outline-margin)) + (overlays-at (point))))) + (unless o + (setq o (make-overlay (point) (1+ (point)))) + (overlay-put o 'follow-link 'mouse-face) + (overlay-put o 'mouse-face 'highlight) + (overlay-put o 'outline-margin t)) + (let ((icon + (icon-elements (if (eq type 'close) + (if (eq (current-bidi-paragraph-direction) + 'right-to-left) + 'outline-close-rtl-in-margins + 'outline-close-in-margins) + 'outline-open-in-margins))) + (inhibit-read-only t)) + (overlay-put + o 'before-string + (propertize " " 'display + `((margin ,(if (eq (current-bidi-paragraph-direction) + 'right-to-left) + 'right-margin 'left-margin)) + ,(or (plist-get icon 'image) + (plist-get icon 'string)))))) + o)) + +(defun outline--insert-open-button (&optional margins-p) (with-silent-modifications (save-excursion - (beginning-of-line) + (beginning-of-line) + (if margins-p + (let ((o (outline--make-margin-overlay 'open))) + (overlay-put o 'help-echo "Click to hide") + (overlay-put o 'keymap + (define-keymap + "" #'outline-hide-subtree))) (when (derived-mode-p 'special-mode) (let ((inhibit-read-only t)) (insert " ") @@ -1025,12 +1107,18 @@ outline--insert-open-button (overlay-put o 'keymap (define-keymap "RET" #'outline-hide-subtree - "" #'outline-hide-subtree)))))) + "" #'outline-hide-subtree))))))) -(defun outline--insert-close-button () +(defun outline--insert-close-button (&optional margins-p) (with-silent-modifications (save-excursion - (beginning-of-line) + (beginning-of-line) + (if margins-p + (let ((o (outline--make-margin-overlay 'close))) + (overlay-put o 'help-echo "Click to show") + (overlay-put o 'keymap + (define-keymap + "" #'outline-show-subtree))) (when (derived-mode-p 'special-mode) (let ((inhibit-read-only t)) (insert " ") @@ -1040,23 +1128,25 @@ outline--insert-close-button (overlay-put o 'keymap (define-keymap "RET" #'outline-show-subtree - "" #'outline-show-subtree)))))) + "" #'outline-show-subtree))))))) (defun outline--fix-up-all-buttons (&optional from to) - (when (outline--use-buttons-p) - (when from - (save-excursion - (goto-char from) - (setq from (line-beginning-position)))) - (outline-map-region - (lambda () - (if (save-excursion - (outline-end-of-heading) - (seq-some (lambda (o) (eq (overlay-get o 'invisible) 'outline)) - (overlays-at (point)))) - (outline--insert-close-button) - (outline--insert-open-button))) - (or from (point-min)) (or to (point-max))))) + (let ((buttons-p (outline--use-buttons-p)) + (margins-p (outline--use-margins-p))) + (when (or buttons-p margins-p) + (when from + (save-excursion + (goto-char from) + (setq from (line-beginning-position)))) + (outline-map-region + (lambda () + (if (save-excursion + (outline-end-of-heading) + (seq-some (lambda (o) (eq (overlay-get o 'invisible) 'outline)) + (overlays-at (point)))) + (outline--insert-close-button margins-p) + (outline--insert-open-button margins-p))) + (or from (point-min)) (or to (point-max)))))) (define-obsolete-function-alias 'hide-subtree #'outline-hide-subtree "25.1") --=-=-=--