changeset 2049:a358c97a23e4

(save_excursion_save): Save mark_active of buffer. (save_excursion_restore): Restore mark_active of buffer. Run activate-mark-hook if it's on, or deactivate-mark-hook if it turns off. (region_limit): Error if mark inactive, if transient-mark-mode.
author Richard M. Stallman <rms@gnu.org>
date Sun, 07 Mar 1993 09:32:22 +0000
parents 8cf58355e8a1
children 3ffbf2314074
files src/editfns.c
diffstat 1 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/editfns.c	Sun Mar 07 09:31:37 1993 +0000
+++ b/src/editfns.c	Sun Mar 07 09:32:22 1993 +0000
@@ -1,5 +1,5 @@
 /* Lisp functions pertaining to editing.
-   Copyright (C) 1985, 1986, 1987, 1989, 1992 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1987, 1989, 1993 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -196,6 +196,8 @@
      int beginningp;
 {
   register Lisp_Object m;
+  if (!NILP (Vtransient_mark_mode) && NILP (current_buffer->mark_active))
+    error ("There is no region now");
   m = Fmarker_position (current_buffer->mark);
   if (NILP (m)) error ("There is no region now");
   if ((point < XFASTINT (m)) == beginningp)
@@ -281,14 +283,15 @@
 
   return Fcons (Fpoint_marker (),
 		Fcons (Fcopy_marker (current_buffer->mark),
-		       visible ? Qt : Qnil));
+		       Fcons (visible ? Qt : Qnil,
+			      current_buffer->mark_active)));		       
 }
 
 Lisp_Object
 save_excursion_restore (info)
      register Lisp_Object info;
 {
-  register Lisp_Object tem;
+  register Lisp_Object tem, tem1;
 
   tem = Fmarker_buffer (Fcar (info));
   /* If buffer being returned to is now deleted, avoid error */
@@ -305,9 +308,17 @@
   Fset_marker (current_buffer->mark, tem, Fcurrent_buffer ());
   unchain_marker (tem);
   tem = Fcdr (Fcdr (info));
-  if (!NILP (tem)
+  tem1 = Fcar (tem);
+  if (!NILP (tem1)
       && current_buffer != XBUFFER (XWINDOW (selected_window)->buffer))
     Fswitch_to_buffer (Fcurrent_buffer (), Qnil);
+
+  tem1 = current_buffer->mark_active;
+  current_buffer->mark_active = Fcdr (tem);
+  if (! NILP (current_buffer->mark_active))
+    call1 (Vrun_hooks, intern ("activate-mark-hook"));
+  else if (! NILP (tem1))
+    call1 (Vrun_hooks, intern ("deactivate-mark-hook"));
   return Qnil;
 }
 
@@ -315,7 +326,8 @@
   "Save point, mark, and current buffer; execute BODY; restore those things.\n\
 Executes BODY just like `progn'.\n\
 The values of point, mark and the current buffer are restored\n\
-even in case of abnormal exit (throw or error).")
+even in case of abnormal exit (throw or error).\n\
+The state of activation of the mark is also restored.")
   (args)
      Lisp_Object args;
 {