Mercurial > emacs
comparison src/editfns.c @ 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 | e21c1f3e37cb |
children | 69c58e548ca5 |
comparison
equal
deleted
inserted
replaced
2048:8cf58355e8a1 | 2049:a358c97a23e4 |
---|---|
1 /* Lisp functions pertaining to editing. | 1 /* Lisp functions pertaining to editing. |
2 Copyright (C) 1985, 1986, 1987, 1989, 1992 Free Software Foundation, Inc. | 2 Copyright (C) 1985, 1986, 1987, 1989, 1993 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GNU Emacs. | 4 This file is part of GNU Emacs. |
5 | 5 |
6 GNU Emacs is free software; you can redistribute it and/or modify | 6 GNU Emacs is free software; you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
194 static Lisp_Object | 194 static Lisp_Object |
195 region_limit (beginningp) | 195 region_limit (beginningp) |
196 int beginningp; | 196 int beginningp; |
197 { | 197 { |
198 register Lisp_Object m; | 198 register Lisp_Object m; |
199 if (!NILP (Vtransient_mark_mode) && NILP (current_buffer->mark_active)) | |
200 error ("There is no region now"); | |
199 m = Fmarker_position (current_buffer->mark); | 201 m = Fmarker_position (current_buffer->mark); |
200 if (NILP (m)) error ("There is no region now"); | 202 if (NILP (m)) error ("There is no region now"); |
201 if ((point < XFASTINT (m)) == beginningp) | 203 if ((point < XFASTINT (m)) == beginningp) |
202 return (make_number (point)); | 204 return (make_number (point)); |
203 else | 205 else |
279 register int visible = (XBUFFER (XWINDOW (selected_window)->buffer) | 281 register int visible = (XBUFFER (XWINDOW (selected_window)->buffer) |
280 == current_buffer); | 282 == current_buffer); |
281 | 283 |
282 return Fcons (Fpoint_marker (), | 284 return Fcons (Fpoint_marker (), |
283 Fcons (Fcopy_marker (current_buffer->mark), | 285 Fcons (Fcopy_marker (current_buffer->mark), |
284 visible ? Qt : Qnil)); | 286 Fcons (visible ? Qt : Qnil, |
287 current_buffer->mark_active))); | |
285 } | 288 } |
286 | 289 |
287 Lisp_Object | 290 Lisp_Object |
288 save_excursion_restore (info) | 291 save_excursion_restore (info) |
289 register Lisp_Object info; | 292 register Lisp_Object info; |
290 { | 293 { |
291 register Lisp_Object tem; | 294 register Lisp_Object tem, tem1; |
292 | 295 |
293 tem = Fmarker_buffer (Fcar (info)); | 296 tem = Fmarker_buffer (Fcar (info)); |
294 /* If buffer being returned to is now deleted, avoid error */ | 297 /* If buffer being returned to is now deleted, avoid error */ |
295 /* Otherwise could get error here while unwinding to top level | 298 /* Otherwise could get error here while unwinding to top level |
296 and crash */ | 299 and crash */ |
303 unchain_marker (tem); | 306 unchain_marker (tem); |
304 tem = Fcar (Fcdr (info)); | 307 tem = Fcar (Fcdr (info)); |
305 Fset_marker (current_buffer->mark, tem, Fcurrent_buffer ()); | 308 Fset_marker (current_buffer->mark, tem, Fcurrent_buffer ()); |
306 unchain_marker (tem); | 309 unchain_marker (tem); |
307 tem = Fcdr (Fcdr (info)); | 310 tem = Fcdr (Fcdr (info)); |
308 if (!NILP (tem) | 311 tem1 = Fcar (tem); |
312 if (!NILP (tem1) | |
309 && current_buffer != XBUFFER (XWINDOW (selected_window)->buffer)) | 313 && current_buffer != XBUFFER (XWINDOW (selected_window)->buffer)) |
310 Fswitch_to_buffer (Fcurrent_buffer (), Qnil); | 314 Fswitch_to_buffer (Fcurrent_buffer (), Qnil); |
315 | |
316 tem1 = current_buffer->mark_active; | |
317 current_buffer->mark_active = Fcdr (tem); | |
318 if (! NILP (current_buffer->mark_active)) | |
319 call1 (Vrun_hooks, intern ("activate-mark-hook")); | |
320 else if (! NILP (tem1)) | |
321 call1 (Vrun_hooks, intern ("deactivate-mark-hook")); | |
311 return Qnil; | 322 return Qnil; |
312 } | 323 } |
313 | 324 |
314 DEFUN ("save-excursion", Fsave_excursion, Ssave_excursion, 0, UNEVALLED, 0, | 325 DEFUN ("save-excursion", Fsave_excursion, Ssave_excursion, 0, UNEVALLED, 0, |
315 "Save point, mark, and current buffer; execute BODY; restore those things.\n\ | 326 "Save point, mark, and current buffer; execute BODY; restore those things.\n\ |
316 Executes BODY just like `progn'.\n\ | 327 Executes BODY just like `progn'.\n\ |
317 The values of point, mark and the current buffer are restored\n\ | 328 The values of point, mark and the current buffer are restored\n\ |
318 even in case of abnormal exit (throw or error).") | 329 even in case of abnormal exit (throw or error).\n\ |
330 The state of activation of the mark is also restored.") | |
319 (args) | 331 (args) |
320 Lisp_Object args; | 332 Lisp_Object args; |
321 { | 333 { |
322 register Lisp_Object val; | 334 register Lisp_Object val; |
323 int count = specpdl_ptr - specpdl; | 335 int count = specpdl_ptr - specpdl; |