From: Juanma Barranquero Date: Mon, 27 Nov 2006 15:33:13 +0000 (+0000) Subject: (toggle-emacs-lock): Doc fix. Simplify. X-Git-Tag: emacs-pretest-22.0.92~454 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c4667a1a298b0d85641a0689e6eddca1294fc12e;p=emacs.git (toggle-emacs-lock): Doc fix. Simplify. (emacs-lock-check-buffer-lock): Doc fix. Use `when'. (check-emacs-lock): Doc fix. Simplify. --- 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.