2
## 50_protbuf_custom_and_toggle.dpatch by Peter S Galbraith <psg@debian.org>
4
## All lines beginning with `## DP:' are a description of the patch.
5
## DP: protbuf - custom support + true toggles.
8
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
12
[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
13
patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
16
-patch) patch $patch_opts -p1 < $0;;
17
-unpatch) patch $patch_opts -p1 -R < $0;;
19
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
26
diff -urNad /home/psg/emacs/emacs-goodies-el/emacs-goodies-el/elisp/emacs-goodies-el/protbuf.el emacs-goodies-el/elisp/emacs-goodies-el/protbuf.el
27
--- /home/psg/emacs/emacs-goodies-el/emacs-goodies-el/elisp/emacs-goodies-el/protbuf.el 2003-10-07 19:18:26.000000000 -0400
28
+++ emacs-goodies-el/elisp/emacs-goodies-el/protbuf.el 2003-10-07 21:20:08.000000000 -0400
31
;; This package allows you to make it harder to kill buffers accidentally,
32
;; e.g. by being too trigger happy selecting items in the buffer menu.
33
-;; protect-process-buffer-from-kill-mode is perhaps the more useful of the
34
-;; two, making it harder to accidentally kill shell buffers without
38
+;; `protect-buffer-from-kill-mode'
39
+;; Toggle kill-buffer protection on current buffer.
41
+;; `protect-process-buffer-from-kill-mode'
42
+;; Toggle kill-buffer protection on current buffer with active process.
43
+;; Protection only applies as long as the buffer has an active process.
45
+;; `protect-process-buffer-from-kill-mode' is perhaps the more useful of
46
+;; the two, making it harder to accidentally kill shell buffers without
47
;; terminating the process in them first.
51
+;; 2003-10-07 Peter S Galbraith <psg@debian.org>
52
+;; - custom interface support.
53
+;; - make interactive commands toggle the minor-mode.
54
+;; - some checkdoc changes.
58
-(defvar protect-buffer-verbose t
59
- "*If non-nil, print a message when attempting to kill a protected buffer.")
60
+(defgroup protect-buffer nil
61
+ "Protect buffers from accidental killing."
64
-(defvar protect-buffer-bury-p t
65
+(defcustom protect-buffer-verbose t
66
+ "*If non-nil, print a message when attempting to kill a protected buffer."
68
+ :group 'protect-buffer)
70
+(defcustom protect-buffer-bury-p t
71
"*If non-nil, bury buffer when attempting to kill it.
72
This only has an effect if the buffer to be killed is the one
73
-visible in the selected window.")
74
+visible in the selected window."
76
+ :group 'protect-buffer)
80
(defvar protect-buffer-from-kill-mode nil
81
- "*If non-`nil', then prevent buffer from being accidentally killed.
82
+ "*If non-nil, then prevent buffer from being accidentally killed.
83
This variable is local to all buffers.")
85
(make-variable-buffer-local 'protect-buffer-from-kill-mode)
89
(defvar protect-process-buffer-from-kill-mode nil
90
- "*If non-`nil', then protect buffer with live process from being killed.
91
+ "*If non-nil, then protect buffer with live process from being killed.
92
This variable is local to all buffers.")
94
(make-variable-buffer-local 'protect-process-buffer-from-kill-mode)
98
(defun protect-buffer-from-kill-mode (&optional prefix buffer)
99
- "Protect buffer from being killed.
100
-To remove this protection, call this command with a negative prefix argument."
101
+ "Toggle `kill-buffer' protection on current buffer.
102
+Optionally, set a PREFIX argument to set or unset protection, and specify
105
- (or buffer (setq buffer (current-buffer)))
107
- ;; Each cond does its own set-buffer *after* comparing prefix just in
108
- ;; case there's a buffer-local variable `prefix' to screw up the works.
111
- (set-buffer buffer)
112
- (setq protect-buffer-from-kill-mode
113
- (not protect-buffer-from-kill-mode)))
115
- (set-buffer buffer)
116
- (setq protect-buffer-from-kill-mode t))
118
- (set-buffer buffer)
119
- (setq protect-buffer-from-kill-mode nil)))
121
+ (set-buffer buffer))
122
+ (set (make-local-variable 'protect-buffer-from-kill-mode)
124
+ (> (prefix-numeric-value prefix) 0)
125
+ (not protect-buffer-from-kill-mode)))
126
;; This is always done because kill-buffer-query-functions might have
127
;; been buffer-local when this package was initially loaded, leaving
128
;; the global value unchanged.
129
(add-hook 'kill-buffer-query-functions 'protect-buffer-from-kill)))
131
-;; This function is listed in kill-buffer-query-functions; it should return
132
-;; nil if the buffer should not be killed, t otherwise.
133
(defun protect-buffer-from-kill ()
134
+ "Implements protection from buffer killing.
135
+This function is listed in `kill-buffer-query-functions'; it should return
136
+nil if the buffer should not be killed, t otherwise."
138
(protect-buffer-from-kill-mode
139
(and protect-buffer-verbose
140
@@ -125,32 +144,27 @@
143
(defun protect-process-buffer-from-kill-mode (&optional prefix buffer)
144
- "Protect buffer from being killed as long as it has an active process.
145
-To remove this protection, call this command with a negative prefix argument."
146
+ "Toggle `kill-buffer' protection on current buffer with active process.
147
+Protection only applies as long as the buffer has an active process.
148
+Optionally, set a PREFIX argument to set or unset protection, and specify
151
- (or buffer (setq buffer (current-buffer)))
153
- ;; Each cond does its own set-buffer *after* comparing prefix just in
154
- ;; case there's a buffer-local variable `prefix' to screw up the works.
157
- (set-buffer buffer)
158
- (setq protect-process-buffer-from-kill-mode
159
- (not protect-process-buffer-from-kill-mode)))
161
- (set-buffer buffer)
162
- (setq protect-process-buffer-from-kill-mode t))
164
- (set-buffer buffer)
165
- (setq protect-process-buffer-from-kill-mode nil)))
167
+ (set-buffer buffer))
168
+ (set (make-local-variable 'protect-process-buffer-from-kill-mode)
170
+ (> (prefix-numeric-value prefix) 0)
171
+ (not protect-process-buffer-from-kill-mode)))
172
;; This is always done because kill-buffer-query-functions might have
173
;; been buffer-local when this package was initially loaded, leaving
174
;; the global value unchanged.
175
(add-hook 'kill-buffer-query-functions 'protect-process-buffer-from-kill)))
177
-;; This function is listed in kill-buffer-query-functions; it should return
178
-;; nil if the buffer should be protected, t if buffer should be killed.
179
(defun protect-process-buffer-from-kill ()
180
+ "Implements protection from buffer killing.
181
+This function is listed in `kill-buffer-query-functions'; it should return
182
+nil if the buffer should be protected, t if buffer should be killed."
184
((not protect-process-buffer-from-kill-mode) t)
185
((or (and (boundp 'protect-process-buffer-from-kill-preserve-function)