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 + + * 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. +