From 3d7cf3e751b0ef3ef63dffdea8b5d09828c2341a Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Fri, 4 Oct 2013 13:58:42 +0200 Subject: [PATCH] Initial commit. --- text-counters.el | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 text-counters.el diff --git a/text-counters.el b/text-counters.el new file mode 100644 index 0000000..484bc94 --- /dev/null +++ b/text-counters.el @@ -0,0 +1,40 @@ +;; -*- mode: Emacs-Lisp; mode: rainbow; -*- + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; This program is free software; you can redistribute it and/or ;; +;; modify it under the terms of the GNU General Public License as ;; +;; published by the Free Software Foundation; either version 3, or (at ;; +;; your option) any later version. ;; +;; ;; +;; This program is distributed in the hope that it will be useful, but ;; +;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; +;; General Public License for more details. ;; +;; ;; +;; You should have received a copy of the GNU General Public License ;; +;; along with this program. If not, see . ;; +;; ;; +;; Written by and Copyright (C) Francois Fleuret ;; +;; Contact for comments & bug reports ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; Counts the number of words and characters between the previous and +;; the next line of '-' (with at least four '-' in each line) + +(defun tc/text-counters-string () (interactive) + (let ((a (save-excursion + (and (re-search-backward "^--.*--*$" nil t) + (match-end 0)))) + (b (save-excursion + (and (re-search-forward "^--.*--*$" nil t) + (match-beginning 0))))) + + (when (and a b) + (format "%dw %dc " (count-words a b) (- b a)) + ))) + +;; Add the said counters into the modeline + +(defun tc/add-text-counters-in-modeline () (interactive) + (add-to-list 'mode-line-buffer-identification '(:eval (tc/text-counters-string))) + ) -- 2.20.1