summaryrefslogtreecommitdiff
path: root/lisp/erc/erc-spelling.el
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2006-02-05 12:42:51 +0000
committerMiles Bader <miles@gnu.org>2006-02-05 12:42:51 +0000
commit8508e990c1c0b9bd69bc1d8f7fa2a57753029156 (patch)
tree144e7b505b7262f272839f8535e4ae8f7bd2cbef /lisp/erc/erc-spelling.el
parent98950fd6ba7f1460ceb548002caa75a92d593af3 (diff)
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-46
Creator: Michael Olson <mwolson@gnu.org> Merge from erc--emacs--0
Diffstat (limited to 'lisp/erc/erc-spelling.el')
-rw-r--r--lisp/erc/erc-spelling.el55
1 files changed, 39 insertions, 16 deletions
diff --git a/lisp/erc/erc-spelling.el b/lisp/erc/erc-spelling.el
index dd9aad68f22..41e342c0e50 100644
--- a/lisp/erc/erc-spelling.el
+++ b/lisp/erc/erc-spelling.el
@@ -64,28 +64,51 @@ name here."
"Enable flyspell mode in an ERC buffer."
(let ((name (downcase (buffer-name)))
(dicts erc-spelling-dictionaries))
- (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)))))
+ (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))
-(put 'erc-mode
- 'flyspell-mode-predicate
- 'erc-spelling-flyspell-verify)
+(defun erc-spelling-unhighlight-word (word)
+ "Unhighlight the given WORD.
+The cadr is the beginning and the caddr is the end."
+ (let ((beg (nth 1 word))
+ (end (nth 2 word)))
+ (flyspell-unhighlight-at beg)
+ (when (> end beg)
+ (flyspell-unhighlight-at (1- end)))))
(defun erc-spelling-flyspell-verify ()
"Flyspell only the input line, nothing else."
- (> (point)
- erc-input-marker))
+ (let ((word-data (and (boundp 'flyspell-word)
+ flyspell-word)))
+ (when word-data
+ (cond ((< (point) erc-input-marker)
+ nil)
+ ;; don't spell-check names of users
+ ((and erc-channel-users
+ (erc-get-channel-user (car word-data)))
+ (erc-spelling-unhighlight-word word-data)
+ nil)
+ ;; if '/' occurs before the word, don't spell-check it
+ ((eq (char-before (nth 1 word-data)) ?/)
+ (erc-spelling-unhighlight-word word-data)
+ nil)
+ (t t)))))
+
+(put 'erc-mode
+ 'flyspell-mode-predicate
+ 'erc-spelling-flyspell-verify)
(provide 'erc-spelling)