Mercurial > emacs
changeset 74249:13b7163b7bff
(toggle-emacs-lock): Doc fix. Simplify.
(emacs-lock-check-buffer-lock): Doc fix. Use `when'.
(check-emacs-lock): Doc fix. Simplify.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Mon, 27 Nov 2006 15:33:13 +0000 |
parents | cbf2bdfd677d |
children | 902c7026a247 |
files | lisp/emacs-lock.el |
diffstat | 1 files changed, 16 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/emacs-lock.el Mon Nov 27 14:35:47 2006 +0000 +++ b/lisp/emacs-lock.el Mon Nov 27 15:33:13 2006 +0000 @@ -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.