From 04a525f624e1a42c47a2755fbc63be32104f44cb Mon Sep 17 00:00:00 2001 From: Misaka Date: Tue, 19 Mar 2024 11:15:03 +0800 Subject: [PATCH] Fix text align for `buffer-face-mode` (#20) * Fix text align for buffer-face-mode * Use sideline--str-len instead of length --------- Co-authored-by: Jen-Chieh Shen --- sideline.el | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/sideline.el b/sideline.el index 9af9570..66ae150 100644 --- a/sideline.el +++ b/sideline.el @@ -298,20 +298,22 @@ "Align sideline STR from the right of the window. Argument OFFSET is additional calculation from the right alignment." - (list (+ - ;; If the sideline text is displayed without at least 1 pixel gap from the right fringe and - ;; overflow-newline-into-fringe is not true, emacs will line wrap it. - (if (and (display-graphic-p) - (> (nth 1 (window-fringes)) 0) - (not overflow-newline-into-fringe)) - 1 - 0) - (* (window-font-width) - (+ offset (if (display-graphic-p) - ;; If right fringe deactivated add 1 offset - (if (= 0 (nth 1 (window-fringes))) 1 0) - 1))) - (sideline--string-pixel-width str)))) + (let ((graphic-p (display-graphic-p)) + (fringes (window-fringes))) + (list (+ + ;; If the sideline text is displayed without at least 1 pixel gap from the right fringe and + ;; overflow-newline-into-fringe is not true, emacs will line wrap it. + (if (and graphic-p + (> (nth 1 fringes) 0) + (not overflow-newline-into-fringe)) + 1 + 0) + (* (window-font-width) + (+ offset (if graphic-p + ;; If right fringe deactivated add 1 offset + (if (= 0 (nth 1 fringes)) 1 0) + 1) + (sideline--str-len str))))))) (defun sideline--get-line () "Return current line."