You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Don't count form feed character (\f or ^L) as newline, optionally #2609
In Emacs, the form feed\f or ^L (Ctrl+L) character, 0xC in ASCII, is not considered to start a new line. Wikipedia explains:
The form feed character is sometimes used in plain text files of source code as a delimiter for a page break, or as marker for sections of code. Some editors, in particular emacs and vi, have built-in commands to page up/down on the form feed character. This convention is predominantly used in Lisp code, and is also seen in C and Python source code. GNU Coding Standards require such form feeds in C.[2] Editors like Vim and Emacs understand such sections and have shortcuts for moving among them.
In Emacs, a file containing just the three characters \n\f\d will be considered to have two (2) lines, the first of them being \n and the second line \f\n. But codespell counts this file as a file with three (3) lines.
Recipe to reproduce:
$ echo -ne "foo\n\f\nte\n" > /tmp/foo.txt
$ codespell /tmp/foo.txt
/tmp/foo.txt:4: te ==> the, be, we, to
If I open /tmp/foo.txt in Emacs, and try to jump to line 4, I end up on the empty line at the end of the file. I do not go to the line containing the typo, which in Emacs is line 3. This obviously gets worse the more \n\f\n there are in a file: every one means we land further and further from the actual typo.
Would it be possible to add an option to treat \f in the way that is expected by Emacs? I'm not sure what it should be called, but something like --form-feed-no-newline or --emacs-form-feed perhaps.
This would help tremendously when using codespell on Emacs Lisp source code. There are many, many Lisp files which contain the character sequence \n\f\n.
However, when I re-run the above using codespell from the master branch I do get the expected result:
/tmp/foo.txt:3: te ==> the, be, we, to
This is surprising to me, as the version I tried with previously was the latest released 2.2.2 on Debian. I can't see any relevant changes in codespell itself in the intervening period. Perhaps some bug was fixed in a dependency that was not yet updated in Debian?
Are you seeing the same as me when running current master?
Activity
DimitriPapadopoulos commentedon Nov 19, 2022
It looks
moreunderstands this too, by default:Gnome editors too, by default as well:

Perhaps it should be the default in codespell too.
skangas commentedon Nov 19, 2022
Yes, indeed it could/should be the default.
However, when I re-run the above using codespell from the master branch I do get the expected result:
This is surprising to me, as the version I tried with previously was the latest released 2.2.2 on Debian. I can't see any relevant changes in codespell itself in the intervening period. Perhaps some bug was fixed in a dependency that was not yet updated in Debian?
Are you seeing the same as me when running current
master?DimitriPapadopoulos commentedon Nov 20, 2022
Fixed by #2378.