* Re: fortran-fill-paragraph fails [not found] <m3r6uq778w.fsf@tfkp07.physik.uni-erlangen.de> @ 2006-12-24 0:15 ` Michaël Cadilhac 2006-12-24 1:35 ` Roland Winkler ` (2 more replies) 0 siblings, 3 replies; 14+ messages in thread From: Michaël Cadilhac @ 2006-12-24 0:15 UTC (permalink / raw) Cc: emacs-devel [-- Attachment #1.1.1: Type: text/plain, Size: 447 bytes --] "Roland Winkler" <Roland.Winkler@physik.uni-erlangen.de> writes: > Start a fresh emacs --no-init-file. Load file foo.f (fortran-mode): > cat foo.f <<EOF > C This is a fortran comment > CALL FOO > EOF > > On line 1 execute fill-paragraph, which will run > fortran-fill-paragraph. This gives me > > C This is a fortran comment ALL FOO Thanks for reporting this bug. Does the following fix it ? (And is it an acceptable solution ?) [-- Attachment #1.1.2: fill.patch --] [-- Type: text/x-patch, Size: 1579 bytes --] Index: lisp/textmodes/fill.el =================================================================== RCS file: /sources/emacs/emacs/lisp/textmodes/fill.el,v retrieving revision 1.192 diff -c -r1.192 fill.el *** lisp/textmodes/fill.el 6 Nov 2006 16:01:53 -0000 1.192 --- lisp/textmodes/fill.el 24 Dec 2006 00:12:07 -0000 *************** *** 838,844 **** (commark (comment-string-strip (buffer-substring comstart comin) nil t)) (comment-re ! (if (string-match comment-start-skip (concat commark "a")) (concat "[ \t]*" (regexp-quote commark) ;; Make sure we only match comments that use ;; the exact same comment marker. --- 838,844 ---- (commark (comment-string-strip (buffer-substring comstart comin) nil t)) (comment-re ! (if (string-match comment-start-skip (concat "\0" commark "a")) (concat "[ \t]*" (regexp-quote commark) ;; Make sure we only match comments that use ;; the exact same comment marker. Index: lisp/ChangeLog =================================================================== RCS file: /sources/emacs/emacs/lisp/ChangeLog,v retrieving revision 1.10475 diff -C0 -r1.10475 ChangeLog *** lisp/ChangeLog 23 Dec 2006 19:06:59 -0000 1.10475 --- lisp/ChangeLog 24 Dec 2006 00:13:34 -0000 *************** *** 0 **** --- 1,5 ---- + 2006-12-24 Michaël Cadilhac <michael.cadilhac@lrde.org> + + * textmodes/fill.el (fill-comment-paragraph): Prevent the use of + an optimized comment regexp if `comment-start-skip' uses a ^. + [-- Attachment #1.1.3: Type: text/plain, Size: 403 bytes --] -- /!\ My mail address has changed, please update your files accordingly. | Michaël `Micha' Cadilhac | C'est véritablement un scandale | | Epita/LRDE Promo 2007 | et probablement une contrepéterie. | | http://michael.cadilhac.name | -- P. Desproges | `--JID: 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] 14+ messages in thread
* Re: fortran-fill-paragraph fails 2006-12-24 0:15 ` fortran-fill-paragraph fails Michaël Cadilhac @ 2006-12-24 1:35 ` Roland Winkler 2006-12-24 20:26 ` Michaël Cadilhac 2006-12-25 23:00 ` Stefan Monnier 2 siblings, 0 replies; 14+ messages in thread From: Roland Winkler @ 2006-12-24 1:35 UTC (permalink / raw) Cc: emacs-devel On Sun Dec 24 2006 Michaël Cadilhac wrote: > "Roland Winkler" <Roland.Winkler@physik.uni-erlangen.de> writes: > > Start a fresh emacs --no-init-file. Load file foo.f (fortran-mode): > > cat foo.f <<EOF > > C This is a fortran comment > > CALL FOO > > EOF > > > > On line 1 execute fill-paragraph, which will run > > fortran-fill-paragraph. This gives me > > > > C This is a fortran comment ALL FOO > > Thanks for reporting this bug. > > Does the following fix it ? (And is it an acceptable solution ?) Thanks a lot for the quick reply. For me, it works fine for the above. Hopefully someone else can comment whether your patch is not causing new problems which is unfortunately beyond my elisp knowledge. Roland ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: fortran-fill-paragraph fails 2006-12-24 0:15 ` fortran-fill-paragraph fails Michaël Cadilhac 2006-12-24 1:35 ` Roland Winkler @ 2006-12-24 20:26 ` Michaël Cadilhac 2006-12-25 23:00 ` Stefan Monnier 2 siblings, 0 replies; 14+ messages in thread From: Michaël Cadilhac @ 2006-12-24 20:26 UTC (permalink / raw) Cc: emacs-devel [-- Attachment #1.1: Type: text/plain, Size: 1516 bytes --] michael@cadilhac.name (Michaël Cadilhac) writes: > "Roland Winkler" <Roland.Winkler@physik.uni-erlangen.de> writes: > >> Start a fresh emacs --no-init-file. Load file foo.f (fortran-mode): >> cat foo.f <<EOF >> C This is a fortran comment >> CALL FOO >> EOF >> >> On line 1 execute fill-paragraph, which will run >> fortran-fill-paragraph. This gives me >> >> C This is a fortran comment ALL FOO > > Thanks for reporting this bug. > > Does the following fix it ? (And is it an acceptable solution ?) > > *** lisp/textmodes/fill.el 6 Nov 2006 16:01:53 -0000 1.192 > --- lisp/textmodes/fill.el 24 Dec 2006 00:12:07 -0000 > *************** > *** 838,844 **** > (commark > (comment-string-strip (buffer-substring comstart comin) nil t)) > (comment-re > ! (if (string-match comment-start-skip (concat commark "a")) > --- 838,844 ---- > (commark > (comment-string-strip (buffer-substring comstart comin) nil t)) > (comment-re > ! (if (string-match comment-start-skip (concat "\0" commark "a")) Installed. -- /!\ My mail address has changed, please update your files accordingly. | Michaël `Micha' Cadilhac | C'est véritablement un scandale | | Epita/LRDE Promo 2007 | et probablement une contrepéterie. | | http://michael.cadilhac.name | -- P. Desproges | `--JID: 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] 14+ messages in thread
* Re: fortran-fill-paragraph fails 2006-12-24 0:15 ` fortran-fill-paragraph fails Michaël Cadilhac 2006-12-24 1:35 ` Roland Winkler 2006-12-24 20:26 ` Michaël Cadilhac @ 2006-12-25 23:00 ` Stefan Monnier 2006-12-27 17:12 ` Roland Winkler 2 siblings, 1 reply; 14+ messages in thread From: Stefan Monnier @ 2006-12-25 23:00 UTC (permalink / raw) Cc: emacs-devel, Roland Winkler > *************** > *** 838,844 **** > (commark > (comment-string-strip (buffer-substring comstart comin) nil t)) > (comment-re > ! (if (string-match comment-start-skip (concat commark "a")) > (concat "[ \t]*" (regexp-quote commark) > ;; Make sure we only match comments that use > ;; the exact same comment marker. > --- 838,844 ---- > (commark > (comment-string-strip (buffer-substring comstart comin) nil t)) > (comment-re > ! (if (string-match comment-start-skip (concat "\0" commark "a")) > (concat "[ \t]*" (regexp-quote commark) > ;; Make sure we only match comments that use > ;; the exact same comment marker. Please add a clear comment explaining the reason for this "\0". Stefan ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: fortran-fill-paragraph fails 2006-12-25 23:00 ` Stefan Monnier @ 2006-12-27 17:12 ` Roland Winkler 2006-12-29 21:06 ` Stefan Monnier 0 siblings, 1 reply; 14+ messages in thread From: Roland Winkler @ 2006-12-27 17:12 UTC (permalink / raw) Cc: emacs-devel On Mon Dec 25 2006 Stefan Monnier wrote: > > (commark > > (comment-string-strip (buffer-substring comstart comin) nil t)) > > (comment-re > > ! (if (string-match comment-start-skip (concat "\0" commark "a")) > > (concat "[ \t]*" (regexp-quote commark) > > ;; Make sure we only match comments that use > > ;; the exact same comment marker. > > Please add a clear comment explaining the reason for this "\0". I must admit that this patch goes much beyond my knowledge of elisp hacking. Also, I cannot find anything in the elisp manual explaining the meaning of "\0" in this context. If there is a general idea for this, I'd much appreciate if it was documented in the elisp manual, too. (Or did I look at the wrong spot?) Roland ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: fortran-fill-paragraph fails 2006-12-27 17:12 ` Roland Winkler @ 2006-12-29 21:06 ` Stefan Monnier 2006-12-29 22:43 ` Michaël Cadilhac ` (2 more replies) 0 siblings, 3 replies; 14+ messages in thread From: Stefan Monnier @ 2006-12-29 21:06 UTC (permalink / raw) Cc: Michaël Cadilhac, emacs-devel >> > (commark >> > (comment-string-strip (buffer-substring comstart comin) nil t)) >> > (comment-re >> > ! (if (string-match comment-start-skip (concat "\0" commark "a")) >> > (concat "[ \t]*" (regexp-quote commark) >> > ;; Make sure we only match comments that use >> > ;; the exact same comment marker. >> >> Please add a clear comment explaining the reason for this "\0". > I must admit that this patch goes much beyond my knowledge of elisp > hacking. Also, I cannot find anything in the elisp manual explaining > the meaning of "\0" in this context. If there is a general idea for > this, I'd much appreciate if it was documented in the elisp manual, > too. (Or did I look at the wrong spot?) There's nothing specific to elisp there, and the \0 is just some arbitrary char: a space would have probably worked just as well. Stefan ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: fortran-fill-paragraph fails 2006-12-29 21:06 ` Stefan Monnier @ 2006-12-29 22:43 ` Michaël Cadilhac 2006-12-30 6:24 ` Richard Stallman 2006-12-30 16:04 ` Roland Winkler 2 siblings, 0 replies; 14+ messages in thread From: Michaël Cadilhac @ 2006-12-29 22:43 UTC (permalink / raw) Cc: emacs-devel, Roland Winkler [-- Attachment #1.1: Type: text/plain, Size: 1455 bytes --] Stefan Monnier <monnier@iro.umontreal.ca> writes: >>> > (commark >>> > (comment-string-strip (buffer-substring comstart comin) nil t)) >>> > (comment-re >>> > ! (if (string-match comment-start-skip (concat "\0" commark "a")) >>> > (concat "[ \t]*" (regexp-quote commark) >>> > ;; Make sure we only match comments that use >>> > ;; the exact same comment marker. >>> >>> Please add a clear comment explaining the reason for this "\0". > >> I must admit that this patch goes much beyond my knowledge of elisp >> hacking. Also, I cannot find anything in the elisp manual explaining >> the meaning of "\0" in this context. If there is a general idea for >> this, I'd much appreciate if it was documented in the elisp manual, >> too. (Or did I look at the wrong spot?) > > There's nothing specific to elisp there, and the \0 is just some > arbitrary char: a space would have probably worked just as well. ... but it would have needed some thinking to get rid of the « probably » ;-) I've installed a comment for that. Thanks for your help Stefan! -- | Michaël `Micha' Cadilhac | Le second degré, | | Epita/LRDE Promo 2007 | c'est un peu | | http://michael.cadilhac.name | le verlan sémantique. | `--JID: 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] 14+ messages in thread
* Re: fortran-fill-paragraph fails 2006-12-29 21:06 ` Stefan Monnier 2006-12-29 22:43 ` Michaël Cadilhac @ 2006-12-30 6:24 ` Richard Stallman 2006-12-30 12:56 ` Michaël Cadilhac 2006-12-30 16:04 ` Roland Winkler 2 siblings, 1 reply; 14+ messages in thread From: Richard Stallman @ 2006-12-30 6:24 UTC (permalink / raw) Cc: emacs-devel, michael, Roland.Winkler There's nothing specific to elisp there, and the \0 is just some arbitrary char: a space would have probably worked just as well. What purpose does that character serve? Is the aim to prevent the regexp from ever matching, in practice? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: fortran-fill-paragraph fails 2006-12-30 6:24 ` Richard Stallman @ 2006-12-30 12:56 ` Michaël Cadilhac 2006-12-31 1:45 ` Richard Stallman 0 siblings, 1 reply; 14+ messages in thread From: Michaël Cadilhac @ 2006-12-30 12:56 UTC (permalink / raw) Cc: emacs-devel, Stefan Monnier, Roland.Winkler [-- Attachment #1.1: Type: text/plain, Size: 1382 bytes --] Richard Stallman <rms@gnu.org> writes: > There's nothing specific to elisp there, and the \0 is just some > arbitrary char: a space would have probably worked just as well. > > What purpose does that character serve? Is the aim to prevent the > regexp from ever matching, in practice? No! The aim of \0 is to prevent the match when the regexp is "^C", for example, but also "^x?C" (no mode does that AFAIK, but it's just a security) where x is any non regexp-special char except \0. Suppose commark is `C', we will have : (string-match "^C" (concat "\0" commark "a")) -> nil (string-match "C" (concat "\0" commark "a")) -> 1 (string-match "^ ?C" (concat "\0" commark "a")) -> nil If ` ' was used instead of "\0", the last one would have returned 0. Of course, it doesn't prevent a regexp like "^.C", but we can suppose, IMO, that no mode will do that. And IMO, it would be overkill to do something to prevent that. "\0" is just a more secure char in this precise context, at no cost :-) (except this thread ;-)) -- | Michaël `Micha' Cadilhac | In a World without Walls and Fences, | | Epita/LRDE Promo 2007 | who needs Windows and Gates? | | http://michael.cadilhac.name | -- Dino Esposito | `--JID: 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] 14+ messages in thread
* Re: fortran-fill-paragraph fails 2006-12-30 12:56 ` Michaël Cadilhac @ 2006-12-31 1:45 ` Richard Stallman 2007-01-02 23:22 ` Stefan Monnier 0 siblings, 1 reply; 14+ messages in thread From: Richard Stallman @ 2006-12-31 1:45 UTC (permalink / raw) Cc: emacs-devel, monnier, Roland.Winkler Suppose commark is `C', we will have : (string-match "^C" (concat "\0" commark "a")) -> nil (string-match "C" (concat "\0" commark "a")) -> 1 (string-match "^ ?C" (concat "\0" commark "a")) -> nil Why are these results correct? What is the overall explanation for the job this code is trying to do? I find I can't understand these comments ;; `commark' is surrounded with arbitrary text (`\0' and `a') ;; to make sure it can be used as an optimization of ;; `comment-start-skip' in the middle of a line. For example, ;; `commark' can't be used with the "@c" in TeXinfo (hence ;; the `a') or with the "C" at BOL in Fortran (hence the `\0'). As far as I know, COMMARK (which is how it should be written) refers to some text copied out of the buffer. What does it mean to say whether that that text "can't be used with the `@c' in Texinfo"? Is there anyone that actually understands that comment and could rewrite it more clearly? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: fortran-fill-paragraph fails 2006-12-31 1:45 ` Richard Stallman @ 2007-01-02 23:22 ` Stefan Monnier 2007-01-03 21:11 ` Richard Stallman 0 siblings, 1 reply; 14+ messages in thread From: Stefan Monnier @ 2007-01-02 23:22 UTC (permalink / raw) Cc: emacs-devel, Michaël Cadilhac, Roland.Winkler > Suppose commark is `C', we will have : > (string-match "^C" (concat "\0" commark "a")) -> nil > (string-match "C" (concat "\0" commark "a")) -> 1 > (string-match "^ ?C" (concat "\0" commark "a")) -> nil > Why are these results correct? What is the overall explanation for > the job this code is trying to do? > I find I can't understand these comments > ;; `commark' is surrounded with arbitrary text (`\0' and `a') > ;; to make sure it can be used as an optimization of > ;; `comment-start-skip' in the middle of a line. For example, > ;; `commark' can't be used with the "@c" in TeXinfo (hence > ;; the `a') or with the "C" at BOL in Fortran (hence the `\0'). > As far as I know, COMMARK (which is how it should be written) refers > to some text copied out of the buffer. What does it mean to say > whether that that text "can't be used with the `@c' in Texinfo"? > Is there anyone that actually understands that comment > and could rewrite it more clearly? It seems a bit hard to understand indeed. What the code around there is trying to do is to try and come up with a more precise regexp than comment-start-skip, which should not match any comment-start but only the exact comment starter used in these comment lines. So if the comment starter used is ";;;" the regexp can just be something like ";;;[^;]". But that's only for "typical" comment markers. For Texinfo's "@c" we can't just use "@c[^c]" because "@ca" is not a comment starter. And For Fortran we can't just use "C[^C]" because the "C" is only a comment starter when it's at the beginning of a line. We heuristically try to discover whether it's a "typical" comment starter by matching (concat "\0" comstart "a") against comment-start-skip, which should correctly distinguish those two special cases. Stefan ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: fortran-fill-paragraph fails 2007-01-02 23:22 ` Stefan Monnier @ 2007-01-03 21:11 ` Richard Stallman 2007-01-07 20:12 ` Stefan Monnier 0 siblings, 1 reply; 14+ messages in thread From: Richard Stallman @ 2007-01-03 21:11 UTC (permalink / raw) Cc: emacs-devel, michael, Roland.Winkler So if the comment starter used is ";;;" the regexp can just be something like ";;;[^;]". But that's only for "typical" comment markers. For Texinfo's "@c" we can't just use "@c[^c]" because "@ca" is not a comment starter. And For Fortran we can't just use "C[^C]" because the "C" is only a comment starter when it's at the beginning of a line. We heuristically try to discover whether it's a "typical" comment starter by matching (concat "\0" comstart "a") against comment-start-skip, which should correctly distinguish those two special cases. Could you make the comments explain this? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: fortran-fill-paragraph fails 2007-01-03 21:11 ` Richard Stallman @ 2007-01-07 20:12 ` Stefan Monnier 0 siblings, 0 replies; 14+ messages in thread From: Stefan Monnier @ 2007-01-07 20:12 UTC (permalink / raw) Cc: emacs-devel, michael, Roland.Winkler > So if the comment starter used is ";;;" the regexp can just be > something like ";;;[^;]". But that's only for "typical" comment > markers. For Texinfo's "@c" we can't just use "@c[^c]" because "@ca" > is not a comment starter. And For Fortran we can't just use "C[^C]" > because the "C" is only a comment starter when it's at the beginning > of a line. > We heuristically try to discover whether it's a "typical" comment > starter by matching (concat "\0" comstart "a") against > comment-start-skip, which should correctly distinguish those two > special cases. > Could you make the comments explain this? Done, Stefan ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: fortran-fill-paragraph fails 2006-12-29 21:06 ` Stefan Monnier 2006-12-29 22:43 ` Michaël Cadilhac 2006-12-30 6:24 ` Richard Stallman @ 2006-12-30 16:04 ` Roland Winkler 2 siblings, 0 replies; 14+ messages in thread From: Roland Winkler @ 2006-12-30 16:04 UTC (permalink / raw) Cc: Michaël Cadilhac, emacs-devel On Fri Dec 29 2006 Stefan Monnier wrote: > There's nothing specific to elisp there, and the \0 is just some > arbitrary char: a space would have probably worked just as well. Thank you, slowly I start to understand what happens. The char must be "sufficiently arbitrary" to do the job. If "\0" is replaced by "C" it doesn't solve the bug. It is rather unlikely that "\0" has the special meaning in some other mode which "C" has in fortran-mode. Roland ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2007-01-07 20:12 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <m3r6uq778w.fsf@tfkp07.physik.uni-erlangen.de> 2006-12-24 0:15 ` fortran-fill-paragraph fails Michaël Cadilhac 2006-12-24 1:35 ` Roland Winkler 2006-12-24 20:26 ` Michaël Cadilhac 2006-12-25 23:00 ` Stefan Monnier 2006-12-27 17:12 ` Roland Winkler 2006-12-29 21:06 ` Stefan Monnier 2006-12-29 22:43 ` Michaël Cadilhac 2006-12-30 6:24 ` Richard Stallman 2006-12-30 12:56 ` Michaël Cadilhac 2006-12-31 1:45 ` Richard Stallman 2007-01-02 23:22 ` Stefan Monnier 2007-01-03 21:11 ` Richard Stallman 2007-01-07 20:12 ` Stefan Monnier 2006-12-30 16:04 ` Roland Winkler
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).