all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* flypell and check-comments.
@ 2007-03-07 14:36 Michaël Cadilhac
  2007-03-07 18:28 ` martin rudalics
  0 siblings, 1 reply; 15+ messages in thread
From: Michaël Cadilhac @ 2007-03-07 14:36 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1.1: Type: text/plain, Size: 238 bytes --]

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:

[-- Attachment #1.1.2: flyspell.patch --]
[-- Type: text/x-patch, Size: 3958 bytes --]

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  <michael@cadilhac.name>
+ 
+ 	* 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.
+ 

[-- Attachment #1.1.3: Type: text/plain, Size: 608 bytes --]


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.    |
 `----  michael.cadilhac@gmail.com  |           -- P. Desproges         -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2007-03-25 19:48 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-07 14:36 flypell and check-comments Michaël Cadilhac
2007-03-07 18:28 ` martin rudalics
2007-03-07 18:42   ` Michaël Cadilhac
2007-03-07 20:31   ` Stefan Monnier
2007-03-07 21:55     ` martin rudalics
2007-03-11  4:24     ` Richard Stallman
2007-03-11 12:59       ` Michaël Cadilhac
2007-03-11 14:38         ` martin rudalics
2007-03-11 17:25           ` Michaël Cadilhac
2007-03-11 19:52             ` martin rudalics
2007-03-12 13:01               ` Michaël Cadilhac
2007-03-12 18:59                 ` martin rudalics
2007-03-11 21:58         ` Stefan Monnier
2007-03-24 16:55         ` Chong Yidong
2007-03-25 19:48           ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.