GNU bug report logs -
#59201
`fill-paragraph' works differently depending on whether Emacs is run in batch mode or not
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 59201 in the body.
You can then email your comments to 59201 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59201
; Package
emacs
.
(Fri, 11 Nov 2022 19:41:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Paul Pogonyshev <pogonyshev <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 11 Nov 2022 19:41:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Tested with Emacs 28 and a recent Emacs 29 build.
To reproduce:
$ emacs --batch --eval "(princ (with-temp-buffer (insert \"Lorem ipsum
dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua...\n\") (set-mark 1)
(fill-paragraph nil t) (buffer-string)) 'external-debugging-output)"
Prints the text in one line, i.e. `fill-paragraph' appears to have done
nothing.
If you replace `--batch' in the command line with `-Q' without changing
*anything* else:
$ emacs -Q --eval "(princ (with-temp-buffer (insert \"Lorem ipsum dolor
sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna aliqua...\n\") (set-mark 1) (fill-paragraph nil t)
(buffer-string)) 'external-debugging-output)"
the output in the console becomes formatted in two lines, i.e.
`fill-paragraph' does its work.
In both cases the code is exactly the same and the function is called
non-interactively. The only difference, as far as I see, is the batch mode.
Paul
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59201
; Package
emacs
.
(Sat, 12 Nov 2022 11:18:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 59201 <at> debbugs.gnu.org (full text, mbox):
tags 59201 notabug
thanks
> From: Paul Pogonyshev <pogonyshev <at> gmail.com>
> Date: Fri, 11 Nov 2022 20:40:25 +0100
>
> $ emacs --batch --eval "(princ (with-temp-buffer (insert \"Lorem ipsum dolor sit amet, consectetur
> adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...\n\") (set-mark 1)
> (fill-paragraph nil t) (buffer-string)) 'external-debugging-output)"
>
> Prints the text in one line, i.e. `fill-paragraph' appears to have done nothing.
>
> If you replace `--batch' in the command line with `-Q' without changing anything else:
>
> $ emacs -Q --eval "(princ (with-temp-buffer (insert \"Lorem ipsum dolor sit amet, consectetur adipiscing
> elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...\n\") (set-mark 1) (fill-paragraph nil
> t) (buffer-string)) 'external-debugging-output)"
>
> the output in the console becomes formatted in two lines, i.e. `fill-paragraph' does its work.
>
> In both cases the code is exactly the same and the function is called non-interactively. The only difference,
> as far as I see, is the batch mode.
Your program has a bug: it doesn't make sure transient-mark-mode is
turned ON, and it doesn't move point after inserting the text into the
inserted text. Thus, point is left at EOB, where there's no paragraph
that fill-paragraph can work on. The doc string of fill-paragraph
says:
Fill paragraph at or after point.
[...]
The REGION argument is non-nil if called interactively; in that
case, if Transient Mark mode is enabled and the mark is active,
call ‘fill-region’ to fill each of the paragraphs in the active
region, instead of just filling the current paragraph.
If you modify the program as follows:
$ emacs --batch --eval "(princ (with-temp-buffer (insert \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...\n\") (goto-char (point-min)) (set-mark 1) (fill-paragraph nil t) (buffer-string)) 'external-debugging-output)"
then the text will be filled in --batch mode as well.
Transient Mark mode is turned on by default only in interactive
sessions, and if you meant fill-region to work on the active region,
then the solution is to modify the program like this:
$ emacs --batch --eval "(princ (with-temp-buffer (insert \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...\n\") (transient-mark-mode 1) (set-mark 1) (fill-paragraph nil t) (buffer-string)) 'external-debugging-output)"
Added tag(s) notabug.
Request was from
Eli Zaretskii <eliz <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Sat, 12 Nov 2022 11:18:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#59201
; Package
emacs
.
(Sat, 12 Nov 2022 11:27:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 59201 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thanks, please close this then.
Paul
On Sat, 12 Nov 2022 at 12:17, Eli Zaretskii <eliz <at> gnu.org> wrote:
> tags 59201 notabug
> thanks
>
> > From: Paul Pogonyshev <pogonyshev <at> gmail.com>
> > Date: Fri, 11 Nov 2022 20:40:25 +0100
> >
> > $ emacs --batch --eval "(princ (with-temp-buffer (insert \"Lorem
> ipsum dolor sit amet, consectetur
> > adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
> magna aliqua...\n\") (set-mark 1)
> > (fill-paragraph nil t) (buffer-string)) 'external-debugging-output)"
> >
> > Prints the text in one line, i.e. `fill-paragraph' appears to have done
> nothing.
> >
> > If you replace `--batch' in the command line with `-Q' without changing
> anything else:
> >
> > $ emacs -Q --eval "(princ (with-temp-buffer (insert \"Lorem ipsum
> dolor sit amet, consectetur adipiscing
> > elit, sed do eiusmod tempor incididunt ut labore et dolore magna
> aliqua...\n\") (set-mark 1) (fill-paragraph nil
> > t) (buffer-string)) 'external-debugging-output)"
> >
> > the output in the console becomes formatted in two lines, i.e.
> `fill-paragraph' does its work.
> >
> > In both cases the code is exactly the same and the function is called
> non-interactively. The only difference,
> > as far as I see, is the batch mode.
>
> Your program has a bug: it doesn't make sure transient-mark-mode is
> turned ON, and it doesn't move point after inserting the text into the
> inserted text. Thus, point is left at EOB, where there's no paragraph
> that fill-paragraph can work on. The doc string of fill-paragraph
> says:
>
> Fill paragraph at or after point.
> [...]
> The REGION argument is non-nil if called interactively; in that
> case, if Transient Mark mode is enabled and the mark is active,
> call ‘fill-region’ to fill each of the paragraphs in the active
> region, instead of just filling the current paragraph.
>
> If you modify the program as follows:
>
> $ emacs --batch --eval "(princ (with-temp-buffer (insert \"Lorem ipsum
> dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
> incididunt ut labore et dolore magna aliqua...\n\") (goto-char (point-min))
> (set-mark 1) (fill-paragraph nil t) (buffer-string))
> 'external-debugging-output)"
>
> then the text will be filled in --batch mode as well.
>
> Transient Mark mode is turned on by default only in interactive
> sessions, and if you meant fill-region to work on the active region,
> then the solution is to modify the program like this:
>
> $ emacs --batch --eval "(princ (with-temp-buffer (insert \"Lorem ipsum
> dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
> incididunt ut labore et dolore magna aliqua...\n\") (transient-mark-mode 1)
> (set-mark 1) (fill-paragraph nil t) (buffer-string))
> 'external-debugging-output)"
>
[Message part 2 (text/html, inline)]
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Sat, 12 Nov 2022 11:34:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Paul Pogonyshev <pogonyshev <at> gmail.com>
:
bug acknowledged by developer.
(Sat, 12 Nov 2022 11:34:02 GMT)
Full text and
rfc822 format available.
Message #18 received at 59201-done <at> debbugs.gnu.org (full text, mbox):
> From: Paul Pogonyshev <pogonyshev <at> gmail.com>
> Date: Sat, 12 Nov 2022 12:26:12 +0100
> Cc: 59201 <at> debbugs.gnu.org
>
> Thanks, please close this then.
Done.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 10 Dec 2022 12:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 191 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.