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

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

[nongnu] elpa/page-break-lines e8bfd1ab66: Better method for calculating


From: ELPA Syncer
Subject: [nongnu] elpa/page-break-lines e8bfd1ab66: Better method for calculating line width, requiring Emacs 25.1+
Date: Wed, 17 Jan 2024 13:01:18 -0500 (EST)

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

    Better method for calculating line width, requiring Emacs 25.1+
    
    In Emacs 29, where `string-pixel-width` exists, the result should be
    better still.
---
 .github/workflows/test.yml |  2 --
 page-break-lines.el        | 18 ++++++------------
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 3bdca2a7e6..8358a4153b 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -12,8 +12,6 @@ jobs:
     strategy:
       matrix:
         emacs_version:
-          - 24.1
-          - 24.5
           - 25.1
           - 25.3
           - 26.1
diff --git a/page-break-lines.el b/page-break-lines.el
index 9172cda397..a8f929403e 100644
--- a/page-break-lines.el
+++ b/page-break-lines.el
@@ -5,7 +5,7 @@
 ;; Author: Steve Purcell <steve@sanityinc.com>
 ;; URL: https://github.com/purcell/page-break-lines
 ;; Package-Version: 0.15
-;; Package-Requires: ((emacs "24.4"))
+;; Package-Requires: ((emacs "25.1"))
 ;; Keywords: convenience, faces
 
 ;; This program is free software; you can redistribute it and/or modify
@@ -125,17 +125,11 @@ its display table will be modified as necessary."
               (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-pix (- (window-width nil t)
-                                    (if (and (bound-and-true-p 
display-line-numbers)
-                                             (fboundp 
'line-number-display-width))
-                                        (line-number-display-width t)
-                                      0)))
-                     (width (- (/ wwidth-pix (frame-char-width) cwidth)
-                               (if (display-graphic-p) 0 1)))
-                     (width (if page-break-lines-max-width
-                                (min width page-break-lines-max-width)
-                              width))
+              (let* ((char-relative-width (if (fboundp 'string-pixel-width)
+                                              (/ (string-pixel-width 
(make-string 100 page-break-lines-char))
+                                                 (string-pixel-width 
(make-string 100 ?a)))
+                                            (char-width 
page-break-lines-char)))
+                     (width (floor (window-max-chars-per-line) 
char-relative-width))
                      (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))



reply via email to

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