emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 28/38] org-string-width: Handle undefined behaviour in older E


From: Ihor Radchenko
Subject: [PATCH v2 28/38] org-string-width: Handle undefined behaviour in older Emacs
Date: Wed, 20 Apr 2022 21:27:42 +0800

* lisp/org-macs.el (org-string-width): Force older Emacs treating
invisible text with ellipsis as zero-width.  Newer Emacs versions do
exactly this.
---
 lisp/org-macs.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index 188168cdc..e56a234d3 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -926,7 +926,16 @@ (defun org-string-width (string &optional pixels)
     (with-temp-buffer
       (setq-local display-line-numbers nil)
       (setq-local buffer-invisibility-spec
-                  current-invisibility-spec)
+                  (if (listp current-invisibility-spec)
+                      (mapcar (lambda (el)
+                                ;; Consider elipsis to have 0 width.
+                                ;; It is what Emacs 28+ does, but we have
+                                ;; to force it in earlier Emacs versions.
+                                (if (and (consp el) (cdr el))
+                                    (list (car el))
+                                  el))
+                              current-invisibility-spec)
+                    current-invisibility-spec))
       (setq-local char-property-alias-alist
                   current-char-property-alias-alist)
       (let (pixel-width symbol-width)
-- 
2.35.1



-- 
Ihor Radchenko,
PhD,
Center for Advancing Materials Performance from the Nanoscale (CAMP-nano)
State Key Laboratory for Mechanical Behavior of Materials, Xi'an Jiaotong 
University, Xi'an, China
Email: yantar92@gmail.com, ihor_radchenko@alumni.sutd.edu.sg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]