diff options
| author | Juanma Barranquero | 2006-11-27 15:33:13 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2006-11-27 15:33:13 +0000 |
| commit | c4667a1a298b0d85641a0689e6eddca1294fc12e (patch) | |
| tree | c04888aecbe1108390a272b4eb148634d4974229 | |
| parent | 8d4bf0e5374213dbb5bd8b808241afff8893f80d (diff) | |
| download | emacs-c4667a1a298b0d85641a0689e6eddca1294fc12e.tar.gz emacs-c4667a1a298b0d85641a0689e6eddca1294fc12e.zip | |
(toggle-emacs-lock): Doc fix. Simplify.
(emacs-lock-check-buffer-lock): Doc fix. Use `when'.
(check-emacs-lock): Doc fix. Simplify.
| -rw-r--r-- | lisp/emacs-lock.el | 36 |
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 @@ | |||
| 1 | ;;; emacs-lock.el --- prevents you from exiting emacs if a buffer is locked | 1 | ;;; emacs-lock.el --- prevents you from exiting Emacs if a buffer is locked |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1994, 1997, 2002, 2003, 2004, | 3 | ;; Copyright (C) 1994, 1997, 2002, 2003, 2004, |
| 4 | ;; 2005, 2006 Free Software Foundation, Inc | 4 | ;; 2005, 2006 Free Software Foundation, Inc |
| @@ -27,12 +27,12 @@ | |||
| 27 | ;;; Commentary: | 27 | ;;; Commentary: |
| 28 | 28 | ||
| 29 | ;; This code sets a buffer-local variable to t if toggle-emacs-lock is run, | 29 | ;; This code sets a buffer-local variable to t if toggle-emacs-lock is run, |
| 30 | ;; then if the user attempts to exit emacs, the locked buffer name will be | 30 | ;; then if the user attempts to exit Emacs, the locked buffer name will be |
| 31 | ;; displayed and the exit aborted. This is just a way of protecting | 31 | ;; displayed and the exit aborted. This is just a way of protecting |
| 32 | ;; yourself from yourself. For example, if you have a shell running a big | 32 | ;; yourself from yourself. For example, if you have a shell running a big |
| 33 | ;; program and exiting emacs would abort that program, you may want to lock | 33 | ;; program and exiting Emacs would abort that program, you may want to lock |
| 34 | ;; that buffer, then if you forget about it after a while, you won't | 34 | ;; that buffer, then if you forget about it after a while, you won't |
| 35 | ;; accidentally exit emacs. To unlock the buffer, just goto the buffer and | 35 | ;; accidentally exit Emacs. To unlock the buffer, just goto the buffer and |
| 36 | ;; run toggle-emacs-lock again. | 36 | ;; run toggle-emacs-lock again. |
| 37 | 37 | ||
| 38 | ;;; Code: | 38 | ;;; Code: |
| @@ -48,34 +48,30 @@ | |||
| 48 | 48 | ||
| 49 | (defun check-emacs-lock () | 49 | (defun check-emacs-lock () |
| 50 | "Check if variable `emacs-lock-from-exiting' is t for any buffer. | 50 | "Check if variable `emacs-lock-from-exiting' is t for any buffer. |
| 51 | If any t is found, signal error and display the locked buffer name." | 51 | If any locked buffer is found, signal error and display the buffer's name." |
| 52 | (let ((buffers (buffer-list))) | 52 | (save-excursion |
| 53 | (save-excursion | 53 | (dolist (buffer (buffer-list)) |
| 54 | (while buffers | 54 | (set-buffer buffer) |
| 55 | (set-buffer (car buffers)) | 55 | (when emacs-lock-from-exiting |
| 56 | (if emacs-lock-from-exiting | 56 | (error "Emacs is locked from exit due to buffer: %s" (buffer-name)))))) |
| 57 | (error "Emacs is locked from exit due to buffer: %s" (buffer-name)) | ||
| 58 | (setq buffers (cdr buffers))))))) | ||
| 59 | 57 | ||
| 60 | (defun toggle-emacs-lock () | 58 | (defun toggle-emacs-lock () |
| 61 | "Toggle `emacs-lock-from-exiting' between t and nil for the current buffer. | 59 | "Toggle `emacs-lock-from-exiting' for the current buffer. |
| 62 | See `check-emacs-lock'." | 60 | See `check-emacs-lock'." |
| 63 | (interactive) | 61 | (interactive) |
| 64 | (if emacs-lock-from-exiting | 62 | (setq emacs-lock-from-exiting (not emacs-lock-from-exiting)) |
| 65 | (setq emacs-lock-from-exiting nil) | ||
| 66 | (setq emacs-lock-from-exiting t)) | ||
| 67 | (if emacs-lock-from-exiting | 63 | (if emacs-lock-from-exiting |
| 68 | (message "Buffer is now locked") | 64 | (message "Buffer is now locked") |
| 69 | (message "Buffer is now unlocked"))) | 65 | (message "Buffer is now unlocked"))) |
| 70 | 66 | ||
| 71 | (defun emacs-lock-check-buffer-lock () | 67 | (defun emacs-lock-check-buffer-lock () |
| 72 | "Check if variable `emacs-lock-from-exiting' is t for a buffer. | 68 | "Check if variable `emacs-lock-from-exiting' is t for a buffer. |
| 73 | If t is found, signal error and display the locked buffer name." | 69 | If the buffer is locked, signal error and display its name." |
| 74 | (if emacs-lock-from-exiting | 70 | (when emacs-lock-from-exiting |
| 75 | (error "Buffer `%s' is locked, can't delete it" (buffer-name)))) | 71 | (error "Buffer `%s' is locked, can't delete it" (buffer-name)))) |
| 76 | 72 | ||
| 77 | ; These next defuns make it so if you exit a shell that is locked, the lock | 73 | ; These next defuns make it so if you exit a shell that is locked, the lock |
| 78 | ; is shut off for that shell so you can exit emacs. Same for telnet. | 74 | ; is shut off for that shell so you can exit Emacs. Same for telnet. |
| 79 | ; Also, if a shell or a telnet buffer was locked and the process killed, | 75 | ; Also, if a shell or a telnet buffer was locked and the process killed, |
| 80 | ; turn the lock back on again if the process is restarted. | 76 | ; turn the lock back on again if the process is restarted. |
| 81 | 77 | ||