]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/simple.el (mark-word): Mark more if repeated.
authorKai Großjohann <kgrossjo@eu.uu.net>
Fri, 15 Feb 2002 08:53:15 +0000 (08:53 +0000)
committerKai Großjohann <kgrossjo@eu.uu.net>
Fri, 15 Feb 2002 08:53:15 +0000 (08:53 +0000)
* lisp/textmodes/paragraphs.el (mark-paragraph): Ditto.
(mark-end-of-sentence): Ditto.

etc/NEWS
lisp/ChangeLog
lisp/emacs-lisp/lisp.el
lisp/simple.el
lisp/textmodes/paragraphs.el
man/mark.texi

index 210fd452cfc98e1de0c3c44021a6e77b93c95d00..06e6553a54ba32497fec26e5c05ec0bf3aa30b3b 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -245,9 +245,13 @@ idle time in seconds to wait before starting fontification.  For
 example, if you set `jit-lock-defer-time' to 0.25, fontification will
 only happen after 0.25s of idle time.
 
-** If you hit M-C-SPC (mark-sexp) repeatedly, the marked region
-will now be extended each time, so you can mark the next two sexps with
-M-C-SPC M-C-SPC, for example.
++++
+** Marking commands extend the region when invoked multiple times.  If
+you hit M-C-SPC (mark-sexp), M-@ (mark-word), M-h (mark-paragraph), or
+C-M-h (mark-defun) repeatedly, the marked region will now be extended
+each time, so you can mark the next two sexps with M-C-SPC M-C-SPC,
+for example.  This feature also works for mark-end-of-sentence, if you
+bind that to a key.
 
 ** In the *Occur* buffer, `o' switches to it in another window, and
 C-o displays the current line's occurrence in another window without
index 2343d88cb710b298c5e691b0b989f9982ec71931..a4ed23eef55e64fe3073e4f85efe6461d9e09f36 100644 (file)
@@ -1,3 +1,9 @@
+2002-02-15  Kai Gro\e,A_\e(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+       * simple.el (mark-word): Mark more if repeated.
+       * textmodes/paragraphs.el (mark-paragraph): Ditto.
+       (mark-end-of-sentence): Ditto.
+
 2002-02-15  Per Abrahamsen  <abraham@dina.kvl.dk>
 
        * wid-edit.el (widgetp): Made it more robust.
index deab27f34e796c0dda2ab4ff4d2897bfec585dcb..a815eddfd78f0997754f7ed36fb393fa21fdeed6 100644 (file)
@@ -76,13 +76,18 @@ move to with the same argument.
 If this command is repeated, it marks the next ARG sexps after the ones
 already marked."
   (interactive "p")
-  (push-mark
-    (save-excursion
-      (if (and (eq last-command this-command) (mark t))
-         (goto-char (mark)))
-      (forward-sexp (or arg 1))
-      (point))
-    nil t))
+  (cond ((and (eq last-command this-command) (mark t))
+        (set-mark
+         (save-excursion
+          (goto-char (mark))
+          (forward-sexp (or arg 1))
+          (point))))
+       (t
+        (push-mark
+         (save-excursion
+           (forward-sexp (or arg 1))
+           (point))
+         nil t))))
 
 (defun forward-list (&optional arg)
   "Move forward across one balanced group of parentheses.
@@ -250,13 +255,21 @@ is called as a function to find the defun's end."
 
 (defun mark-defun ()
   "Put mark at end of this defun, point at beginning.
-The defun marked is the one that contains point or follows point."
+The defun marked is the one that contains point or follows point.
+If this command is repeated, marks more defuns after the ones
+already marked."
   (interactive)
-  (push-mark (point))
-  (end-of-defun)
-  (push-mark (point) nil t)
-  (beginning-of-defun)
-  (re-search-backward "^\n" (- (point) 1) t))
+  (let (here)
+    (when (and (eq last-command this-command) (mark t))
+      (setq here (point))
+      (goto-char (mark)))
+    (push-mark (point))
+    (end-of-defun)
+    (push-mark (point) nil t)
+    (if here
+       (goto-char here)
+      (beginning-of-defun)
+      (re-search-backward "^\n" (- (point) 1) t))))
 
 (defun narrow-to-defun (&optional arg)
   "Make text outside current defun invisible.
index ff36a7c1873713e302686e8531143ed0e7c55330..6708af57a2c1f0248a79f322895c0ca07858ea17 100644 (file)
@@ -2812,13 +2812,22 @@ With argument, do this that many times."
   (forward-word (- arg)))
 
 (defun mark-word (arg)
-  "Set mark arg words away from point."
+  "Set mark arg words away from point.
+If this command is repeated, it marks the next ARG words after the ones
+already marked."
   (interactive "p")
-  (push-mark
-    (save-excursion
-      (forward-word arg)
-      (point))
-    nil t))
+  (cond ((and (eq last-command this-command) (mark t))
+        (set-mark
+         (save-excursion
+           (goto-char (mark))
+           (forward-word arg)
+           (point))))
+       (t
+        (push-mark
+         (save-excursion
+           (forward-word arg)
+           (point))
+         nil t))))
 
 (defun kill-word (arg)
   "Kill characters forward until encountering the end of a word.
index ed9a78696fd78f14a1d9ed69a243393f9ce612ef..91d9b1699f9fa56f6489bab39f02b2acc237493d 100644 (file)
@@ -325,14 +325,23 @@ With argument ARG, puts mark at end of a following paragraph, so that
 the number of paragraphs marked equals ARG.
 
 If ARG is negative, point is put at end of this paragraph, mark is put
-at beginning of this or a previous paragraph."
+at beginning of this or a previous paragraph.
+
+If this command is repeated, it marks the next ARG paragraphs after (or
+before, if arg is negative) the ones already marked."
   (interactive "p")
-  (unless arg (setq arg 1))
-  (when (zerop arg)
-    (error "Cannot mark zero paragraphs"))
-  (forward-paragraph arg)
-  (push-mark nil t t)
-  (backward-paragraph arg))
+  (let (here)
+    (unless arg (setq arg 1))
+    (when (zerop arg)
+      (error "Cannot mark zero paragraphs"))
+    (when (and (eq last-command this-command) (mark t))
+      (setq here (point))
+      (goto-char (mark)))
+    (forward-paragraph arg)
+    (push-mark nil t t)
+    (if here
+       (goto-char here)
+      (backward-paragraph arg))))
 
 (defun kill-paragraph (arg)
   "Kill forward to end of paragraph.
@@ -424,13 +433,17 @@ With arg, repeat, or kill forward to Nth end of sentence if negative arg -N."
   (kill-region (point) (progn (backward-sentence arg) (point))))
 
 (defun mark-end-of-sentence (arg)
-  "Put mark at end of sentence.  Arg works as in `forward-sentence'."
+  "Put mark at end of sentence.  Arg works as in `forward-sentence'.
+If this command is repeated, it marks the next ARG sentences after the
+ones already marked."
   (interactive "p")
   (push-mark
-    (save-excursion
-      (forward-sentence arg)
-      (point))
-    nil t))
+   (save-excursion
+     (if (and (eq last-command this-command) (mark t))
+        (goto-char (mark)))
+     (forward-sentence arg)
+     (point))
+   nil t))
 
 (defun transpose-sentences (arg)
   "Interchange this (next) and previous sentence."
index 7cdc5a24fc824c12c109dc58674bff4cc18b6755..4b3c28814a4b165034667737ea17b74f2d1fd5bc 100644 (file)
@@ -278,7 +278,9 @@ Put region around current page (@code{mark-page}).
 @kbd{M-@@} (@code{mark-word}) puts the mark at the end of the next
 word, while @kbd{C-M-@@} (@code{mark-sexp}) puts it at the end of the
 next balanced expression (@pxref{Expressions}).  These commands handle
-arguments just like @kbd{M-f} and @kbd{C-M-f}.
+arguments just like @kbd{M-f} and @kbd{C-M-f}.  If you repeat these
+commands, the region is extended.  For example, you can type either
+@kbd{C-u 2 M-@@} or @kbd{M-@@ M-@@} to mark the next two words.
 
 @kindex C-x h
 @findex mark-whole-buffer
@@ -292,17 +294,20 @@ paragraph.  With prefix argument, if the argument's value is positive,
 point.  If the prefix argument is @minus{}@var{n}, @kbd{M-h} also
 marks @var{n} paragraphs, running back form the one surrounding point.
 In that last case, point moves forward to the end of that paragraph,
-and the mark goes at the start of the region.
+and the mark goes at the start of the region.  The @kbd{M-h} command
+also supports the extension of the region, similar to @kbd{M-@@} and
+@kbd{C-M-@@}.
 
   @kbd{C-M-h} (@code{mark-defun}) similarly puts point before, and the
 mark after, the current (or following) major top-level definition, or
-defun (@pxref{Moving by Defuns}).  (Currently it only marks one
-defun.)  @kbd{C-x C-p} (@code{mark-page}) puts point before the
-current page, and mark at the end (@pxref{Pages}).  The mark goes
-after the terminating page delimiter (to include it in the region),
-while point goes after the preceding page delimiter (to exclude it).
-A numeric argument specifies a later page (if positive) or an earlier
-page (if negative) instead of the current page.
+defun (@pxref{Moving by Defuns}).  (Currently it only marks one defun,
+but repeating it marks more defuns, like for @kbd{M-@@}.)  @kbd{C-x
+C-p} (@code{mark-page}) puts point before the current page, and mark
+at the end (@pxref{Pages}).  The mark goes after the terminating page
+delimiter (to include it in the region), while point goes after the
+preceding page delimiter (to exclude it).  A numeric argument
+specifies a later page (if positive) or an earlier page (if negative)
+instead of the current page.
 
   Finally, @kbd{C-x h} (@code{mark-whole-buffer}) sets up the entire
 buffer as the region, by putting point at the beginning and the mark at