emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r109554: Bind M-= back to count-words


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109554: Bind M-= back to count-words-region, and let it accept a prefix arg.
Date: Sat, 11 Aug 2012 00:02:48 +0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109554
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sat 2012-08-11 00:02:48 +0800
message:
  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.
modified:
  etc/NEWS
  lisp/ChangeLog
  lisp/bindings.el
  lisp/simple.el
=== modified file 'etc/NEWS'
--- a/etc/NEWS  2012-08-10 14:47:12 +0000
+++ b/etc/NEWS  2012-08-10 16:02:48 +0000
@@ -176,7 +176,7 @@
 ** `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.

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-08-10 14:47:12 +0000
+++ b/lisp/ChangeLog    2012-08-10 16:02:48 +0000
@@ -1,3 +1,11 @@
+2012-08-10  Chong Yidong  <address@hidden>
+
+       * 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  <address@hidden>
 
        * term/x-win.el (x-menu-bar-open): Always pass last-nonmenu-event.

=== modified file 'lisp/bindings.el'
--- a/lisp/bindings.el  2012-07-18 14:17:49 +0000
+++ b/lisp/bindings.el  2012-08-10 16:02:48 +0000
@@ -793,7 +793,7 @@
 (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.

=== modified file 'lisp/simple.el'
--- a/lisp/simple.el    2012-08-07 04:52:15 +0000
+++ b/lisp/simple.el    2012-08-10 16:02:48 +0000
@@ -966,16 +966,22 @@
        (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.
@@ -999,11 +1005,14 @@
        ((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))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]