emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/org-modern 9e76abd307 1/3: Table scaling (See #69 and #


From: ELPA Syncer
Subject: [elpa] externals/org-modern 9e76abd307 1/3: Table scaling (See #69 and #75)
Date: Mon, 12 Sep 2022 15:57:52 -0400 (EDT)

branch: externals/org-modern
commit 9e76abd3070be52b8d244386c38fd76cc217fb41
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Table scaling (See #69 and #75)
---
 org-modern.el | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/org-modern.el b/org-modern.el
index a238e8412f..fc1befd9a9 100644
--- a/org-modern.el
+++ b/org-modern.el
@@ -322,6 +322,7 @@ You can specify a font `:family'. The font families 
`Iosevka', `Hack' and
 (defvar-local org-modern--star-cache nil)
 (defvar-local org-modern--checkbox-cache nil)
 (defvar-local org-modern--progress-cache nil)
+(defvar-local org-modern--sp-width (list nil))
 
 (defun org-modern--checkbox ()
   "Prettify checkboxes according to `org-modern-checkbox'."
@@ -450,9 +451,9 @@ You can specify a font `:family'. The font families 
`Iosevka', `Hack' and
            (end (match-end 0))
            (tbeg (match-beginning 1))
            (tend (match-end 1))
-           ;; Unique objects
-           (sp1 (list 'space :width 1))
-           (sp2 (list 'space :width 1))
+           ;; Unique space objects
+           (sp1 (list 'space :width org-modern--sp-width))
+           (sp2 (list 'space :width org-modern--sp-width))
            (color (face-attribute 'org-table :foreground nil t))
            (inner (progn
                     (goto-char beg)
@@ -547,6 +548,10 @@ You can specify a font `:family'. The font families 
`Iosevka', `Hack' and
           (forward-line)
           t)))))
 
+(defun org-modern--pre-redisplay (_)
+  "Compute font width before redisplay."
+  (setcar org-modern--sp-width (default-font-width)))
+
 ;;;###autoload
 (define-minor-mode org-modern-mode
   "Modern looks for Org."
@@ -554,6 +559,7 @@ You can specify a font `:family'. The font families 
`Iosevka', `Hack' and
   :group 'org-modern
   (cond
    (org-modern-mode
+    (add-hook 'pre-redisplay-functions #'org-modern--pre-redisplay nil 'local)
     (when (and (fboundp 'fringe-bitmap-p)
                (not (fringe-bitmap-p 'org-modern--block-inner)))
       (let* ((g (ceiling (frame-char-height) 1.8))
@@ -566,6 +572,7 @@ You can specify a font `:family'. The font families 
`Iosevka', `Hack' and
           (vconcat (make-vector (- 127 h) #x80) [#xFF] (make-vector h 0)) nil 
nil 'bottom)))
     (org-modern--update-label-face)
     (setq
+     org-modern--sp-width (list nil)
      org-modern--star-cache
      (vconcat (mapcar
                (lambda (x) (propertize x 'face 'org-modern-symbol))
@@ -688,7 +695,9 @@ You can specify a font `:family'. The font families 
`Iosevka', `Hack' and
            (6 '(face nil display " ")))))))
     (font-lock-add-keywords nil org-modern--font-lock-keywords 'append)
     (advice-add #'org-unfontify-region :after #'org-modern--unfontify))
-   (t (font-lock-remove-keywords nil org-modern--font-lock-keywords)))
+   (t
+    (remove-hook 'pre-redisplay-functions #'org-modern--pre-redisplay 'local)
+    (font-lock-remove-keywords nil org-modern--font-lock-keywords)))
   (save-restriction
     (widen)
     (let ((org-modern-mode t))



reply via email to

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