This file is indexed.

/usr/share/emacs/site-lisp/emacs-goodies-el/protbuf.el is in emacs-goodies-el 35.12.

This file is owned by root:root, with mode 0o655.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
;;; protbuf.el --- protect buffers from accidental killing

;; Copyright (C) 1994, 1999 Noah S. Friedman

;; Author: Noah Friedman <friedman@splode.com>
;; Maintainer: friedman@splode.com
;; Keywords: extensions
;; Status: Works with emacs 19.23 or later.
;; Created: 1994-06-21

;; $Id: protbuf.el,v 1.2 2013/12/04 22:32:10 psg Exp $

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, you can either send email to this
;; program's maintainer or write to: The Free Software Foundation,
;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.

;;; Commentary:

;; This package allows you to make it harder to kill buffers accidentally,
;; e.g. by being too trigger happy selecting items in the buffer menu.
;;
;; The commands are:
;;
;; `protect-buffer-from-kill-mode'
;;   Toggle kill-buffer protection on current buffer.
;;
;; `protect-process-buffer-from-kill-mode'
;;   Toggle kill-buffer protection on current buffer with active process.
;;   Protection only applies as long as the buffer has an active process.
;;
;; `protect-process-buffer-from-kill-mode' is perhaps the more useful of
;; the two, making it harder to accidentally kill shell buffers without
;; terminating the process in them first.

;;; History:
;;
;; 2003-10-07 Peter S Galbraith <psg@debian.org>
;;  - custom interface support.
;;  - make interactive commands toggle the minor-mode.
;;  - some checkdoc changes.

;;; Code:

(defgroup protect-buffer nil
  "Protect buffers from accidental killing."
  :group 'killing)

(defcustom protect-buffer-verbose t
  "*If non-nil, print a message when attempting to kill a protected buffer."
  :type 'boolean
  :group 'protect-buffer)

(defcustom protect-buffer-bury-p t
  "*If non-nil, bury buffer when attempting to kill it.
This only has an effect if the buffer to be killed is the one
visible in the selected window."
  :type 'boolean
  :group 'protect-buffer)


;;;###autoload
(defvar protect-buffer-from-kill-mode nil
  "*If non-nil, then prevent buffer from being accidentally killed.
This variable is local to all buffers.")
(progn
  (make-variable-buffer-local 'protect-buffer-from-kill-mode)
  (put 'protect-buffer-from-kill-mode 'permanent-local t)
  (or (assq 'protect-buffer-from-kill-mode minor-mode-alist)
      (setq minor-mode-alist (cons '(protect-buffer-from-kill-mode " ProtBuf")
                                   minor-mode-alist))))

;;;###autoload
(defvar protect-process-buffer-from-kill-mode nil
  "*If non-nil, then protect buffer with live process from being killed.
This variable is local to all buffers.")
(progn
  (make-variable-buffer-local 'protect-process-buffer-from-kill-mode)
  (put 'protect-process-buffer-from-kill-mode 'permanent-local t)
  (or (assq 'protect-process-buffer-from-kill-mode minor-mode-alist)
      (setq minor-mode-alist
            (cons '(protect-process-buffer-from-kill-mode " ProtProcBuf")
                  minor-mode-alist))))

;;;###autoload
(defvar protect-process-buffer-from-kill-preserve-function nil
  "*Function to run to determine whether to kill a process buffer.
If function returns non-nil, buffer is preserved.  Otherwise, the buffer
may be killed.

If this variable is undefined, default action is to test whether a process
object is using this buffer as a process buffer.

This variable is buffer-local when set.")
(make-variable-buffer-local 'protect-process-buffer-from-kill-preserve-function)
(put 'protect-process-buffer-from-kill-preserve-function 'permanent-local t)



;;;###autoload
(defun protect-buffer-from-kill-mode (&optional prefix buffer)
  "Toggle `kill-buffer' protection on current buffer.
Optionally, set a PREFIX argument to set or unset protection, and specify
alternate BUFFER."
  (interactive "P")
  (save-excursion
    (if buffer
        (set-buffer buffer))
    (set (make-local-variable 'protect-buffer-from-kill-mode)
         (if prefix
             (> (prefix-numeric-value prefix) 0)
           (not protect-buffer-from-kill-mode)))
    ;; This is always done because kill-buffer-query-functions might have
    ;; been buffer-local when this package was initially loaded, leaving
    ;; the global value unchanged.
    (add-hook 'kill-buffer-query-functions 'protect-buffer-from-kill)))

(defun protect-buffer-from-kill ()
  "Implements protection from buffer killing.
This function is listed in `kill-buffer-query-functions'; it should return
nil if the buffer should not be killed, t otherwise."
  (cond
   (protect-buffer-from-kill-mode
    (and protect-buffer-verbose
         (message "Buffer \"%s\" is protected from being killed."
                  (buffer-name)))
    (and protect-buffer-bury-p
         (eq (current-buffer)
             (window-buffer (selected-window)))
         (bury-buffer))
    nil)
   (t)))


;;;###autoload
(defun protect-process-buffer-from-kill-mode (&optional prefix buffer)
  "Toggle `kill-buffer' protection on current buffer with active process.
Protection only applies as long as the buffer has an active process.
Optionally, set a PREFIX argument to set or unset protection, and specify
alternate BUFFER."
  (interactive "P")
  (save-excursion
    (if buffer
        (set-buffer buffer))
    (set (make-local-variable 'protect-process-buffer-from-kill-mode)
         (if prefix
             (> (prefix-numeric-value prefix) 0)
           (not protect-process-buffer-from-kill-mode)))
    ;; This is always done because kill-buffer-query-functions might have
    ;; been buffer-local when this package was initially loaded, leaving
    ;; the global value unchanged.
    (add-hook 'kill-buffer-query-functions 'protect-process-buffer-from-kill)))

(defun protect-process-buffer-from-kill ()
  "Implements protection from buffer killing.
This function is listed in `kill-buffer-query-functions'; it should return
nil if the buffer should be protected, t if buffer should be killed."
  (cond
   ((not protect-process-buffer-from-kill-mode) t)
   ((or (and (boundp 'protect-process-buffer-from-kill-preserve-function)
             protect-process-buffer-from-kill-preserve-function
             (funcall protect-process-buffer-from-kill-preserve-function))
        (get-buffer-process (current-buffer)))
    (and protect-buffer-verbose
         (message "Buffer \"%s\" has live process; not killing."
                  (buffer-name)))
    (and protect-buffer-bury-p
         (eq (current-buffer)
             (window-buffer (selected-window)))
         (bury-buffer))
    nil)
   (t t)))

(add-hook 'kill-buffer-query-functions 'protect-buffer-from-kill)
(add-hook 'kill-buffer-query-functions 'protect-process-buffer-from-kill)

(provide 'protbuf)

;;; protbuf.el ends here