aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/bindings.el2
-rw-r--r--lisp/simple.el31
3 files changed, 29 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 347f7b666f6..b6649d4b37d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12012-08-10 Chong Yidong <cyd@gnu.org>
2
3 * bindings.el: Bind M-= back to count-words-region.
4
5 * simple.el (count-words-region): Accept a prefix arg for acting
6 on the entire buffer.
7 (count-words--buffer-message): New helper function.
8
12012-08-10 Stefan Monnier <monnier@iro.umontreal.ca> 92012-08-10 Stefan Monnier <monnier@iro.umontreal.ca>
2 10
3 * term/x-win.el (x-menu-bar-open): Always pass last-nonmenu-event. 11 * term/x-win.el (x-menu-bar-open): Always pass last-nonmenu-event.
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 655cda235b4..e0555a17b15 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -793,7 +793,7 @@ if `inhibit-field-text-motion' is non-nil."
793(define-key ctl-x-map "\C-o" 'delete-blank-lines) 793(define-key ctl-x-map "\C-o" 'delete-blank-lines)
794(define-key esc-map " " 'just-one-space) 794(define-key esc-map " " 'just-one-space)
795(define-key esc-map "z" 'zap-to-char) 795(define-key esc-map "z" 'zap-to-char)
796(define-key esc-map "=" 'count-words) 796(define-key esc-map "=" 'count-words-region)
797(define-key ctl-x-map "=" 'what-cursor-position) 797(define-key ctl-x-map "=" 'what-cursor-position)
798(define-key esc-map ":" 'eval-expression) 798(define-key esc-map ":" 'eval-expression)
799;; Define ESC ESC : like ESC : for people who type ESC ESC out of habit. 799;; Define ESC ESC : like ESC : for people who type ESC ESC out of habit.
diff --git a/lisp/simple.el b/lisp/simple.el
index 0877f396faa..f644044a430 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -966,16 +966,22 @@ rather than line counts."
966 (re-search-forward "[\n\C-m]" nil 'end (1- line)) 966 (re-search-forward "[\n\C-m]" nil 'end (1- line))
967 (forward-line (1- line))))) 967 (forward-line (1- line)))))
968 968
969(defun count-words-region (start end) 969(defun count-words-region (start end &optional arg)
970 "Count the number of words in the region. 970 "Count the number of words in the region.
971If called interactively, print a message reporting the number of 971If called interactively, print a message reporting the number of
972lines, words, and chars in the region. 972lines, words, and characters in the region (whether or not the
973region is active); with prefix ARG, report for the entire buffer
974rather than the region.
975
973If called from Lisp, return the number of words between positions 976If called from Lisp, return the number of words between positions
974START and END." 977START and END."
975 (interactive "r") 978 (interactive "r\nP")
976 (if (called-interactively-p 'any) 979 (cond ((not (called-interactively-p 'any))
977 (count-words--message "Region" start end) 980 (count-words start end))
978 (count-words start end))) 981 (arg
982 (count-words--buffer-message))
983 (t
984 (count-words--message "Region" start end))))
979 985
980(defun count-words (start end) 986(defun count-words (start end)
981 "Count words between START and END. 987 "Count words between START and END.
@@ -999,11 +1005,14 @@ END, without printing any message."
999 ((use-region-p) 1005 ((use-region-p)
1000 (call-interactively 'count-words-region)) 1006 (call-interactively 'count-words-region))
1001 (t 1007 (t
1002 (count-words--message 1008 (count-words--buffer-message))))
1003 (if (= (point-max) (1+ (buffer-size))) 1009
1004 "Buffer" 1010(defun count-words--buffer-message ()
1005 "Narrowed part of buffer") 1011 (count-words--message
1006 (point-min) (point-max))))) 1012 (if (= (point-max) (1+ (buffer-size)))
1013 "Buffer"
1014 "Narrowed part of buffer")
1015 (point-min) (point-max)))
1007 1016
1008(defun count-words--message (str start end) 1017(defun count-words--message (str start end)
1009 (let ((lines (count-lines start end)) 1018 (let ((lines (count-lines start end))