Commit e1293765 authored by Chong Yidong's avatar Chong Yidong
Browse files

Bind M-= back to count-words-region, and let it accept a prefix arg.

* lisp/bindings.el: Bind M-= back to count-words-region.

* lisp/simple.el (count-words-region): Accept a prefix arg for acting
on the entire buffer.
(count-words--buffer-message): New helper function.
parent e1894109
......@@ -176,7 +176,7 @@ prompts for a column number.
** `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 <>
* 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 <>
* term/x-win.el (x-menu-bar-open): Always pass last-nonmenu-event.
......@@ -793,7 +793,7 @@ if `inhibit-field-text-motion' is non-nil."
(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.
......@@ -966,16 +966,22 @@ rather than line counts."
(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
(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))
(count-words--message "Region" start end))))
(defun count-words (start end)
"Count words between START and END.
......@@ -999,11 +1005,14 @@ END, without printing any message."
(call-interactively 'count-words-region))
(defun count-words--buffer-message ()
(if (= (point-max) (1+ (buffer-size)))
"Narrowed part of buffer")
(point-min) (point-max)))))
(point-min) (point-max)))
(defun count-words--message (str start end)
(let ((lines (count-lines start end))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment