Mercurial > emacs
comparison src/buffer.c @ 87977:0f04103be3bf
(reset_buffer_local_variables): Implement `permanent-local-hook'.
(Qpermanent_local_hook): New variable.
(syms_of_buffer): init and staticpro it.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Fri, 25 Jan 2008 22:56:30 +0000 |
| parents | e1d6c4e34d2c |
| children | c70e45a7acfd |
comparison
equal
deleted
inserted
replaced
| 87976:d56fb4ed60d1 | 87977:0f04103be3bf |
|---|---|
| 151 | 151 |
| 152 /* If nonzero, all modification hooks are suppressed. */ | 152 /* If nonzero, all modification hooks are suppressed. */ |
| 153 int inhibit_modification_hooks; | 153 int inhibit_modification_hooks; |
| 154 | 154 |
| 155 Lisp_Object Qfundamental_mode, Qmode_class, Qpermanent_local; | 155 Lisp_Object Qfundamental_mode, Qmode_class, Qpermanent_local; |
| 156 Lisp_Object Qpermanent_local_hook; | |
| 156 | 157 |
| 157 Lisp_Object Qprotected_field; | 158 Lisp_Object Qprotected_field; |
| 158 | 159 |
| 159 Lisp_Object QSFundamental; /* A string "Fundamental" */ | 160 Lisp_Object QSFundamental; /* A string "Fundamental" */ |
| 160 | 161 |
| 759 /* Reset all (or most) per-buffer variables to their defaults. */ | 760 /* Reset all (or most) per-buffer variables to their defaults. */ |
| 760 if (permanent_too) | 761 if (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 |
| 774 XSETCDR (last, XCDR (tmp)); | 800 XSETCDR (last, XCDR (tmp)); |
| 775 } | 801 } |
| 5290 staticpro (&Qmode_class); | 5316 staticpro (&Qmode_class); |
| 5291 staticpro (&QSFundamental); | 5317 staticpro (&QSFundamental); |
| 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); |
| 5298 Qevaporate = intern ("evaporate"); | 5326 Qevaporate = intern ("evaporate"); |
| 5299 staticpro (&Qevaporate); | 5327 staticpro (&Qevaporate); |
| 5317 staticpro (&Qfirst_change_hook); | 5345 staticpro (&Qfirst_change_hook); |
| 5318 Qbefore_change_functions = intern ("before-change-functions"); | 5346 Qbefore_change_functions = intern ("before-change-functions"); |
| 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"); |
| 5325 staticpro (&Qkill_buffer_query_functions); | 5354 staticpro (&Qkill_buffer_query_functions); |
| 5326 | 5355 |
