]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/lisp.el
(mark-sexp, mark-defun): New arg ALLOW-EXTEND
[gnu-emacs] / lisp / emacs-lisp / lisp.el
index 090f793c700191c06d22b950af41a7aeba2c8f36..69938255112a8f48e5e0da2eaed0ec2ee6c66d11 100644 (file)
@@ -69,15 +69,17 @@ move forward across N balanced expressions."
   (or arg (setq arg 1))
   (forward-sexp (- arg)))
 
-(defun mark-sexp (&optional arg)
+(defun mark-sexp (&optional arg allow-extend)
   "Set mark ARG sexps from point.
 The place mark goes is the same place \\[forward-sexp] would
 move to with the same argument.
-If this command is repeated or mark is active in Transient Mark mode,
+Interactively, if this command is repeated
+or (in Transient Mark mode) if the mark is active, 
 it marks the next ARG sexps after the ones already marked."
-  (interactive "P")
-  (cond ((or (and (eq last-command this-command) (mark t))
-            (and transient-mark-mode mark-active))
+  (interactive "P\np")
+  (cond ((and allow-extend
+             (or (and (eq last-command this-command) (mark t))
+                 (and transient-mark-mode mark-active)))
         (setq arg (if arg (prefix-numeric-value arg)
                     (if (< (mark) (point)) -1 1)))
         (set-mark
@@ -192,8 +194,7 @@ open-parenthesis, and point ends up at the beginning of the line.
 If variable `beginning-of-defun-function' is non-nil, its value
 is called as a function to find the defun's beginning."
   (interactive "p")
-  (or inhibit-mark-movement
-      (not (eq this-command 'beginning-of-defun))
+  (or (not (eq this-command 'beginning-of-defun))
       (eq last-command 'beginning-of-defun)
       (and transient-mark-mode mark-active)
       (push-mark))
@@ -245,8 +246,7 @@ matches the open-parenthesis that starts a defun; see function
 If variable `end-of-defun-function' is non-nil, its value
 is called as a function to find the defun's end."
   (interactive "p")
-  (or inhibit-mark-movement
-      (not (eq this-command 'end-of-defun))
+  (or (not (eq this-command 'end-of-defun))
       (eq last-command 'end-of-defun)
       (and transient-mark-mode mark-active)
       (push-mark))
@@ -291,14 +291,17 @@ is called as a function to find the defun's end."
                (goto-char (point-min)))))
        (setq arg (1+ arg))))))
 
-(defun mark-defun ()
+(defun mark-defun (&optional allow-extend)
   "Put mark at end of this defun, point at beginning.
 The defun marked is the one that contains point or follows point.
-If this command is repeated or mark is active in Transient Mark mode,
-it marks more defuns after the ones already marked."
-  (interactive)
-  (cond ((or (and (eq last-command this-command) (mark t))
-            (and transient-mark-mode mark-active))
+
+Interactively, if this command is repeated
+or (in Transient Mark mode) if the mark is active, 
+it marks the next defun after the ones already marked."
+  (interactive "p")
+  (cond ((and allow-extend
+             (or (and (eq last-command this-command) (mark t))
+                 (and transient-mark-mode mark-active)))
         (set-mark
          (save-excursion
            (goto-char (mark))