annotate lisp/emacs-lock.el @ 15304:d78c3fd6a0ab

(Info-insert-dir): Fix default directory.
author Karl Heuer <kwzh@gnu.org>
date Thu, 30 May 1996 19:46:24 +0000
parents 83f275dcd93a
children 3b7e375756d2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13337
84acc3adcd63 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 13336
diff changeset
1 ;;; emacs-lock.el --- prevents you from exiting emacs if a buffer is locked
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
2
10240
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1994 Free Software Foundation, Inc
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
4
10240
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Tom Wurgler <twurgler@goodyear.com>
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Created: 12/8/94
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Version: 1.3
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; Keywords:
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
9
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
10 ;; This file is part of GNU Emacs.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
11
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
10240
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
15 ;; any later version.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
16
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
10240
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
21
10240
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
25 ;; Boston, MA 02111-1307, USA.
10240
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
28
10240
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; This code sets a buffer-local variable to t if toggle-emacs-lock is run,
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; then if the user attempts to exit emacs, the locked buffer name will be
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; displayed and the exit aborted. This is just a way of protecting
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; yourself from yourself. For example, if you have a shell running a big
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; program and exiting emacs would abort that program, you may want to lock
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; that buffer, then if you forget about it after a while, you won't
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13337
diff changeset
35 ;; accidentally exit emacs. To unlock the buffer, just goto the buffer and
10240
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; run toggle-emacs-lock again.
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
38 ;;; Code:
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
39
10240
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 (defvar lock-emacs-from-exiting nil
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 "Whether emacs is locked to prevent exiting. See `check-emacs-lock'.")
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 (make-variable-buffer-local 'lock-emacs-from-exiting)
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (defun check-emacs-lock ()
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 "Check if variable `lock-emacs-from-exiting' is t for any buffer.
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 If any t is found, signal error and display the locked buffer name."
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (let ((buffers (buffer-list)))
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 (save-excursion
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 (while buffers
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (set-buffer (car buffers))
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 (if lock-emacs-from-exiting
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 (error "Emacs is locked from exit due to buffer: %s" (buffer-name))
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 (setq buffers (cdr buffers)))))))
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (defun toggle-emacs-lock ()
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 "Toggle `lock-emacs-from-exiting' between t and nil for the current buffer.
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 See `check-emacs-lock'."
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (interactive)
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (if lock-emacs-from-exiting
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (setq lock-emacs-from-exiting nil)
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (setq lock-emacs-from-exiting t))
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 (if lock-emacs-from-exiting
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (message "Emacs is now locked from exiting.")
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (message "Emacs is now unlocked.")))
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (add-hook 'kill-emacs-hook 'check-emacs-lock)
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
72101c74e9e7 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; emacs-lock.el ends here