erc-commit
[Top][All Lists]
Advanced

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

[Erc-commit] [commit][emacs22] erc-log: Try to fix error when quitting E


From: mwolson
Subject: [Erc-commit] [commit][emacs22] erc-log: Try to fix error when quitting Emacs.
Date: Sun, 14 Oct 2007 00:48:20 -0400

commit 76ffbcc90116d2eaec824467aaf42c75c846222a
Author: Michael Olson <address@hidden>
Date:   Sat Jul 15 00:48:35 2006 +0000

    erc-log: Try to fix error when quitting Emacs.
    
    * erc-log.el (log): Make sure that we enable logging on already-opened
      buffers as well, in case the user toggles this module after loading
      ERC.  Also be sure to remove logging ability from all ERC buffers when
      the module is disabled.
      (erc-log-setup-logging): Set buffer-file-name to nil rather than the
      empty string.  This should fix some errors that occur when quitting
      Emacs without first killing all ERC buffers.
      (erc-log-disable-logging): New function that removes the logging
      ability from the current buffer.
    
    * erc-spelling.el (spelling): Use dolist and buffer-live-p.
    git-archimport-id: address@hidden/erc--main--0--patch-23

diff --git a/ChangeLog b/ChangeLog
index 38b0520..7f04ee7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2006-07-14  Michael Olson  <address@hidden>
+
+       * erc-log.el (log): Make sure that we enable logging on
+       already-opened buffers as well, in case the user toggles this
+       module after loading ERC.  Also be sure to remove logging ability
+       from all ERC buffers when the module is disabled.
+       (erc-log-setup-logging): Set buffer-file-name to nil rather than
+       the empty string.  This should fix some errors that occur when
+       quitting Emacs without first killing all ERC buffers.
+       (erc-log-disable-logging): New function that removes the logging
+       ability from the current buffer.
+
+       * erc-spelling.el (spelling): Use dolist and buffer-live-p.
+
 2006-07-12  Michael Olson  <address@hidden>
 
        * erc-match.el (erc-log-matches): Bind inhibit-read-only rather
diff --git a/erc-log.el b/erc-log.el
index dc5ba7d..18b2e3b 100644
--- a/erc-log.el
+++ b/erc-log.el
@@ -218,7 +218,10 @@ also be a predicate function. To only log when you are not 
set away, use:
    (add-hook 'erc-quit-hook 'erc-conditional-save-queries)
    (add-hook 'erc-part-hook 'erc-conditional-save-buffer)
    ;; append, so that 'erc-initialize-log-marker runs first
-   (add-hook 'erc-connect-pre-hook 'erc-log-setup-logging 'append))
+   (add-hook 'erc-connect-pre-hook 'erc-log-setup-logging 'append)
+   (dolist (buffer (erc-buffer-list))
+     (when (buffer-live-p buffer)
+       (with-current-buffer buffer (erc-log-setup-logging)))))
   ;; disable
   ((remove-hook 'erc-insert-post-hook 'erc-save-buffer-in-logs)
    (remove-hook 'erc-send-post-hook 'erc-save-buffer-in-logs)
@@ -226,7 +229,10 @@ also be a predicate function. To only log when you are not 
set away, use:
    (remove-hook 'erc-kill-channel-hook 'erc-save-buffer-in-logs)
    (remove-hook 'erc-quit-hook 'erc-conditional-save-queries)
    (remove-hook 'erc-part-hook 'erc-conditional-save-buffer)
-   (remove-hook 'erc-connect-pre-hook 'erc-log-setup-logging)))
+   (remove-hook 'erc-connect-pre-hook 'erc-log-setup-logging)
+   (dolist (buffer (erc-buffer-list))
+     (when (buffer-live-p buffer)
+       (with-current-buffer buffer (erc-log-disable-logging))))))
 
 (define-key erc-mode-map "\C-c\C-l" 'erc-save-buffer-in-logs)
 
@@ -237,7 +243,7 @@ This function is destined to be run from 
`erc-connect-pre-hook'."
   (when (erc-logging-enabled)
     (auto-save-mode -1)
     (setq buffer-offer-save t
-         buffer-file-name "")
+         buffer-file-name nil)
     (cond ((boundp 'write-file-functions)
           (set (make-local-variable 'write-file-functions)
                '(erc-save-buffer-in-logs)))
@@ -251,6 +257,12 @@ This function is destined to be run from 
`erc-connect-pre-hook'."
                     (move-marker erc-last-saved-position
                                  (1- (point-max)))))))
 
+(defun erc-log-disable-logging ()
+  "Disable logging in the current buffer."
+  (when (erc-logging-enabled)
+    (setq buffer-offer-save nil
+         erc-enable-logging nil)))
+
 (defun erc-log-all-but-server-buffers (buffer)
   "Returns t if logging should be enabled in BUFFER.
 Returns nil iff `erc-server-buffer-p' returns t."
diff --git a/erc-spelling.el b/erc-spelling.el
index 528668f..ed49758 100644
--- a/erc-spelling.el
+++ b/erc-spelling.el
@@ -40,15 +40,13 @@
   ;; Use erc-connect-pre-hook instead of erc-mode-hook as pre-hook is
   ;; called AFTER the server buffer is initialized.
   ((add-hook 'erc-connect-pre-hook 'erc-spelling-init)
-   (mapc (lambda (buffer)
-           (when buffer
-             (with-current-buffer buffer (erc-spelling-init))))
-         (erc-buffer-list)))
+   (dolist (buffer (erc-buffer-list))
+     (when (buffer-live-p buffer)
+       (with-current-buffer buffer (erc-spelling-init)))))
   ((remove-hook 'erc-connect-pre-hook 'erc-spelling-init)
-   (mapc (lambda (buffer)
-           (when buffer
-             (with-current-buffer buffer (flyspell-mode 0))))
-         (erc-buffer-list))))
+   (dolist (buffer (erc-buffer-list))
+     (when (buffer-live-p buffer)
+       (with-current-buffer buffer (flyspell-mode 0))))))
 
 (defcustom erc-spelling-dictionaries nil
   "An alist mapping buffer names to dictionaries.




reply via email to

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