Skip to content

Commit

Permalink
Add a function for counting words.
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Mar 24, 2012
1 parent 36b5e9c commit aea879c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions emacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,25 @@ These are in the format (FILENAME)NODENAME."
(file-name-nondirectory file)
"") ")")))))

(defun my-count-words ()
"Count words, ignoring footnotes and links."
(interactive)
(save-excursion
(end-of-buffer)
(let ((last-real-line (save-excursion
(re-search-backward "^[^0-9 \n]")
(point))))
(re-search-backward "^1\. " last-real-line t)
(let ((contents-no-footnotes
(buffer-substring-no-properties
(save-excursion (beginning-of-buffer) (point))
(point))))
(with-temp-buffer
(insert contents-no-footnotes)
(beginning-of-buffer)
(replace-regexp "\\[[^\]]+\\]" "")
(count-words))))))

;; ----------
;; -- Keybindings
;; ----------
Expand Down

0 comments on commit aea879c

Please sign in to comment.