From: Juri Linkov <juri@linkov.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: justksqsf@gmail.com, 59719@debbugs.gnu.org
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 [thread overview]
Message-ID: <865yev5561.fsf@mail.linkov.net> (raw)
In-Reply-To: <835yewjom2.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 30 Nov 2022 20:15:01 +0200")
[-- Attachment #1: Type: text/plain, Size: 118 bytes --]
> Why not use string-pixel-width, and divide by what default-font-width
> returns?
Here is the complete tested fix:
[-- Attachment #2: outline-margin-width.patch --]
[-- Type: text/x-diff, Size: 5265 bytes --]
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))
next prev parent reply other threads:[~2022-12-01 18:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-30 9:10 bug#59719: 29.0.60; emacs-news-mode does not adjust the width of the fringe to accommodate the outline icons Kai Ma
2022-11-30 15:11 ` Eli Zaretskii
2022-11-30 16:11 ` Kai Ma
2022-11-30 17:08 ` Eli Zaretskii
2022-11-30 16:26 ` Arash Esbati
2022-11-30 16:41 ` Juri Linkov
2022-11-30 17:44 ` Eli Zaretskii
2022-11-30 17:56 ` Juri Linkov
2022-11-30 18:15 ` Eli Zaretskii
2022-11-30 18:30 ` Juri Linkov
2022-11-30 18:44 ` Eli Zaretskii
2022-11-30 18:59 ` Juri Linkov
2022-11-30 20:19 ` Eli Zaretskii
2022-12-01 18:51 ` Juri Linkov [this message]
2022-12-01 20:09 ` Eli Zaretskii
2022-12-02 7:54 ` 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=865yev5561.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=59719@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=justksqsf@gmail.com \
/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).