Closed stardiviner closed 7 years ago
Try something like (setq wc-modeline-format "[Words: %tw, Chars: %tc]")
.
@holtzermann17 Not just change wc-modeline-format
. It's about the function or string variable which generated by wc-mdoe
that can be used in my upper custom mode-line format.
Like the following command will not work.
(setq-default
mode-line-format
(quote
(
;; wc-mode (word count) `wc-modeline-format'
(:eval
(if wc-mode
(propertize " WC:[%tw]"
'face '(:foreground "cyan" :weight bold))))
)))
@stardiviner, You can look at the wc-format-modeline-string
function in wc-mode.el line 168. It accepts a format as its argument.
I think in your example, it becomes:
(setq-default
mode-line-format
(quote
(
;; wc-mode (word count) `wc-modeline-format'
(:eval
(if wc-mode
(propertize (wc-format-modeline-string " WC:[%tw]")
'face '(:foreground "cyan" :weight bold))))
)))
Or something like that.
I got an error when I executing (wc-format-modeline-string " WC:[%tw]")
(wrong-type-argument number-or-marker-p nil)
+(nil 0)
(number-to-string (+ wc-orig-words wc-words-delta))
eval((number-to-string (+ wc-orig-words wc-words-delta)))
wc-format-modeline-string(" WC:[%tw]")
eval((wc-format-modeline-string " WC:[%tw]") nil)
I have this in my modeline code and its working very well
'(:eval
(if wc-mode
(propertize (wc-format-modeline-string " Word Count:[%tw]")
'face '(:foreground "cyan" :weight bold))))
I figure out why now. I use edebug
to debug function
wc-format-modeline-string
. then found in alist wc-modeline-format-alist
. the
pair ("%tw" . (number-to-string (+ wc-orig-words wc-words-delta)))
's value
wc-orig-words
is nil
even the wc-mode is enabled, and the value of wc-mode
is t
. Then I check out wc-mode
minor mode definition. Found :lighter (:eval (wc-mode-update))
. Because I use custom mode-line, so the :light
is not
active. Is there other way to update with (wc-mode-update)
? Like:
(add-hook 'wc-mode-hook #'wc-mode-update)
But this is not instantly. Maybe a timer
is a solution?
(Or maybe there is a way to add lighter
into my custom mode-line solution?)
BTW: for wc-orig-words
default value maybe should be 0
instead of nil
?
@bnbeckwith How about my suggestion?
I found a solution which use an idle timer to run wc-mode-update
.
(use-package wc-mode
:ensure t
:init
(add-hook 'org-mode-hook 'wc-mode)
:config
(run-with-idle-timer (* 60 1) nil
'wc-mode-update)
)
I customize mode-line like this:
Is there wc-mode has a function or variable to show counts in the custom mode-line?