Mercurial > emacs
changeset 37760:2ae7cda73ec4
(signal_before_change, signal_after_change): Consider a
local change hook which changes the buffer.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Wed, 16 May 2001 16:06:48 +0000 |
parents | a487ac338b24 |
children | 4727302e7b0b |
files | src/insdel.c |
diffstat | 1 files changed, 36 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/insdel.c Wed May 16 16:05:20 2001 +0000 +++ b/src/insdel.c Wed May 16 16:06:48 2001 +0000 @@ -1,5 +1,6 @@ /* Buffer insertion/deletion and gap motion for GNU Emacs. - Copyright (C) 1985, 86,93,94,95,97,98, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1985, 86,93,94,95,97,98, 1999, 2000, 2001 + Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -1901,6 +1902,8 @@ Lisp_Object before_change_functions; Lisp_Object after_change_functions; struct gcpro gcpro1, gcpro2; + struct buffer *old = current_buffer; + struct buffer *new; PRESERVE_VALUE; PRESERVE_START_END; @@ -1920,9 +1923,21 @@ args[2] = FETCH_END; run_hook_list_with_args (before_change_functions, 3, args); - /* "Unbind" the variables we "bound" to nil. */ - Vbefore_change_functions = before_change_functions; - Vafter_change_functions = after_change_functions; + /* "Unbind" the variables we "bound" to nil. Beware a + buffer-local hook which changes the buffer when run (e.g. W3). */ + if (old != current_buffer) + { + new = current_buffer; + set_buffer_internal (old); + Vbefore_change_functions = before_change_functions; + Vafter_change_functions = after_change_functions; + set_buffer_internal (new); + } + else + { + Vbefore_change_functions = before_change_functions; + Vafter_change_functions = after_change_functions; + } UNGCPRO; } @@ -1988,6 +2003,8 @@ Lisp_Object args[4]; Lisp_Object before_change_functions; Lisp_Object after_change_functions; + struct buffer *old = current_buffer; + struct buffer *new; struct gcpro gcpro1, gcpro2; /* "Bind" before-change-functions and after-change-functions @@ -2007,9 +2024,21 @@ run_hook_list_with_args (after_change_functions, 4, args); - /* "Unbind" the variables we "bound" to nil. */ - Vbefore_change_functions = before_change_functions; - Vafter_change_functions = after_change_functions; + /* "Unbind" the variables we "bound" to nil. Beware a + buffer-local hook which changes the buffer when run (e.g. W3). */ + if (old != current_buffer) + { + new = current_buffer; + set_buffer_internal (old); + Vbefore_change_functions = before_change_functions; + Vafter_change_functions = after_change_functions; + set_buffer_internal (new); + } + else + { + Vbefore_change_functions = before_change_functions; + Vafter_change_functions = after_change_functions; + } UNGCPRO; }