Mercurial > emacs
view lisp/erc/erc-spelling.el @ 111433:05dc9dca8729
Replace end-of-line, save-excursion etc with point-at-eol, point-at-bol.
* lisp/mh-e/mh-seq.el (mh-read-msg-list): Use point-at-eol.
* lisp/gnus/gnus-bookmark.el (gnus-bookmark-bmenu-show-infos)
(gnus-bookmark-kill-line): Use point-at-eol.
* lisp/cedet/ede/proj-elisp.el (ede-proj-flush-autoconf): Use point-at-bol.
* lisp/emacs-lisp/chart.el (chart-zap-chars):
* lisp/play/decipher.el (decipher-set-map):
* lisp/progmodes/ada-mode.el (ada-get-current-indent)
(ada-search-ignore-string-comment, ada-tab-hard, ada-untab-hard):
* lisp/progmodes/ada-prj.el (ada-prj-load-from-file, ada-prj-display-help):
* lisp/progmodes/ada-xref.el (ada-initialize-runtime-library)
(ada-get-all-references):
* lisp/progmodes/cperl-mode.el (cperl-electric-paren)
(cperl-electric-rparen, cperl-electric-keyword, cperl-electric-else)
(cperl-linefeed, cperl-sniff-for-indent, cperl-to-comment-or-eol)
(cperl-find-pods-heres, cperl-indent-exp, cperl-fix-line-spacing)
(cperl-word-at-point-hard):
* lisp/progmodes/idlw-shell.el (idlwave-shell-move-or-history)
(idlwave-shell-filename-string, idlwave-shell-batch-command)
(idlwave-shell-display-line):
* lisp/progmodes/idlwave.el (idlwave-show-begin, idlwave-fill-paragraph)
(idlwave-calc-hanging-indent, idlwave-auto-fill, idlwave-template):
* lisp/progmodes/js.el (js--re-search-forward-inner)
(js--re-search-backward-inner):
* lisp/progmodes/vhdl-mode.el (vhdl-align-region-1, vhdl-align-region-2)
(vhdl-fix-clause, vhdl-compose-configuration-architecture):
* lisp/progmodes/ruby-mode.el (ruby-parse-partial, eval-when-compile):
* lisp/textmodes/flyspell.el (flyspell-process-localwords):
* lisp/textmodes/ispell.el (ispell-buffer-local-parsing)
(ispell-buffer-local-dict, ispell-buffer-local-words):
Use point-at-bol and point-at-eol.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 06 Nov 2010 18:36:33 -0700 |
parents | 1d1d5d9bd884 |
children | 376148b31b5e |
line wrap: on
line source
;;; erc-spelling.el --- use flyspell in ERC ;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: Jorgen Schaefer <forcer@forcix.cx> ;; Keywords: irc ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?ErcSpelling ;; This file is part of GNU Emacs. ;; 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 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 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. ;;; Commentary: ;; This is an ERC module to enable flyspell mode in ERC buffers. This ;; ensures correct behavior of flyspell, and even sets up a ;; channel-local dictionary if so required. ;;; Code: (require 'erc) (require 'flyspell) ;;;###autoload (autoload 'erc-spelling-mode "erc-spelling" nil t) (define-erc-module spelling nil "Enable flyspell mode in ERC buffers." ;; 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) (dolist (buffer (erc-buffer-list)) (erc-spelling-init buffer))) ((remove-hook 'erc-connect-pre-hook 'erc-spelling-init) (dolist (buffer (erc-buffer-list)) (with-current-buffer buffer (flyspell-mode 0))))) (defcustom erc-spelling-dictionaries nil "An alist mapping buffer names to dictionaries. The `car' of every cell is a buffer name, the `cadr' is the string name of an associated dictionary. The dictionary is inherited from server buffers, so if you want a default dictionary for some server, you can use a server buffer name here." :type '(choice (const nil) (repeat (cons (string :tag "Buffer name") (string :tag "Dictionary")))) :group 'erc-spelling) (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. 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." (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) ;; arch-tag: 04ae1c46-0fd1-4e1a-8b80-55bfa471c945 ;;; erc-spelling.el ends here