changeset 2075:ec62da254d4d

(set-mark): Activate the mark. (mark): Handle region-active. New optional arg FORCE. (exchange-point-and-mark, push_mark): Pass FORCE. (set-mark-command): Likewise.
author Richard M. Stallman <rms@gnu.org>
date Tue, 09 Mar 1993 05:40:33 +0000
parents 0196b8bce529
children 5140299129c3
files lisp/simple.el
diffstat 1 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/simple.el	Tue Mar 09 05:37:50 1993 +0000
+++ b/lisp/simple.el	Tue Mar 09 05:40:33 1993 +0000
@@ -1154,11 +1154,16 @@
       (save-excursion
 	(insert-buffer-substring oldbuf start end)))))
 
-(defun mark ()
-  "Return this buffer's mark value as integer, or nil if no mark.
+(defun mark (&optional force)
+  "Return this buffer's mark value as integer, or nil if no active mark now.
+If optional argument FORCE is non-nil, access the mark value
+even if the mark is not currently active.
+
 If you are using this in an editing command, you are most likely making
 a mistake; see the documentation of `set-mark'."
-  (marker-position (mark-marker)))
+  (if (or force mark-active)
+      (marker-position (mark-marker))
+    (error "The mark is not currently active")))
 
 (defun set-mark (pos)
   "Set this buffer's mark to POS.  Don't use this function!
@@ -1177,6 +1182,8 @@
 
    (let ((beg (point))) (forward-line 1) (delete-region beg (point)))."
 
+  (setq mark-active t)
+  (run-hooks 'activate-mark-hook)
   (set-marker (mark-marker) pos (current-buffer)))
 
 (defvar mark-ring nil
@@ -1197,7 +1204,7 @@
   (interactive "P")
   (if (null arg)
       (push-mark)
-    (if (null (mark))
+    (if (null (mark t))
 	(error "No mark set in this buffer")
       (goto-char (mark))
       (pop-mark))))
@@ -1208,7 +1215,7 @@
 
 Novice Emacs Lisp programmers often try to use the mark for the wrong
 purposes.  See the documentation of `set-mark' for more information."
-  (if (null (mark))
+  (if (null (mark t))
       nil
     (setq mark-ring (cons (copy-marker (mark-marker)) mark-ring))
     (if (> (length mark-ring) mark-ring-max)
@@ -1233,9 +1240,11 @@
 
 (fset 'exchange-dot-and-mark 'exchange-point-and-mark)
 (defun exchange-point-and-mark ()
-  "Put the mark where point is now, and point where the mark is now."
+  "Put the mark where point is now, and point where the mark is now.
+This command works even when the mark is not active,
+and it reactivates the mark."
   (interactive nil)
-  (let ((omark (mark)))
+  (let ((omark (mark t)))
     (if (null omark)
 	(error "No mark set in this buffer"))
     (set-mark (point))
@@ -1869,7 +1878,9 @@
 ; this is just something for the luser to see in a keymap -- this is not
 ;  how quitting works normally!
 (defun keyboard-quit ()
-  "Signal a  quit  condition."
+  "Signal a  quit  condition.
+During execution of Lisp code, this character causes a quit directly.
+At top-level, as an editor command, this simply beeps."
   (interactive)
   (signal 'quit nil))