代码:
(setq-default mode-line-format
(append mode-line-format
'((:eval
(let ((lines (count-lines (point-min) (point-max))))
(propertize (format "[%d Lines]" lines)
'face '(:foreground "red" :background "green")
'mouse-face 'mode-line-highlightn
'help-echo (format "Current buffer contains %d lines." lines)))))))
效果: