From: Dmitry Antipov Date: Thu, 11 Oct 2012 13:23:12 +0000 (+0400) Subject: * editfns.c (save_excursion_save): Use nil if mark points to nowhere. X-Git-Tag: emacs-24.2.90~235^2~29 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=549c3414d97575bfe537d2a4d357d48ea58c980a;p=emacs.git * editfns.c (save_excursion_save): Use nil if mark points to nowhere. (save_excursion_restore): Do not restore mark if it was not saved. --- diff --git a/src/ChangeLog b/src/ChangeLog index 0b274598986..99caae59cf7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2012-10-11 Dmitry Antipov + + * editfns.c (save_excursion_save): Use nil if mark points to nowhere. + (save_excursion_restore): Do not restore mark if it was not saved. + 2012-10-11 Paul Eggert * marker.c (cached_modiff): EMACS_INT, not int. diff --git a/src/editfns.c b/src/editfns.c index fc6465a3d46..19fad7130a7 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -819,9 +819,13 @@ save_excursion_save (void) { bool visible = (XBUFFER (XWINDOW (selected_window)->buffer) == current_buffer); + /* Do not copy the mark if it points to nowhere. */ + Lisp_Object mark = (XMARKER (BVAR (current_buffer, mark))->buffer + ? Fcopy_marker (BVAR (current_buffer, mark), Qnil) + : Qnil); return Fcons (Fpoint_marker (), - Fcons (Fcopy_marker (BVAR (current_buffer, mark), Qnil), + Fcons (mark, Fcons (visible ? Qt : Qnil, Fcons (BVAR (current_buffer, mark_active), selected_window)))); @@ -856,9 +860,14 @@ save_excursion_restore (Lisp_Object info) info = XCDR (info); tem = XCAR (info); omark = Fmarker_position (BVAR (current_buffer, mark)); - Fset_marker (BVAR (current_buffer, mark), tem, Fcurrent_buffer ()); - nmark = Fmarker_position (tem); - unchain_marker (XMARKER (tem)); + if (NILP (tem)) + unchain_marker (XMARKER (BVAR (current_buffer, mark))); + else + { + Fset_marker (BVAR (current_buffer, mark), tem, Fcurrent_buffer ()); + nmark = Fmarker_position (tem); + unchain_marker (XMARKER (tem)); + } /* visible */ info = XCDR (info);