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. ...@@ -176,7 +176,7 @@ prompts for a column number.
** `mouse-avoidance-banish-position' can now be used to customize ** `mouse-avoidance-banish-position' can now be used to customize
`mouse-avoidance-mode' further. `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 ** `C-M-f' and `C-M-b' will now move to the path name separator
character when doing minibuffer filename prompts. 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> 2012-08-10 Stefan Monnier <monnier@iro.umontreal.ca>
* term/x-win.el (x-menu-bar-open): Always pass last-nonmenu-event. * 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." ...@@ -793,7 +793,7 @@ if `inhibit-field-text-motion' is non-nil."
(define-key ctl-x-map "\C-o" 'delete-blank-lines) (define-key ctl-x-map "\C-o" 'delete-blank-lines)
(define-key esc-map " " 'just-one-space) (define-key esc-map " " 'just-one-space)
(define-key esc-map "z" 'zap-to-char) (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 ctl-x-map "=" 'what-cursor-position)
(define-key esc-map ":" 'eval-expression) (define-key esc-map ":" 'eval-expression)
;; Define ESC ESC : like ESC : for people who type ESC ESC out of habit. ;; Define ESC ESC : like ESC : for people who type ESC ESC out of habit.
......
...@@ -966,16 +966,22 @@ rather than line counts." ...@@ -966,16 +966,22 @@ rather than line counts."
(re-search-forward "[\n\C-m]" nil 'end (1- line)) (re-search-forward "[\n\C-m]" nil 'end (1- line))
(forward-line (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. "Count the number of words in the region.
If called interactively, print a message reporting the number of 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 If called from Lisp, return the number of words between positions
START and END." START and END."
(interactive "r") (interactive "r\nP")
(if (called-interactively-p 'any) (cond ((not (called-interactively-p 'any))
(count-words--message "Region" start end) (count-words start end))
(count-words start end))) (arg
(count-words--buffer-message))
(t
(count-words--message "Region" start end))))
(defun count-words (start end) (defun count-words (start end)
"Count words between START and END. "Count words between START and END.
...@@ -999,11 +1005,14 @@ END, without printing any message." ...@@ -999,11 +1005,14 @@ END, without printing any message."
((use-region-p) ((use-region-p)
(call-interactively 'count-words-region)) (call-interactively 'count-words-region))
(t (t
(count-words--message (count-words--buffer-message))))
(if (= (point-max) (1+ (buffer-size)))
"Buffer" (defun count-words--buffer-message ()
"Narrowed part of buffer") (count-words--message
(point-min) (point-max))))) (if (= (point-max) (1+ (buffer-size)))
"Buffer"
"Narrowed part of buffer")
(point-min) (point-max)))
(defun count-words--message (str start end) (defun count-words--message (str start end)
(let ((lines (count-lines 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