6
6
; ; Maintainer: Shen, Jen-Chieh <jcs090218@gmail.com>
7
7
; ; URL: https://github.com/jcs-emacs/jcs-modeline
8
8
; ; Version: 0.1.1
9
- ; ; Package-Requires: ((emacs "28 .1") (moody "0.7.1") (minions "0.3.7") (elenv "0.1.0") (nerd-icons "0.0.1") (reveal-in-folder "0.1.2"))
9
+ ; ; Package-Requires: ((emacs "29 .1") (moody "0.7.1") (minions "0.3.7") (elenv "0.1.0") (nerd-icons "0.0.1") (reveal-in-folder "0.1.2"))
10
10
; ; Keywords: faces mode-line
11
11
12
12
; ; This file is not part of GNU Emacs.
84
84
; ; (@* "Externals" )
85
85
; ;
86
86
87
- (declare-function string-pixel-width " subr-x.el" ) ; TODO: remove this after 29.1
88
- (declare-function shr-string-pixel-width " shr.el" ) ; TODO: remove this after 29.1
89
-
90
87
(defvar buffer-undo-tree )
91
88
(defvar undo-tree-visualizer-buffer-name )
92
89
(defvar undo-tree-visualizer-parent-buffer )
171
168
(puthash char result jcs-modeline--char-displayable-cache)
172
169
(and result str-or-char)))
173
170
174
- ; ; TODO: Use function `string-pixel-width' after 29.1
175
- (defun jcs-modeline--string-pixel-width (str )
176
- " Return the width of STR in pixels."
177
- (if (fboundp #'string-pixel-width )
178
- (string-pixel-width str)
179
- (require 'shr )
180
- (shr-string-pixel-width str)))
181
-
182
- (defun jcs-modeline--str-len (str )
171
+ (defun jcs-modeline--str-width (str )
183
172
" Calculate STR in pixel width."
184
173
(let ((width (frame-char-width ))
185
- (len (jcs-modeline-- string-pixel-width str)))
174
+ (len (string-pixel-width str)))
186
175
(+ (/ len width)
187
176
(if (zerop (% len width)) 0 1 )))) ; add one if exceeed
188
177
@@ -235,7 +224,7 @@ Position argument ARG0."
235
224
(let* ((item (nth (if is-left left-index right-index)
236
225
(if is-left jcs-modeline-left right-list)))
237
226
(format (format-mode-line item))
238
- (width (jcs-modeline--str-len format))
227
+ (width (jcs-modeline--str-width format))
239
228
(new-width (+ current-width width)))
240
229
; ; Can the new item added to the list?
241
230
(when (<= new-width (window-width )) ; can be displayed properly!
@@ -262,8 +251,8 @@ Position argument ARG0."
262
251
263
252
(defun jcs-modeline-render (left right )
264
253
" Render mode line with LEFT and RIGHT alignment."
265
- (let* ((len-left (jcs-modeline--str-len (format-mode-line left)))
266
- (len-right (jcs-modeline--str-len (format-mode-line right)))
254
+ (let* ((len-left (jcs-modeline--str-width (format-mode-line left)))
255
+ (len-right (jcs-modeline--str-width (format-mode-line right)))
267
256
(available-width (- (window-width ) (+ len-left len-right)))
268
257
(available-width (+ available-width (jcs-modeline--adjust-pad))))
269
258
(append left
0 commit comments