;;; erc-spelling.el --- use flyspell in ERC
-;; Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2012 Free Software Foundation, Inc.
;; Author: Jorgen Schaefer <forcer@forcix.cx>
;; Keywords: irc
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; called AFTER the server buffer is initialized.
((add-hook 'erc-connect-pre-hook 'erc-spelling-init)
(dolist (buffer (erc-buffer-list))
- (when (buffer-live-p buffer)
- (with-current-buffer buffer (erc-spelling-init)))))
+ (erc-spelling-init buffer)))
((remove-hook 'erc-connect-pre-hook 'erc-spelling-init)
(dolist (buffer (erc-buffer-list))
- (when (buffer-live-p buffer)
- (with-current-buffer buffer (flyspell-mode 0))))))
+ (with-current-buffer buffer (flyspell-mode 0)))))
(defcustom erc-spelling-dictionaries nil
"An alist mapping buffer names to dictionaries.
(string :tag "Dictionary"))))
:group 'erc-spelling)
-(defun erc-spelling-init ()
- "Enable flyspell mode in an ERC buffer."
- (let ((name (downcase (buffer-name)))
- (dicts erc-spelling-dictionaries))
- (when dicts
- (while (and dicts
- (not (string= name (downcase (caar dicts)))))
- (setq dicts (cdr dicts)))
- (setq ispell-local-dictionary
- (if dicts
- (cadr (car dicts))
- (let ((server (erc-server-buffer)))
- (if server
- (with-current-buffer server
- ispell-local-dictionary)
- nil))))))
- (setq flyspell-generic-check-word-p 'erc-spelling-flyspell-verify)
- (flyspell-mode 1))
+(defun erc-spelling-init (buffer)
+ "Enable flyspell mode in an ERC buffer.
+The current buffer is given by BUFFER."
+ (with-current-buffer buffer
+ (let ((name (downcase (buffer-name)))
+ (dicts erc-spelling-dictionaries))
+ (when dicts
+ (while (and dicts
+ (not (string= name (downcase (caar dicts)))))
+ (setq dicts (cdr dicts)))
+ (setq ispell-local-dictionary
+ (if dicts
+ (cadr (car dicts))
+ (erc-with-server-buffer ispell-local-dictionary)))))
+ (setq flyspell-generic-check-word-p 'erc-spelling-flyspell-verify)
+ (flyspell-mode 1)))
(defun erc-spelling-unhighlight-word (word)
"Unhighlight the given WORD.
(provide 'erc-spelling)
-;; arch-tag: 04ae1c46-0fd1-4e1a-8b80-55bfa471c945
;;; erc-spelling.el ends here