emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/emacs-lock.el,v


From: Juanma Barranquero
Subject: [Emacs-diffs] Changes to emacs/lisp/emacs-lock.el,v
Date: Mon, 27 Nov 2006 15:33:19 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Juanma Barranquero <lektu>      06/11/27 15:33:14

Index: emacs-lock.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lock.el,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- emacs-lock.el       6 Nov 2006 02:47:53 -0000       1.13
+++ emacs-lock.el       27 Nov 2006 15:33:13 -0000      1.14
@@ -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)))
+If any locked buffer is found, signal error and display the buffer's name."
     (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)))))))
+    (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
+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.
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]