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#59719: 29.0.60; emacs-news-mode does not adjust the width of the fringe to accommodate the outline icons Date: Thu, 01 Dec 2022 20:51:02 +0200 Organization: LINKOV.NET Message-ID: <865yev5561.fsf@mail.linkov.net> References: <86pmd4h2tw.fsf@mail.linkov.net> <83a648jq04.fsf@gnu.org> <86fse0e37z.fsf@mail.linkov.net> <835yewjom2.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="6057"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: justksqsf@gmail.com, 59719@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 01 19:55:21 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 1p0oiP-0001P6-EO for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Dec 2022 19:55:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0oi8-0002h2-Qb; Thu, 01 Dec 2022 13:55:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0oi6-0002gl-TD for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 13:55:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p0oi6-0007v5-Kj for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 13:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p0oi6-0000du-7E for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2022 13:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Dec 2022 18:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59719 X-GNU-PR-Package: emacs Original-Received: via spool by 59719-submit@debbugs.gnu.org id=B59719.16699208492450 (code B ref 59719); Thu, 01 Dec 2022 18:55:02 +0000 Original-Received: (at 59719) by debbugs.gnu.org; 1 Dec 2022 18:54:09 +0000 Original-Received: from localhost ([127.0.0.1]:41358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0ohF-0000dS-Dr for submit@debbugs.gnu.org; Thu, 01 Dec 2022 13:54:09 -0500 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:33917) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0ohD-0000d4-7T for 59719@debbugs.gnu.org; Thu, 01 Dec 2022 13:54:08 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 892FAFF805; Thu, 1 Dec 2022 18:53:58 +0000 (UTC) In-Reply-To: <835yewjom2.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 30 Nov 2022 20:15:01 +0200") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:249664 Archived-At: --=-=-= Content-Type: text/plain > Why not use string-pixel-width, and divide by what default-font-width > returns? Here is the complete tested fix: --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=outline-margin-width.patch Content-Transfer-Encoding: 8bit diff --git a/lisp/emacs-lisp/icons.el b/lisp/emacs-lisp/icons.el index 86c44830308..8ba6d97ea00 100644 --- a/lisp/emacs-lisp/icons.el +++ b/lisp/emacs-lisp/icons.el @@ -202,6 +202,10 @@ icons--create (list :height (if (eq height 'line) (window-default-line-height) height))) + (if-let ((width (plist-get keywords :width))) + (list :width (if (eq width 'font) + (default-font-width) + width))) '(:scale 1) (if-let ((rotation (plist-get keywords :rotation))) (list :rotation rotation)) diff --git a/lisp/outline.el b/lisp/outline.el index 86ac19aa415..b50f4f81b62 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -318,8 +319,14 @@ outline--button-icons (defvar-local outline--use-rtl nil "Non-nil when direction of clickable buttons is right-to-left.") +(defvar-local outline--margin-width nil + "Current margin width.") + +(defvar-local outline-margin-width nil + "Default margin width.") + (define-icon outline-open nil - '((image "outline-open.svg" "outline-open.pbm" :height (0.8 . em)) + '((image "outline-open.svg" "outline-open.pbm" :width (0.8 . em)) (emoji "🔽") (symbol " ▼ ") (text " open ")) @@ -328,7 +335,7 @@ outline-open :help-echo "Close this section") (define-icon outline-close nil - '((image "outline-close.svg" "outline-close.pbm" :height (0.8 . em)) + '((image "outline-close.svg" "outline-close.pbm" :width (0.8 . em)) (emoji "▶️") (symbol " ▶ ") (text " close ")) @@ -337,15 +344,14 @@ outline-close :help-echo "Open this section") (define-icon outline-close-rtl outline-close - '((image "outline-close.svg" "outline-close.pbm" :height (0.8 . em) - :rotation 180) + '((image "outline-close.svg" "outline-close.pbm" :width (0.8 . em) :rotation 180) (emoji "◀️") (symbol " ◀ ")) "Right-to-left icon used for buttons in closed outline sections." :version "29.1") (define-icon outline-open-in-margins outline-open - '((image "outline-open.svg" "outline-open.pbm" :height 10) + '((image "outline-open.svg" "outline-open.pbm" :width font) (emoji "🔽") (symbol "▼") (text "v")) @@ -353,7 +359,7 @@ outline-open-in-margins :version "29.1") (define-icon outline-close-in-margins outline-close - '((image "outline-open.svg" "outline-open.pbm" :height 10 :rotation -90) + '((image "outline-open.svg" "outline-open.pbm" :width font :rotation -90) (emoji "▶️") (symbol "▶") (text ">")) @@ -361,7 +367,7 @@ outline-close-in-margins :version "29.1") (define-icon outline-close-rtl-in-margins outline-close-rtl - '((image "outline-open.svg" "outline-open.pbm" :height 10 :rotation 90) + '((image "outline-open.svg" "outline-open.pbm" :width font :rotation 90) (emoji "◀️") (symbol "◀") (text "<")) @@ -528,9 +534,22 @@ outline-minor-mode (when (and (eq outline-minor-mode-use-buttons 'in-margins) (> 1 (if outline--use-rtl right-margin-width left-margin-width))) + (setq outline--margin-width + (or outline-margin-width + (ceiling + (/ (seq-max + (seq-map #'string-pixel-width + (seq-map #'icon-string + `(outline-open-in-margins + ,(if 'outline--use-rtl + 'outline-close-rtl-in-margins + 'outline-close-in-margins))))) + (* (default-font-width) 1.0))))) (if outline--use-rtl - (setq-local right-margin-width (1+ right-margin-width)) - (setq-local left-margin-width (1+ left-margin-width))) + (setq-local right-margin-width (+ right-margin-width + outline--margin-width)) + (setq-local left-margin-width (+ left-margin-width + outline--margin-width))) (setq-local fringes-outside-margins t) ;; Force display of margins (when (eq (current-buffer) (window-buffer)) @@ -566,8 +587,10 @@ outline-minor-mode (< 0 (if outline--use-rtl right-margin-width left-margin-width))) (if outline--use-rtl - (setq-local right-margin-width (1- right-margin-width)) - (setq-local left-margin-width (1- left-margin-width))) + (setq-local right-margin-width (- right-margin-width + outline--margin-width)) + (setq-local left-margin-width (- left-margin-width + outline--margin-width))) (setq-local fringes-outside-margins nil) ;; Force removal of margins (when (eq (current-buffer) (window-buffer)) --=-=-=--