summaryrefslogtreecommitdiff
path: root/lisp/emacs-lock.el
diff options
context:
space:
mode:
authorJuanma Barranquero <lekktu@gmail.com>2006-11-27 15:33:13 +0000
committerJuanma Barranquero <lekktu@gmail.com>2006-11-27 15:33:13 +0000
commit9a141c70ced02878fac7ac9cc44896470b04da4b (patch)
tree844c3badea48ca44643a55c9e8999c7f7a280fb7 /lisp/emacs-lock.el
parent086e1263624b0ecaf22efea2d0ff515a0f36e73c (diff)
downloademacs-9a141c70ced02878fac7ac9cc44896470b04da4b.tar.gz
(toggle-emacs-lock): Doc fix. Simplify.
(emacs-lock-check-buffer-lock): Doc fix. Use `when'. (check-emacs-lock): Doc fix. Simplify.
Diffstat (limited to 'lisp/emacs-lock.el')
-rw-r--r--lisp/emacs-lock.el36
1 files changed, 16 insertions, 20 deletions
diff --git a/lisp/emacs-lock.el b/lisp/emacs-lock.el
index 615f2f44df3..6fb9e8ec7cb 100644
--- a/lisp/emacs-lock.el
+++ b/lisp/emacs-lock.el
@@ -1,4 +1,4 @@
-;;; emacs-lock.el --- prevents you from exiting emacs if a buffer is locked
+;;; emacs-lock.el --- prevents you from exiting Emacs if a buffer is locked
;; Copyright (C) 1994, 1997, 2002, 2003, 2004,
;; 2005, 2006 Free Software Foundation, Inc
@@ -27,12 +27,12 @@
;;; Commentary:
;; This code sets a buffer-local variable to t if toggle-emacs-lock is run,
-;; then if the user attempts to exit emacs, the locked buffer name will be
+;; then if the user attempts to exit Emacs, the locked buffer name will be
;; displayed and the exit aborted. This is just a way of protecting
;; yourself from yourself. For example, if you have a shell running a big
-;; program and exiting emacs would abort that program, you may want to lock
+;; program and exiting Emacs would abort that program, you may want to lock
;; that buffer, then if you forget about it after a while, you won't
-;; accidentally exit emacs. To unlock the buffer, just goto the buffer and
+;; accidentally exit Emacs. To unlock the buffer, just goto the buffer and
;; run toggle-emacs-lock again.
;;; Code:
@@ -48,34 +48,30 @@
(defun check-emacs-lock ()
"Check if variable `emacs-lock-from-exiting' is t for any buffer.
-If any t is found, signal error and display the locked buffer name."
- (let ((buffers (buffer-list)))
- (save-excursion
- (while buffers
- (set-buffer (car buffers))
- (if emacs-lock-from-exiting
- (error "Emacs is locked from exit due to buffer: %s" (buffer-name))
- (setq buffers (cdr buffers)))))))
+If any locked buffer is found, signal error and display the buffer's name."
+ (save-excursion
+ (dolist (buffer (buffer-list))
+ (set-buffer buffer)
+ (when emacs-lock-from-exiting
+ (error "Emacs is locked from exit due to buffer: %s" (buffer-name))))))
(defun toggle-emacs-lock ()
- "Toggle `emacs-lock-from-exiting' between t and nil for the current buffer.
+ "Toggle `emacs-lock-from-exiting' for the current buffer.
See `check-emacs-lock'."
(interactive)
- (if emacs-lock-from-exiting
- (setq emacs-lock-from-exiting nil)
- (setq emacs-lock-from-exiting t))
+ (setq emacs-lock-from-exiting (not emacs-lock-from-exiting))
(if emacs-lock-from-exiting
(message "Buffer is now locked")
(message "Buffer is now unlocked")))
(defun emacs-lock-check-buffer-lock ()
"Check if variable `emacs-lock-from-exiting' is t for a buffer.
-If t is found, signal error and display the locked buffer name."
- (if emacs-lock-from-exiting
- (error "Buffer `%s' is locked, can't delete it" (buffer-name))))
+If the buffer is locked, signal error and display its name."
+ (when emacs-lock-from-exiting
+ (error "Buffer `%s' is locked, can't delete it" (buffer-name))))
; These next defuns make it so if you exit a shell that is locked, the lock
-; is shut off for that shell so you can exit emacs. Same for telnet.
+; is shut off for that shell so you can exit Emacs. Same for telnet.
; Also, if a shell or a telnet buffer was locked and the process killed,
; turn the lock back on again if the process is restarted.