]> code.delx.au - gnu-emacs/blobdiff - src/insdel.c
Fix ob-lisp.el expectation that slime would be available
[gnu-emacs] / src / insdel.c
index ac220d6b74bd924c631d1d1e4b1607a6f4a86e41..ff380ada1928eb96011b36cd08884d8f832cdd9f 100644 (file)
@@ -74,7 +74,7 @@ Lisp_Object combine_after_change_buffer;
 
 Lisp_Object Qinhibit_modification_hooks;
 
-extern Lisp_Object Vselect_active_regions, Vsaved_region_selection;
+extern Lisp_Object Vselect_active_regions, Vsaved_region_selection, Qonly;
 
 \f
 /* Check all markers in the current buffer, looking for something invalid.  */
@@ -2050,18 +2050,21 @@ prepare_to_modify_buffer (EMACS_INT start, EMACS_INT end,
 #endif /* not CLASH_DETECTION */
 
   /* If `select-active-regions' is non-nil, save the region text.  */
-  if (!NILP (Vselect_active_regions)
-      && !NILP (current_buffer->mark_active)
-      && !NILP (Vtransient_mark_mode)
-      && NILP (Vsaved_region_selection))
+  if (!NILP (current_buffer->mark_active)
+      && !inhibit_modification_hooks
+      && XMARKER (current_buffer->mark)->buffer
+      && NILP (Vsaved_region_selection)
+      && (EQ (Vselect_active_regions, Qonly)
+         ? EQ (CAR_SAFE (Vtransient_mark_mode), Qonly)
+         : (!NILP (Vselect_active_regions)
+            && !NILP (Vtransient_mark_mode))))
     {
-      Lisp_Object b = Fmarker_position (current_buffer->mark);
-      Lisp_Object e = make_number (PT);
-      if (NILP (Fequal (b, e)))
-       {
-         validate_region (&b, &e);
-         Vsaved_region_selection = make_buffer_string (XINT (b), XINT (e), 0);
-       }
+      EMACS_INT b = XMARKER (current_buffer->mark)->charpos;
+      EMACS_INT e = PT;
+      if (b < e)
+       Vsaved_region_selection = make_buffer_string (b, e, 0);
+      else if (b > e)
+       Vsaved_region_selection = make_buffer_string (e, b, 0);
     }
 
   signal_before_change (start, end, preserve_ptr);