diff options
| author | Richard M. Stallman | 1994-02-24 05:34:16 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-02-24 05:34:16 +0000 |
| commit | dcdffbf66a72f4eeda7ee995157fa09c32e19dff (patch) | |
| tree | 255baa953a61ecc2a811222eadc4f5c5de4706b8 | |
| parent | 88902b356e9b11e65625517c0471895e9ace8937 (diff) | |
| download | emacs-dcdffbf66a72f4eeda7ee995157fa09c32e19dff.tar.gz emacs-dcdffbf66a72f4eeda7ee995157fa09c32e19dff.zip | |
(Fkill_buffer): Call the Vkill_buffer_query_functions.
(syms_of_buffer): Make Lisp var for kill-buffer-query-functions.
| -rw-r--r-- | src/buffer.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c index 638a3f70241..2f21a7b133f 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -117,6 +117,10 @@ Lisp_Object Vtransient_mark_mode; | |||
| 117 | Any non-nil value means ignore buffer-read-only. */ | 117 | Any non-nil value means ignore buffer-read-only. */ |
| 118 | Lisp_Object Vinhibit_read_only; | 118 | Lisp_Object Vinhibit_read_only; |
| 119 | 119 | ||
| 120 | /* List of functions to call that can query about killing a buffer. | ||
| 121 | If any of these functions returns nil, we don't kill it. */ | ||
| 122 | Lisp_Object Vkill_buffer_query_functions; | ||
| 123 | |||
| 120 | /* List of functions to call before changing an unmodified buffer. */ | 124 | /* List of functions to call before changing an unmodified buffer. */ |
| 121 | Lisp_Object Vfirst_change_hook; | 125 | Lisp_Object Vfirst_change_hook; |
| 122 | Lisp_Object Qfirst_change_hook; | 126 | Lisp_Object Qfirst_change_hook; |
| @@ -729,13 +733,25 @@ with `delete-process'.") | |||
| 729 | return Qnil; | 733 | return Qnil; |
| 730 | } | 734 | } |
| 731 | 735 | ||
| 732 | /* Run kill-buffer hook with the buffer to be killed the current buffer. */ | 736 | /* Run hooks with the buffer to be killed the current buffer. */ |
| 733 | { | 737 | { |
| 734 | register Lisp_Object val; | 738 | register Lisp_Object val; |
| 735 | int count = specpdl_ptr - specpdl; | 739 | int count = specpdl_ptr - specpdl; |
| 740 | Lisp_Object list; | ||
| 736 | 741 | ||
| 737 | record_unwind_protect (save_excursion_restore, save_excursion_save ()); | 742 | record_unwind_protect (save_excursion_restore, save_excursion_save ()); |
| 738 | set_buffer_internal (b); | 743 | set_buffer_internal (b); |
| 744 | |||
| 745 | /* First run the query functions; if any query is answered no, | ||
| 746 | don't kill the buffer. */ | ||
| 747 | for (list = Vkill_buffer_query_functions; !NILP (list); list = Fcdr (list)) | ||
| 748 | { | ||
| 749 | tem = call0 (Fcar (list)); | ||
| 750 | if (NILP (tem)) | ||
| 751 | return unbind_to (count, Qnil); | ||
| 752 | } | ||
| 753 | |||
| 754 | /* Then run the hooks. */ | ||
| 739 | call1 (Vrun_hooks, Qkill_buffer_hook); | 755 | call1 (Vrun_hooks, Qkill_buffer_hook); |
| 740 | unbind_to (count, Qnil); | 756 | unbind_to (count, Qnil); |
| 741 | } | 757 | } |
| @@ -2615,6 +2631,10 @@ and disregard a `read-only' text property if the property value\n\ | |||
| 2615 | is a member of the list."); | 2631 | is a member of the list."); |
| 2616 | Vinhibit_read_only = Qnil; | 2632 | Vinhibit_read_only = Qnil; |
| 2617 | 2633 | ||
| 2634 | DEFVAR_LISP ("kill-buffer-query-functions", &Vkill_buffer_query_functions, | ||
| 2635 | "List of functions called with no args to query before killing a buffer."); | ||
| 2636 | Vkill_buffer_query_functions = Qnil; | ||
| 2637 | |||
| 2618 | defsubr (&Sbuffer_list); | 2638 | defsubr (&Sbuffer_list); |
| 2619 | defsubr (&Sget_buffer); | 2639 | defsubr (&Sget_buffer); |
| 2620 | defsubr (&Sget_file_buffer); | 2640 | defsubr (&Sget_file_buffer); |