aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorRichard M. Stallman2008-01-25 22:56:30 +0000
committerRichard M. Stallman2008-01-25 22:56:30 +0000
commit2f7a359dddf8eff1830548918d2fdc43211b84a9 (patch)
tree6cec8a532738bfc4ce73e3005764ee2ecb52f53c /src/buffer.c
parent2b88d62a493196add69d764cf971e4f10ab1e42d (diff)
downloademacs-2f7a359dddf8eff1830548918d2fdc43211b84a9.tar.gz
emacs-2f7a359dddf8eff1830548918d2fdc43211b84a9.zip
(reset_buffer_local_variables): Implement `permanent-local-hook'.
(Qpermanent_local_hook): New variable. (syms_of_buffer): init and staticpro it.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 6cbaabf85ec..cf125559f76 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -153,6 +153,7 @@ Lisp_Object Qucs_set_table_for_input;
153int inhibit_modification_hooks; 153int inhibit_modification_hooks;
154 154
155Lisp_Object Qfundamental_mode, Qmode_class, Qpermanent_local; 155Lisp_Object Qfundamental_mode, Qmode_class, Qpermanent_local;
156Lisp_Object Qpermanent_local_hook;
156 157
157Lisp_Object Qprotected_field; 158Lisp_Object Qprotected_field;
158 159
@@ -761,13 +762,38 @@ reset_buffer_local_variables (b, permanent_too)
761 b->local_var_alist = Qnil; 762 b->local_var_alist = Qnil;
762 else 763 else
763 { 764 {
764 Lisp_Object tmp, last = Qnil; 765 Lisp_Object tmp, prop, last = Qnil;
765 for (tmp = b->local_var_alist; CONSP (tmp); tmp = XCDR (tmp)) 766 for (tmp = b->local_var_alist; CONSP (tmp); tmp = XCDR (tmp))
766 if (CONSP (XCAR (tmp)) 767 if (CONSP (XCAR (tmp))
767 && SYMBOLP (XCAR (XCAR (tmp))) 768 && SYMBOLP (XCAR (XCAR (tmp)))
768 && !NILP (Fget (XCAR (XCAR (tmp)), Qpermanent_local))) 769 && !NILP (prop = Fget (XCAR (XCAR (tmp)), Qpermanent_local)))
769 /* If permanent-local, keep it. */ 770 {
770 last = tmp; 771 /* If permanent-local, keep it. */
772 last = tmp;
773 if (EQ (prop, Qpermanent_local_hook))
774 {
775 /* This is a partially permanent hook variable.
776 Preserve only the elements that want to be preserved. */
777 Lisp_Object list, newlist;
778 list = XCDR (XCAR (tmp));
779 if (!CONSP (list))
780 newlist = list;
781 else
782 for (newlist = Qnil; CONSP (list); list = XCDR (list))
783 {
784 Lisp_Object elt = XCAR (list);
785 /* Preserve element ELT if it's t,
786 if it is a function with a `permanent-local-hook' property,
787 or if it's not a symbol. */
788 if (! SYMBOLP (elt)
789 || EQ (elt, Qt)
790 || !NILP (Fget (elt, Qpermanent_local_hook)))
791 newlist = Fcons (elt, newlist);
792 }
793 XSETCDR (XCAR (tmp), Fnreverse (newlist));
794 }
795 }
796 /* Delete this local variable. */
771 else if (NILP (last)) 797 else if (NILP (last))
772 b->local_var_alist = XCDR (tmp); 798 b->local_var_alist = XCDR (tmp);
773 else 799 else
@@ -5292,6 +5318,8 @@ syms_of_buffer ()
5292 staticpro (&Vbuffer_alist); 5318 staticpro (&Vbuffer_alist);
5293 staticpro (&Qprotected_field); 5319 staticpro (&Qprotected_field);
5294 staticpro (&Qpermanent_local); 5320 staticpro (&Qpermanent_local);
5321 Qpermanent_local_hook = intern ("permanent-local-hook");
5322 staticpro (&Qpermanent_local_hook);
5295 staticpro (&Qkill_buffer_hook); 5323 staticpro (&Qkill_buffer_hook);
5296 Qoverlayp = intern ("overlayp"); 5324 Qoverlayp = intern ("overlayp");
5297 staticpro (&Qoverlayp); 5325 staticpro (&Qoverlayp);
@@ -5319,6 +5347,7 @@ syms_of_buffer ()
5319 staticpro (&Qbefore_change_functions); 5347 staticpro (&Qbefore_change_functions);
5320 Qafter_change_functions = intern ("after-change-functions"); 5348 Qafter_change_functions = intern ("after-change-functions");
5321 staticpro (&Qafter_change_functions); 5349 staticpro (&Qafter_change_functions);
5350 /* The next one is initialized in init_buffer_once. */
5322 staticpro (&Qucs_set_table_for_input); 5351 staticpro (&Qucs_set_table_for_input);
5323 5352
5324 Qkill_buffer_query_functions = intern ("kill-buffer-query-functions"); 5353 Qkill_buffer_query_functions = intern ("kill-buffer-query-functions");