* 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
* Re: flypell and check-comments.
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
0 siblings, 2 replies; 15+ messages in thread
From: martin rudalics @ 2007-03-07 18:28 UTC (permalink / raw)
To: Michaël Cadilhac; +Cc: emacs-devel
> + ;; Fontify the part checked, so that font-lock based tests are
> + ;; fine.
> + (font-lock-fontify-region beg end)
I'd use `jit-lock-fontify-now' here.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: flypell and check-comments.
2007-03-07 18:28 ` martin rudalics
@ 2007-03-07 18:42 ` Michaël Cadilhac
2007-03-07 20:31 ` Stefan Monnier
1 sibling, 0 replies; 15+ messages in thread
From: Michaël Cadilhac @ 2007-03-07 18:42 UTC (permalink / raw)
To: martin rudalics; +Cc: emacs-devel
[-- Attachment #1.1: Type: text/plain, Size: 635 bytes --]
martin rudalics <rudalics@gmx.at> writes:
>> + ;; Fontify the part checked, so that font-lock based tests are
>> + ;; fine.
>> + (font-lock-fontify-region beg end)
>
> I'd use `jit-lock-fontify-now' here.
You're probably right, I'm not at all in the font-lock thing :-)
Thanks!
--
| Michaël `Micha' Cadilhac | To be portable, |
| http://michael.cadilhac.name | Just stay on Windows. |
| JID/MSN: | |
`---- michael.cadilhac@gmail.com | -- A Microsoft Guy - --'
[-- 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
* Re: flypell and check-comments.
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
1 sibling, 2 replies; 15+ messages in thread
From: Stefan Monnier @ 2007-03-07 20:31 UTC (permalink / raw)
To: martin rudalics; +Cc: Micha?l Cadilhac, emacs-devel
>> + ;; Fontify the part checked, so that font-lock based tests are
>> + ;; fine.
>> + (font-lock-fontify-region beg end)
> I'd use `jit-lock-fontify-now' here.
Actually it should be neither:
- font-lock-fontify-region will unnecessarily
refontify the region if it was already fontified.
- jit-lock-fontify-now is wrong if the user is not using jit-lock.
- if the user decided not to use font-lock...
There's a need for a new function `font-lock-ensure-fontified' which would
do nothing if font-lock doesn't use any helper thingy like lazy-lock or
font-lock and which would call jit-lock-fontify-now (or the equivalent for
lazy-lock) otherwise.
ps-print currently uses ps-print-ensure-fontified to work around the lack of
font-lock-ensure-fontified. And I'm pretty sure ps-print is not the only
such package.
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: flypell and check-comments.
2007-03-07 20:31 ` Stefan Monnier
@ 2007-03-07 21:55 ` martin rudalics
2007-03-11 4:24 ` Richard Stallman
1 sibling, 0 replies; 15+ messages in thread
From: martin rudalics @ 2007-03-07 21:55 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Micha?l Cadilhac, emacs-devel
> Actually it should be neither:
> - font-lock-fontify-region will unnecessarily
> refontify the region if it was already fontified.
That was my concern here ...
> - jit-lock-fontify-now is wrong if the user is not using jit-lock.
... `occur-mode' has ...
(if (fboundp 'jit-lock-fontify-now)
(jit-lock-fontify-now beg end)))
> - if the user decided not to use font-lock...
... it would be best (and cheaper) to use `syntax-ppss' and
`parse-partial-sexp'.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: flypell and check-comments.
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
1 sibling, 1 reply; 15+ messages in thread
From: Richard Stallman @ 2007-03-11 4:24 UTC (permalink / raw)
To: Stefan Monnier; +Cc: rudalics, michael, emacs-devel
Has a fix for this problem been installed?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: flypell and check-comments.
2007-03-11 4:24 ` Richard Stallman
@ 2007-03-11 12:59 ` Michaël Cadilhac
2007-03-11 14:38 ` martin rudalics
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Michaël Cadilhac @ 2007-03-11 12:59 UTC (permalink / raw)
To: rms; +Cc: rudalics, Stefan Monnier, emacs-devel
[-- 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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: flypell and check-comments.
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 21:58 ` Stefan Monnier
2007-03-24 16:55 ` Chong Yidong
2 siblings, 1 reply; 15+ messages in thread
From: martin rudalics @ 2007-03-11 14:38 UTC (permalink / raw)
To: Michaël Cadilhac; +Cc: emacs-devel, rms, Stefan Monnier
> Stefan, Martin, is the code here what you meant (it may not be,
> font-locking is not my cup of tea)?
Maybe the following should be reconsidered
> ! (and (not ispell-check-comments)
> ! (nth 4 (syntax-ppss (car (cdr flyspell-word))))))
since on the one hand you don't check for `ispell-check-comments' being
eq to 'exclusive (hence you don't emulate ispell faithfully - I don't
know whether this is even desirable) while on the other hand you don't
check whether you're in a string (hence you don't fully emulate the
default of `flyspell-prog-text-faces' either). But maybe I'm wrong.
Also `syntax-ppss' may get expensive for `flyspell-large-region'. It's
generally better to use it for the first position only, save position
and parse-state, and then do `parse-partial-sexp' from the last saved
position and parse-state.
By no means I want(ed) to express here that syntax _should_ be parsed.
What I meant was that if a user does not want to use font-lock _and_
wants to spell-check comments or strings specially, parsing syntax is
the only practical way. Hence, IMHO ignoring `ispell-check-comments'
here is a viable alternative as well.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: flypell and check-comments.
2007-03-11 14:38 ` martin rudalics
@ 2007-03-11 17:25 ` Michaël Cadilhac
2007-03-11 19:52 ` martin rudalics
0 siblings, 1 reply; 15+ messages in thread
From: Michaël Cadilhac @ 2007-03-11 17:25 UTC (permalink / raw)
To: martin rudalics; +Cc: emacs-devel, rms, Stefan Monnier
[-- Attachment #1.1: Type: text/plain, Size: 1762 bytes --]
martin rudalics <rudalics@gmx.at> writes:
>> Stefan, Martin, is the code here what you meant (it may not be,
>> font-locking is not my cup of tea)?
>
> Maybe the following should be reconsidered
>
>> ! (and (not ispell-check-comments)
>> ! (nth 4 (syntax-ppss (car (cdr flyspell-word))))))
>
> since on the one hand you don't check for `ispell-check-comments' being
> eq to 'exclusive
I don't think it matters. At least, if it has to be fixed, it's not
here, but maybe in `flyspell-generic-progmode-verify'. Well, I don't
really know.
> while on the other hand you don't check whether you're in a string
> (hence you don't fully emulate the default of
> `flyspell-prog-text-faces' either).
I don't understand, why should I check that I'm in a string?
> Also `syntax-ppss' may get expensive for `flyspell-large-region'. It's
> generally better to use it for the first position only, save position
> and parse-state, and then do `parse-partial-sexp' from the last saved
> position and parse-state.
I probably agree :) However, I don't really see how this can be
implemented. If ispell has to be mimicked, maybe the test should be
made using comment-start -- comment-end, but not sure.
> Hence, IMHO ignoring `ispell-check-comments' here is a viable
> alternative as well.
Well, this is not just for the fun to make a patch, I really want to
use `ispell-check-comments' (to nil).
--
| Michaël `Micha' Cadilhac | This .sig has been generated |
| http://michael.cadilhac.name | by Outlook Express 98 |
| JID/MSN: | and triple-checked on |
`---- michael.cadilhac@gmail.com | Windows Mail Vista. - --'
[-- 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
* Re: flypell and check-comments.
2007-03-11 17:25 ` Michaël Cadilhac
@ 2007-03-11 19:52 ` martin rudalics
2007-03-12 13:01 ` Michaël Cadilhac
0 siblings, 1 reply; 15+ messages in thread
From: martin rudalics @ 2007-03-11 19:52 UTC (permalink / raw)
To: Michaël Cadilhac; +Cc: emacs-devel, rms, Stefan Monnier
>>since on the one hand you don't check for `ispell-check-comments' being
>>eq to 'exclusive
>
>
> I don't think it matters. At least, if it has to be fixed, it's not
> here, but maybe in `flyspell-generic-progmode-verify'. Well, I don't
> really know.
As far as I understand this, `ispell-check-comments' t means check
comments too, 'exclusive means check comments only, somehow inverting
the sense of nil. When using faces, nil means don't check when the face
is font-lock-comment-face, 'exclusive means check iff the face is
font-lock-comment-face, t means faces don't matter. When using
parse-state it's equally simple: nil means don't check for (nth 4
parse-state), exclusive means check iff (nth 4 parse-state), and t means
parse-state doesn't matter. Trivial.
>>while on the other hand you don't check whether you're in a string
>>(hence you don't fully emulate the default of
>>`flyspell-prog-text-faces' either).
>
>
> I don't understand, why should I check that I'm in a string?
Because the default value of `flyspell-prog-text-faces' has
`font-lock-string-face', `font-lock-comment-face' and
`font-lock-doc-face'. To emulate this you would have to spell-check iff
either (nth 3 parse-state) or (nth 4 parse-state) hold. If a user
wanted to spell-check doc-strings only this wouldn't work though.
>>Also `syntax-ppss' may get expensive for `flyspell-large-region'. It's
>>generally better to use it for the first position only, save position
>>and parse-state, and then do `parse-partial-sexp' from the last saved
>>position and parse-state.
>
>
> I probably agree :) However, I don't really see how this can be
> implemented. If ispell has to be mimicked, maybe the test should be
> made using comment-start -- comment-end, but not sure.
It would have to be done in `flyspell-external-point-words' before
`flyspell-word' is called. Never mind. If there are few spelling
errors `syntax-ppss' might be even faster.
>>Hence, IMHO ignoring `ispell-check-comments' here is a viable
>>alternative as well.
>
>
> Well, this is not just for the fun to make a patch, I really want to
> use `ispell-check-comments' (to nil).
In that case you should probably implement the 'exclusive option as
well. Otherwise you should insert a note about this.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: flypell and check-comments.
2007-03-11 12:59 ` Michaël Cadilhac
2007-03-11 14:38 ` martin rudalics
@ 2007-03-11 21:58 ` Stefan Monnier
2007-03-24 16:55 ` Chong Yidong
2 siblings, 0 replies; 15+ messages in thread
From: Stefan Monnier @ 2007-03-11 21:58 UTC (permalink / raw)
To: Michaël Cadilhac; +Cc: rudalics, rms, emacs-devel
> + ;; 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))))
> +
Actually, I'd rather you do it as
(defvar font-lock-ensure-fontified-function 'ignore)
and then in jit-lock.el set it (buffer-locally) to jit-lock-fontify-now.
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: flypell and check-comments.
2007-03-11 19:52 ` martin rudalics
@ 2007-03-12 13:01 ` Michaël Cadilhac
2007-03-12 18:59 ` martin rudalics
0 siblings, 1 reply; 15+ messages in thread
From: Michaël Cadilhac @ 2007-03-12 13:01 UTC (permalink / raw)
To: martin rudalics; +Cc: emacs-devel, rms, Stefan Monnier
[-- Attachment #1.1: Type: text/plain, Size: 2478 bytes --]
martin rudalics <rudalics@gmx.at> writes:
>>>since on the one hand you don't check for `ispell-check-comments' being
>>>eq to 'exclusive
>>
>> I don't think it matters. At least, if it has to be fixed, it's not
>> here, but maybe in `flyspell-generic-progmode-verify'. Well, I don't
>> really know.
>
> As far as I understand this, `ispell-check-comments' t means check
> comments too, 'exclusive means check comments only, somehow inverting
> the sense of nil.
That's my understanding too.
> When using faces, nil means don't check when the face is
> font-lock-comment-face, 'exclusive means check iff the face is
> font-lock-comment-face, t means faces don't matter. When using
> parse-state it's equally simple: nil means don't check for (nth
> 4 parse-state), exclusive means check iff (nth 4 parse-state), and
> t means parse-state doesn't matter. Trivial.
Yes, you're right. Well, I was sick yesterday :-)
>>>while on the other hand you don't check whether you're in a string
>>>(hence you don't fully emulate the default of
>>>`flyspell-prog-text-faces' either).
>>
>> I don't understand, why should I check that I'm in a string?
>
> Because the default value of `flyspell-prog-text-faces' has
> `font-lock-string-face', `font-lock-comment-face' and
> `font-lock-doc-face'. To emulate this you would have to spell-check iff
> either (nth 3 parse-state) or (nth 4 parse-state) hold. If a user
> wanted to spell-check doc-strings only this wouldn't work though.
Sorry, I still don't understand :-/. I don't want to emulate any of
existing features of flyspell, the point is just to add one.
> It would have to be done in `flyspell-external-point-words' before
> `flyspell-word' is called. Never mind. If there are few spelling
> errors `syntax-ppss' might be even faster.
You're the knowledgeable one for me :-)
>> Well, this is not just for the fun to make a patch, I really want to
>> use `ispell-check-comments' (to nil).
>
> In that case you should probably implement the 'exclusive option as
> well. Otherwise you should insert a note about this.
You're right.
Thanks.
--
| Michaël `Micha' Cadilhac | <ESC>ape this <COLON> thing, |
| http://michael.cadilhac.name | <Q>uit and |
| JID/MSN: | do <NOT> <RET>urn. |
`---- michael.cadilhac@gmail.com | -- VI - --'
[-- 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
* Re: flypell and check-comments.
2007-03-12 13:01 ` Michaël Cadilhac
@ 2007-03-12 18:59 ` martin rudalics
0 siblings, 0 replies; 15+ messages in thread
From: martin rudalics @ 2007-03-12 18:59 UTC (permalink / raw)
To: Michaël Cadilhac; +Cc: emacs-devel, rms, Stefan Monnier
> Sorry, I still don't understand :-/. I don't want to emulate any of
> existing features of flyspell, the point is just to add one.
My point was that in absence of font-locking it would have been possible
to spell-check comments and/or strings only by looking at the 3rd and 4th
return values of the parse-state. If someone really needs this it will
be easy to add, hence there's no need to think about it any further.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: flypell and check-comments.
2007-03-11 12:59 ` Michaël Cadilhac
2007-03-11 14:38 ` martin rudalics
2007-03-11 21:58 ` Stefan Monnier
@ 2007-03-24 16:55 ` Chong Yidong
2007-03-25 19:48 ` Stefan Monnier
2 siblings, 1 reply; 15+ messages in thread
From: Chong Yidong @ 2007-03-24 16:55 UTC (permalink / raw)
To: emacs-devel
michael@cadilhac.name (Michaël Cadilhac) writes:
> Not yet. If I follow Stefan's and Martin's advice (well, I hope
> I really did), I have the following:
>
> ...
>
> Stefan, Martin, is the code here what you meant (it may not be,
> font-locking is not my cup of tea)?
What's the situation with this patch?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: flypell and check-comments.
2007-03-24 16:55 ` Chong Yidong
@ 2007-03-25 19:48 ` Stefan Monnier
0 siblings, 0 replies; 15+ messages in thread
From: Stefan Monnier @ 2007-03-25 19:48 UTC (permalink / raw)
To: Chong Yidong; +Cc: emacs-devel
>> Not yet. If I follow Stefan's and Martin's advice (well, I hope
>> I really did), I have the following:
>>
>> ...
>>
>> Stefan, Martin, is the code here what you meant (it may not be,
>> font-locking is not my cup of tea)?
> What's the situation with this patch?
Last I heard I just told him that I didn't want a font-lock-ensure-fontified
function which had just a big switch to handle the 3 known cases, but
instead one which just called font-lock-ensure-fontified-function and set
this function when turning on jit-lock-mode.
Stefan
^ 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.