all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: michael@cadilhac.name (Michaël Cadilhac)
To: rms@gnu.org
Cc: rudalics@gmx.at, Stefan Monnier <monnier@iro.umontreal.ca>,
	emacs-devel@gnu.org
Subject: Re: flypell and check-comments.
Date: Sun, 11 Mar 2007 13:59:43 +0100	[thread overview]
Message-ID: <87slccrl4w.fsf@lrde.org> (raw)
In-Reply-To: <E1HQFbi-0001sm-DD@fencepost.gnu.org> (Richard Stallman's message of "Sat\, 10 Mar 2007 23\:24\:30 -0500")


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

Richard Stallman <rms@gnu.org> writes:

> Has a fix for this problem been installed?

Not yet.  If I follow Stefan's and Martin's advice (well, I hope
I really did), I have the following:


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

Index: lisp/font-lock.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/font-lock.el,v
retrieving revision 1.313
diff -c -r1.313 font-lock.el
*** lisp/font-lock.el	18 Feb 2007 20:36:06 -0000	1.313
--- lisp/font-lock.el	11 Mar 2007 11:49:31 -0000
***************
*** 1004,1009 ****
--- 1004,1020 ----
    (font-lock-set-defaults)
    (funcall font-lock-fontify-region-function beg end loudly))
  
+ ;; Avoid requiring 'jit-lock and 'lazy-lock.
+ (defalias 'font-lock--jitify 'jit-lock-fontify-now)
+ (defalias 'font-lock--lazify 'lazy-lock-fontify-region)
+ 
+ (defun font-lock-ensure-fontified (beg end)
+   "Ensure the region BEG..END is fontified, if needed."
+   (cond ((and (boundp 'jit-lock-mode) (symbol-value 'jit-lock-mode))
+ 	 (font-lock--jitify beg end))
+ 	((and (boundp 'lazy-lock-mode) (symbol-value 'lazy-lock-mode))
+ 	 (font-lock--lazify beg end))))
+ 
  (defun font-lock-unfontify-region (beg end)
    (save-buffer-state nil
      (funcall font-lock-unfontify-region-function beg end)))
Index: lisp/textmodes/flyspell.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/textmodes/flyspell.el,v
retrieving revision 1.115
diff -c -r1.115 flyspell.el
*** lisp/textmodes/flyspell.el	21 Jan 2007 03:53:09 -0000	1.115
--- lisp/textmodes/flyspell.el	11 Mar 2007 11:49:33 -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 (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 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,1025 ----
             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)
! 		   (nth 4 (syntax-ppss (car (cdr flyspell-word))))))
  	  t
  	(progn
  	  ;; destructure return flyspell-word info list.
***************
*** 1561,1566 ****
--- 1572,1580 ----
  	  (let ((old beg))
  	    (setq beg end)
  	    (setq end old)))
+       ;; Fontify the part checked, so that font-lock based tests are
+       ;; fine.
+       (font-lock-ensure-fontified 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	11 Mar 2007 11:49:50 -0000
***************
*** 0 ****
--- 1,17 ----
+ 2007-03-11  Michaël Cadilhac  <michael@cadilhac.name>
+ 
+ 	* textmodes/flyspell.el (flyspell-face-at-point-in-p): New function.
+ 	Check if the face at point is in a given list.
+ 	(flyspell-generic-progmode-verify): Use it.
+ 	(flyspell-prog-mode): Mention that `ispell-check-comments' affects
+ 	the way comments are detected.
+ 	(flyspell-word): If `ispell-check-comments' is nil, check if we are
+ 	in a comment, if so, don't check the word.
+ 	(flyspell-region): Ensure fontification before flyspelling the region,
+ 	so that font-lock based tests work.
+ 
+ 	* font-lock.el (font-lock--jitify, font-lock--lazify)
+ 	(font-lock-ensure-fontified): New aliases and function.  Ensure that
+ 	a region is fontified.  Taken from `ps-print.el'.
+ 	Suggested by Stefan Monnier.
+

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


After what we can safely change ps-print to use
font-lock-ensure-fontified.

Stefan, Martin, is the code here what you meant (it may not be,
font-locking is not my cup of tea)?

-- 
 |   Michaël `Micha' Cadilhac       |  Fenouil                               |
 |   http://michael.cadilhac.name   |                                        |
 |   JID/MSN:                       |    -- Poème de François Le Lionnais    |
 `----  michael.cadilhac@gmail.com  |                                   -  --'

[-- 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

  reply	other threads:[~2007-03-11 12:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87slccrl4w.fsf@lrde.org \
    --to=michael@cadilhac.name \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=rms@gnu.org \
    --cc=rudalics@gmx.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.