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

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

[nongnu] elpa/page-break-lines 29f9314f8e 47/80: Handle the new native d


From: ELPA Syncer
Subject: [nongnu] elpa/page-break-lines 29f9314f8e 47/80: Handle the new native display-line-number functionality
Date: Tue, 5 Sep 2023 04:03:07 -0400 (EDT)

branch: elpa/page-break-lines
commit 29f9314f8e7bd5ab087ff085d5f1d451a8549d43
Author: Steve Purcell <steve@sanityinc.com>
Commit: Steve Purcell <steve@sanityinc.com>

    Handle the new native display-line-number functionality
    
    Fixes #16
---
 page-break-lines.el | 45 +++++++++++++++++++++++++--------------------
 1 file changed, 25 insertions(+), 20 deletions(-)

diff --git a/page-break-lines.el b/page-break-lines.el
index d964a5b802..53cf9ea7bc 100644
--- a/page-break-lines.el
+++ b/page-break-lines.el
@@ -107,7 +107,8 @@ horizontal line of `page-break-string-char' characters."
 
 (dolist (hook '(window-configuration-change-hook
                 window-size-change-functions
-                after-setting-font-hook))
+                after-setting-font-hook
+                display-line-numbers-mode-hook))
   (add-hook hook 'page-break-lines--update-display-tables))
 
 
@@ -117,28 +118,32 @@ horizontal line of `page-break-string-char' characters."
 If the buffer inside WINDOW has `page-break-lines-mode' enabled,
 its display table will be modified as necessary."
   (with-current-buffer (window-buffer window)
-    (if page-break-lines-mode
-        (progn
-          (unless buffer-display-table
-            (setq buffer-display-table (make-display-table)))
-          (let ((default-height (face-attribute 'default :height nil 
'default)))
-            (set-face-attribute 'page-break-lines nil :height default-height)
-            (let* ((cwidth (char-width page-break-lines-char))
-                   (wwidth (window-width window))
-                   (width (if (zerop (% wwidth cwidth))
-                              (1- (/ wwidth cwidth))
-                            (/ wwidth cwidth)))
-                   (glyph (make-glyph-code page-break-lines-char 
'page-break-lines))
-                   (new-display-entry (vconcat (make-list width glyph))))
-              (unless (equal new-display-entry (elt buffer-display-table ?\^L))
-                (aset buffer-display-table ?\^L new-display-entry)))))
-      (when (and (member major-mode page-break-lines-modes)
-                 buffer-display-table)
-        (aset buffer-display-table ?\^L nil)))))
+    (with-selected-window window
+      (if page-break-lines-mode
+          (progn
+            (unless buffer-display-table
+              (setq buffer-display-table (make-display-table)))
+            (let ((default-height (face-attribute 'default :height nil 
'default)))
+              (set-face-attribute 'page-break-lines nil :height default-height)
+              (let* ((cwidth (char-width page-break-lines-char))
+                     (wwidth (- (window-width)
+                                (if (bound-and-true-p display-line-numbers)
+                                    (+ (line-number-display-width) 2)
+                                  0)
+                                (if (display-graphic-p) 0 1)))
+                     (width (/ wwidth cwidth))
+                     (glyph (make-glyph-code page-break-lines-char 
'page-break-lines))
+                     (new-display-entry (vconcat (make-list width glyph))))
+                (unless (equal new-display-entry (elt buffer-display-table 
?\^L))
+                  (aset buffer-display-table ?\^L new-display-entry)))))
+        (when (and (member major-mode page-break-lines-modes)
+                   buffer-display-table)
+          (aset buffer-display-table ?\^L nil))))))
 
 (defun page-break-lines--update-display-tables  (&optional frame)
   "Function called for updating display table in windows of FRAME."
-  (mapc 'page-break-lines--update-display-table (window-list frame 
'no-minibuffer)))
+  (unless (minibufferp)
+    (mapc 'page-break-lines--update-display-table (window-list frame 
'no-minibuffer))))
 
 
 



reply via email to

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