* bug#59201: `fill-paragraph' works differently depending on whether Emacs is run in batch mode or not @ 2022-11-11 19:40 Paul Pogonyshev 2022-11-12 11:17 ` Eli Zaretskii 0 siblings, 1 reply; 4+ messages in thread From: Paul Pogonyshev @ 2022-11-11 19:40 UTC (permalink / raw) To: 59201 [-- Attachment #1: Type: text/plain, Size: 1035 bytes --] 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 [-- Attachment #2: Type: text/html, Size: 1342 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#59201: `fill-paragraph' works differently depending on whether Emacs is run in batch mode or not 2022-11-11 19:40 bug#59201: `fill-paragraph' works differently depending on whether Emacs is run in batch mode or not Paul Pogonyshev @ 2022-11-12 11:17 ` Eli Zaretskii 2022-11-12 11:26 ` Paul Pogonyshev 0 siblings, 1 reply; 4+ messages in thread From: Eli Zaretskii @ 2022-11-12 11:17 UTC (permalink / raw) To: Paul Pogonyshev; +Cc: 59201 tags 59201 notabug thanks > From: Paul Pogonyshev <pogonyshev@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)" ^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#59201: `fill-paragraph' works differently depending on whether Emacs is run in batch mode or not 2022-11-12 11:17 ` Eli Zaretskii @ 2022-11-12 11:26 ` Paul Pogonyshev 2022-11-12 11:33 ` Eli Zaretskii 0 siblings, 1 reply; 4+ messages in thread From: Paul Pogonyshev @ 2022-11-12 11:26 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 59201 [-- Attachment #1: Type: text/plain, Size: 2868 bytes --] Thanks, please close this then. Paul On Sat, 12 Nov 2022 at 12:17, Eli Zaretskii <eliz@gnu.org> wrote: > tags 59201 notabug > thanks > > > From: Paul Pogonyshev <pogonyshev@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)" > [-- Attachment #2: Type: text/html, Size: 3476 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#59201: `fill-paragraph' works differently depending on whether Emacs is run in batch mode or not 2022-11-12 11:26 ` Paul Pogonyshev @ 2022-11-12 11:33 ` Eli Zaretskii 0 siblings, 0 replies; 4+ messages in thread From: Eli Zaretskii @ 2022-11-12 11:33 UTC (permalink / raw) To: Paul Pogonyshev; +Cc: 59201-done > From: Paul Pogonyshev <pogonyshev@gmail.com> > Date: Sat, 12 Nov 2022 12:26:12 +0100 > Cc: 59201@debbugs.gnu.org > > Thanks, please close this then. Done. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-12 11:33 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-11-11 19:40 bug#59201: `fill-paragraph' works differently depending on whether Emacs is run in batch mode or not Paul Pogonyshev 2022-11-12 11:17 ` Eli Zaretskii 2022-11-12 11:26 ` Paul Pogonyshev 2022-11-12 11:33 ` Eli Zaretskii
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.