1 ;; -*- mode: Emacs-Lisp; mode: rainbow; -*-
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4 ;; This program is free software; you can redistribute it and/or ;;
5 ;; modify it under the terms of the GNU General Public License as ;;
6 ;; published by the Free Software Foundation; either version 3, or (at ;;
7 ;; your option) any later version. ;;
9 ;; This program is distributed in the hope that it will be useful, but ;;
10 ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;
11 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
12 ;; General Public License for more details. ;;
14 ;; You should have received a copy of the GNU General Public License ;;
15 ;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;
17 ;; Written by and Copyright (C) Francois Fleuret ;;
18 ;; Contact <francois@fleuret.org> for comments & bug reports ;;
19 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
21 (defface tc/modeline-face
22 '((((background light)) (:foreground "blue4"))
23 (((background dark)) (:foreground "cyan")))
24 "The face for the alarm-vc modeline message.")
26 ;; Counts the number of words and characters between the previous and
27 ;; the next line of '-' (with at least four '-' in each line)
29 (defun tc/text-counters-string () (interactive)
30 (let ((a (save-excursion
31 (and (re-search-backward "^--.*--*$" nil t)
34 (and (re-search-forward "^--.*--*$" nil t)
35 (match-beginning 0)))))
38 (propertize (format "%dw %dc " (count-words a b) (- b a))
39 'face 'tc/modeline-face)
42 ;; Add the said counters into the modeline
44 (defun tc/add-text-counters-in-modeline () (interactive)
45 (add-to-list 'mode-line-buffer-identification '(:eval (tc/text-counters-string)))