Skip to content

Commit

Permalink
chore: Use built-in substring no prop
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Mar 18, 2024
1 parent 61dd837 commit f3f5a40
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions sideline.el
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,11 @@
`(when (buffer-live-p ,buffer-or-name)
(with-current-buffer ,buffer-or-name ,@body)))

(defun sideline--str-no-props (str)
"Remove STR's text properties."
(with-temp-buffer
(insert str)
(buffer-substring-no-properties (point-min) (point-max))))

;; TODO: Use function `string-pixel-width' after 29.1
(defun sideline--string-pixel-width (str)
"Return the width of STR in pixels."
(let ((str (sideline--str-no-props str)))
;; Text properties may effect the length, remove it!
(let ((str (substring-no-properties str)))
(if (fboundp #'string-pixel-width)
(string-pixel-width str)
(require 'shr)
Expand Down Expand Up @@ -302,7 +297,7 @@
(defun sideline--align-right (str offset)
"Align sideline STR from the right of the window.
Argument OFFSET is additional calculation from the right alignment."
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.
Expand Down

0 comments on commit f3f5a40

Please sign in to comment.