emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r107534: Make c-mark-defun extend reg


From: Alan Mackenzie
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r107534: Make c-mark-defun extend region when repeated, and leave a mark.
Date: Thu, 08 Mar 2012 11:32:57 +0000
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107534
committer: Alan Mackenzie <address@hidden>
branch nick: trunk
timestamp: Thu 2012-03-08 11:32:57 +0000
message:
  Make c-mark-defun extend region when repeated, and leave a mark.
  Fixes bugs #5525, #10906.
modified:
  lisp/ChangeLog
  lisp/progmodes/cc-cmds.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-03-08 08:22:16 +0000
+++ b/lisp/ChangeLog    2012-03-08 11:32:57 +0000
@@ -1,3 +1,10 @@
+2012-03-08  Alan Mackenzie  <address@hidden>
+
+       * progmodes/cc-cmds.el (c-mark-function): Make it leave a mark at
+       the starting position; make it extend the marked region when
+       invoked repeatedly - all under appropriate circumstances.
+       Fixes bugs #5525, #10906.
+
 2012-03-08  Glenn Morris  <address@hidden>
 
        * files.el (locate-dominating-file, dir-locals-find-file):

=== modified file 'lisp/progmodes/cc-cmds.el'
--- a/lisp/progmodes/cc-cmds.el 2012-01-19 07:21:25 +0000
+++ b/lisp/progmodes/cc-cmds.el 2012-03-08 11:32:57 +0000
@@ -1958,7 +1958,12 @@
 
 (defun c-mark-function ()
   "Put mark at end of the current top-level declaration or macro, point at 
beginning.
-If point is not inside any then the closest following one is chosen.
+If point is not inside any then the closest following one is
+chosen.  Each successive call of this command extends the marked
+region by one function.
+
+A mark is left where the command started, unless the region is already active
+\(in Transient Mark mode).
 
 As opposed to \\[c-beginning-of-defun] and \\[c-end-of-defun], this
 function does not require the declaration to contain a brace block."
@@ -1974,8 +1979,24 @@
 
     (if (not decl-limits)
        (error "Cannot find any declaration")
-      (goto-char (car decl-limits))
-      (push-mark (cdr decl-limits) nil t))))
+      (let* ((extend-region-p
+             (and (eq this-command 'c-mark-function)
+                  (eq last-command 'c-mark-function)))
+            (push-mark-p (and (eq this-command 'c-mark-function)
+                              (not extend-region-p)
+                              (not (and transient-mark-mode mark-active)))))
+       (if push-mark-p (push-mark (point)))
+       (if extend-region-p
+           (progn
+             (exchange-point-and-mark)
+             (setq decl-limits (c-declaration-limits t))
+             (when (not decl-limits)
+               (exchange-point-and-mark)
+               (error "Cannot find any declaration"))
+             (goto-char (cdr decl-limits))
+             (exchange-point-and-mark))
+         (goto-char (car decl-limits))
+         (push-mark (cdr decl-limits) nil t))))))
 
 (defun c-cpp-define-name ()
   "Return the name of the current CPP macro, or NIL if we're not in one."


reply via email to

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