X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/a5805c9d0240fab504f2a3e32db6449392005fb6..ae940284fa77a6928f5162b7de859e67bdc7506c:/lisp/erc/erc-spelling.el diff --git a/lisp/erc/erc-spelling.el b/lisp/erc/erc-spelling.el index 41e342c0e5..845a9f07a5 100644 --- a/lisp/erc/erc-spelling.el +++ b/lisp/erc/erc-spelling.el @@ -1,6 +1,6 @@ ;;; erc-spelling.el --- use flyspell in ERC -;; Copyright (C) 2005, 2006 Free Software Foundation, Inc. +;; Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. ;; Author: Jorgen Schaefer ;; Keywords: irc @@ -8,10 +8,10 @@ ;; 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 @@ -19,9 +19,7 @@ ;; 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 . ;;; Commentary: @@ -40,13 +38,11 @@ ;; 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) - (with-current-buffer buffer (erc-spelling-init))) - (erc-buffer-list))) + (dolist (buffer (erc-buffer-list)) + (erc-spelling-init buffer))) ((remove-hook 'erc-connect-pre-hook 'erc-spelling-init) - (mapc (lambda (buffer) - (with-current-buffer buffer (flyspell-mode 0))) - (erc-buffer-list)))) + (dolist (buffer (erc-buffer-list)) + (with-current-buffer buffer (flyspell-mode 0))))) (defcustom erc-spelling-dictionaries nil "An alist mapping buffer names to dictionaries. @@ -60,24 +56,22 @@ name here." (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.