[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
flypell and check-comments.
From: |
Michaël Cadilhac |
Subject: |
flypell and check-comments. |
Date: |
Wed, 07 Mar 2007 15:36:32 +0100 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.95 (gnu/linux) |
Hi!
The ispell package has an interesting feature governed by
``ispell-check-comments'', this feature behaves weirdly with flyspell.
In fact, ispell-check-comments is not at all managed by flyspell.
I propose the following to do that:
Index: lisp/textmodes/flyspell.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/textmodes/flyspell.el,v
retrieving revision 1.115
diff -B -w -c -r1.115 flyspell.el
*** lisp/textmodes/flyspell.el 21 Jan 2007 03:53:09 -0000 1.115
--- lisp/textmodes/flyspell.el 7 Mar 2007 13:40:11 -0000
***************
*** 369,382 ****
'(font-lock-string-face font-lock-comment-face font-lock-doc-face)
"Faces corresponding to text in programming-mode buffers.")
(defun flyspell-generic-progmode-verify ()
"Used for `flyspell-generic-check-word-predicate' in programming modes."
! (let ((f (get-text-property (point) 'face)))
! (memq f flyspell-prog-text-faces)))
;;;###autoload
(defun flyspell-prog-mode ()
! "Turn on `flyspell-mode' for comments and strings."
(interactive)
(setq flyspell-generic-check-word-predicate
'flyspell-generic-progmode-verify)
--- 369,391 ----
'(font-lock-string-face font-lock-comment-face font-lock-doc-face)
"Faces corresponding to text in programming-mode buffers.")
+ (defun flyspell-face-at-point-in-p (point list)
+ "Check if the face at POINT is in LIST."
+ (let ((f (get-text-property point 'face)))
+ (if (listp f)
+ (catch 'found
+ (dolist (face f)
+ (when (memq face list) (throw 'found t))))
+ (memq f list))))
+
(defun flyspell-generic-progmode-verify ()
"Used for `flyspell-generic-check-word-predicate' in programming modes."
! (flyspell-face-at-point-in-p (point) flyspell-prog-text-faces))
;;;###autoload
(defun flyspell-prog-mode ()
! "Turn on `flyspell-mode' for comments and strings.
! Note that comment checking is also affected by `ispell-check-comments'."
(interactive)
(setq flyspell-generic-check-word-predicate
'flyspell-generic-progmode-verify)
***************
*** 1008,1014 ****
start end poss word ispell-filter)
(if (or (eq flyspell-word nil)
(and (fboundp flyspell-generic-check-word-predicate)
! (not (funcall flyspell-generic-check-word-predicate))))
t
(progn
;; destructure return flyspell-word info list.
--- 1017,1026 ----
start end poss word ispell-filter)
(if (or (eq flyspell-word nil)
(and (fboundp flyspell-generic-check-word-predicate)
! (not (funcall flyspell-generic-check-word-predicate)))
! (and (not ispell-check-comments)
! (flyspell-face-at-point-in-p (car (cdr flyspell-word))
! '(font-lock-comment-face))))
t
(progn
;; destructure return flyspell-word info list.
***************
*** 1561,1566 ****
--- 1573,1581 ----
(let ((old beg))
(setq beg end)
(setq end old)))
+ ;; Fontify the part checked, so that font-lock based tests are
+ ;; fine.
+ (font-lock-fontify-region beg end)
(if (and flyspell-large-region (> (- end beg) flyspell-large-region))
(flyspell-large-region beg end)
(flyspell-small-region beg end)))))
Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.10783
diff -C0 -r1.10783 ChangeLog
*** lisp/ChangeLog 7 Mar 2007 12:50:23 -0000 1.10783
--- lisp/ChangeLog 7 Mar 2007 13:43:33 -0000
***************
*** 0 ****
--- 1,11 ----
+ 2007-03-07 Michaël Cadilhac <address@hidden>
+
+ * textmodes/flyspell.el (flyspell-face-at-point-in-p): New. Check
+ if the face at a specified point is in a face list.
+ (flyspell-generic-progmode-verify): Use it.
+ (flyspell-prog-mode): Talk about `ispell-check-comments' in the
+ docstring.
+ (flyspell-word): Consider `ispell-check-comments': if nil, don't
+ check text with face `font-lock-comment-face'.
+ (flyspell-region): Fontify the region before processing it.
+
Note the last part of the patch, the fontification. This not only for
ispell-check-comments : other flyspell features uses font-locking
based tests, and this modification is more like a bugfix than a part
of the patch (and it may be better to install it separately).
TIA!
--
| Michaël `Micha' Cadilhac | «Tu aimeras ton prochain.» |
| http://michael.cadilhac.name | D'abord, Dieu ou pas, |
| JID/MSN: | j'ai horreur qu'on me tutoie. |
`---- address@hidden | -- P. Desproges - --'
pgpzzGI0ujLFY.pgp
Description: PGP signature
- flypell and check-comments.,
Michaël Cadilhac <=
- Re: flypell and check-comments., martin rudalics, 2007/03/07
- Re: flypell and check-comments., Michaël Cadilhac, 2007/03/07
- Re: flypell and check-comments., Stefan Monnier, 2007/03/07
- Re: flypell and check-comments., martin rudalics, 2007/03/07
- Re: flypell and check-comments., Richard Stallman, 2007/03/10
- Re: flypell and check-comments., Michaël Cadilhac, 2007/03/11
- Re: flypell and check-comments., martin rudalics, 2007/03/11
- Re: flypell and check-comments., Michaël Cadilhac, 2007/03/11
- Re: flypell and check-comments., martin rudalics, 2007/03/11
- Re: flypell and check-comments., Michaël Cadilhac, 2007/03/12