** `mouse-avoidance-banish-position' can now be used to customize
`mouse-avoidance-mode' further.
-** `M-=' is now bound to `count-words', not `count-words-region'.
+** `C-u M-=' now counts lines/words/characters in the entire buffer.
** `C-M-f' and `C-M-b' will now move to the path name separator
character when doing minibuffer filename prompts.
+2012-08-10 Chong Yidong <cyd@gnu.org>
+
+ * bindings.el: Bind M-= back to count-words-region.
+
+ * simple.el (count-words-region): Accept a prefix arg for acting
+ on the entire buffer.
+ (count-words--buffer-message): New helper function.
+
2012-08-10 Stefan Monnier <monnier@iro.umontreal.ca>
* term/x-win.el (x-menu-bar-open): Always pass last-nonmenu-event.
(define-key ctl-x-map "\C-o" 'delete-blank-lines)
(define-key esc-map " " 'just-one-space)
(define-key esc-map "z" 'zap-to-char)
-(define-key esc-map "=" 'count-words)
+(define-key esc-map "=" 'count-words-region)
(define-key ctl-x-map "=" 'what-cursor-position)
(define-key esc-map ":" 'eval-expression)
;; Define ESC ESC : like ESC : for people who type ESC ESC out of habit.
(re-search-forward "[\n\C-m]" nil 'end (1- line))
(forward-line (1- line)))))
-(defun count-words-region (start end)
+(defun count-words-region (start end &optional arg)
"Count the number of words in the region.
If called interactively, print a message reporting the number of
-lines, words, and chars in the region.
+lines, words, and characters in the region (whether or not the
+region is active); with prefix ARG, report for the entire buffer
+rather than the region.
+
If called from Lisp, return the number of words between positions
START and END."
- (interactive "r")
- (if (called-interactively-p 'any)
- (count-words--message "Region" start end)
- (count-words start end)))
+ (interactive "r\nP")
+ (cond ((not (called-interactively-p 'any))
+ (count-words start end))
+ (arg
+ (count-words--buffer-message))
+ (t
+ (count-words--message "Region" start end))))
(defun count-words (start end)
"Count words between START and END.
((use-region-p)
(call-interactively 'count-words-region))
(t
- (count-words--message
- (if (= (point-max) (1+ (buffer-size)))
- "Buffer"
- "Narrowed part of buffer")
- (point-min) (point-max)))))
+ (count-words--buffer-message))))
+
+(defun count-words--buffer-message ()
+ (count-words--message
+ (if (= (point-max) (1+ (buffer-size)))
+ "Buffer"
+ "Narrowed part of buffer")
+ (point-min) (point-max)))
(defun count-words--message (str start end)
(let ((lines (count-lines start end))