diff options
| author | Chong Yidong | 2012-08-11 00:02:48 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-08-11 00:02:48 +0800 |
| commit | e1293765d95660fc7f2cf0fcb28026d1efa592df (patch) | |
| tree | ff5bee4a882eb0a7a604fa50cb08d025fe697203 | |
| parent | e18941095a56075d6eb908a65aafcd1697fea2ae (diff) | |
| download | emacs-e1293765d95660fc7f2cf0fcb28026d1efa592df.tar.gz emacs-e1293765d95660fc7f2cf0fcb28026d1efa592df.zip | |
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.
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/bindings.el | 2 | ||||
| -rw-r--r-- | lisp/simple.el | 31 |
4 files changed, 30 insertions, 13 deletions
| @@ -176,7 +176,7 @@ prompts for a column number. | |||
| 176 | ** `mouse-avoidance-banish-position' can now be used to customize | 176 | ** `mouse-avoidance-banish-position' can now be used to customize |
| 177 | `mouse-avoidance-mode' further. | 177 | `mouse-avoidance-mode' further. |
| 178 | 178 | ||
| 179 | ** `M-=' is now bound to `count-words', not `count-words-region'. | 179 | ** `C-u M-=' now counts lines/words/characters in the entire buffer. |
| 180 | 180 | ||
| 181 | ** `C-M-f' and `C-M-b' will now move to the path name separator | 181 | ** `C-M-f' and `C-M-b' will now move to the path name separator |
| 182 | character when doing minibuffer filename prompts. | 182 | character when doing minibuffer filename prompts. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 347f7b666f6..b6649d4b37d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2012-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 | |||
| 1 | 2012-08-10 Stefan Monnier <monnier@iro.umontreal.ca> | 9 | 2012-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. |
| 971 | If called interactively, print a message reporting the number of | 971 | If called interactively, print a message reporting the number of |
| 972 | lines, words, and chars in the region. | 972 | lines, words, and characters in the region (whether or not the |
| 973 | region is active); with prefix ARG, report for the entire buffer | ||
| 974 | rather than the region. | ||
| 975 | |||
| 973 | If called from Lisp, return the number of words between positions | 976 | If called from Lisp, return the number of words between positions |
| 974 | START and END." | 977 | START 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)) |