I want to call some methods in the Emacs mode-line format. For example count-words to see how many characters are selected or what's the class/method name cursor is on.
This is my current mode-line format, but calling count-words, it shows *invalid* as a result and also I'm not sure that it will be invoked in any changes.
(setq-default mode-line-format
(list "---File:[%b%+] Line:[%l] Size:[%i] "
(count-words (point-min) (point-max))
))
I want to call some custom methods in the mode-line area which are updating frequently. For example, how many characters I've selected, who changed this line (git blame), what is the current class name which the cursor is on now, and so on.
The answer to the question you have asked is:
But I don't think that is the question you meant to ask, because the value won't update. Let's fix that.
I've chosen to have it update after you save the file because the counting the words in buffer is going to get v slow at some buffer size if you are doing it frequently.
(It might equally suit your purposes to simply call
messagewith the word count after saving.)