From unknown Thu Jun 19 16:23:35 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#59201 <59201@debbugs.gnu.org> To: bug#59201 <59201@debbugs.gnu.org> Subject: Status: `fill-paragraph' works differently depending on whether Emacs is run in batch mode or not Reply-To: bug#59201 <59201@debbugs.gnu.org> Date: Thu, 19 Jun 2025 23:23:35 +0000 retitle 59201 `fill-paragraph' works differently depending on whether Emacs= is run in batch mode or not reassign 59201 emacs submitter 59201 Paul Pogonyshev severity 59201 normal tag 59201 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 11 14:40:45 2022 Received: (at submit) by debbugs.gnu.org; 11 Nov 2022 19:40:45 +0000 Received: from localhost ([127.0.0.1]:46783 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otZtN-0008MP-AZ for submit@debbugs.gnu.org; Fri, 11 Nov 2022 14:40:45 -0500 Received: from lists.gnu.org ([209.51.188.17]:52388) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otZtL-0008MH-2n for submit@debbugs.gnu.org; Fri, 11 Nov 2022 14:40:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otZtK-0003A3-Az for bug-gnu-emacs@gnu.org; Fri, 11 Nov 2022 14:40:42 -0500 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otZtI-0005Rs-Nt for bug-gnu-emacs@gnu.org; Fri, 11 Nov 2022 14:40:42 -0500 Received: by mail-ej1-x630.google.com with SMTP id f27so14929516eje.1 for ; Fri, 11 Nov 2022 11:40:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=xJfnbwqJod1GHdNAo2Pfl1EJGhiPZR0NoW7XsjsOMYI=; b=iIDLLuLIdq1obqRq6lMaCzTDv53iaSyW0i5g3OZHzRaa5tQ2+z7MduDG38RzuFqntx AwsNvOvLg7cutPfV9si1Oa1KFfd3vZiWb+kvmkPBNvqWcOGP+gf/TVd5g932EMie3zbd Lwy2VOJ2tPvYF/7/bwxTsHvSRjA6XY+i2GYQD8YhO7gyvoPcvMHcAOYxB/Un5XYzTg6s 2pAuiu4q6wAOzu1sKxNkDlN5mSSuNRGIskFwC8q8dghZuhzqNs+2RESgiC1TcoAxhprM LPlQLaqmPri1bbs88Stv+LNhNJk/pz6yJ5Kz+qZtRNhKi0jhdqv6QQtpdukB0p3nb2/+ rebg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=xJfnbwqJod1GHdNAo2Pfl1EJGhiPZR0NoW7XsjsOMYI=; b=xzjrbWiQ2hvgnRFVpibizsKGp43aycpgMHsIRWBf9Xyba6+s05CRadEI463AyA2KUv mld6iZelwpc2N0gKpsJN0o9JrzplmRDpg7Z7I2/muwXmygO4soOV8d/LnolxqLuu416M 5FQc8yr44v2dFo6r6tbAEUa6WCL/EXrlvgqLLL2SAVzg3qqgI7OT6UTT/ROob8IvQOEH 4kbzV2YZ184GCQKzgy+k2IaqmYPFHDet9Zvt5/9q7YrBURph5KsfuWeQqmbYHxBV1lBL pc0KickkCZ6xs3IzA6uQ9Mit20Bke1JPEKrslqHYKFf3UBvEzW1wEv3Uyk7jQu9zBx0F pQQg== X-Gm-Message-State: ANoB5pkuijtIDvG5jYSmODVqwLezWcmYxuuMGQKrPWHpDfIufSG4SN89 8NcJFybNuLAGaVRar36OKvkEGegZuS6o9D8ZHVN0Twba7g== X-Google-Smtp-Source: AA0mqf6BWskWa5xziXVlCSU5WottFbKWJxeXNFmPG8OWKuaszyhFi/NR4R+SJUnPQ+VpY5KxmyYOBOQ3bK46C7xz04c= X-Received: by 2002:a17:906:170c:b0:78d:3e56:52c with SMTP id c12-20020a170906170c00b0078d3e56052cmr2931348eje.732.1668195636875; Fri, 11 Nov 2022 11:40:36 -0800 (PST) MIME-Version: 1.0 From: Paul Pogonyshev Date: Fri, 11 Nov 2022 20:40:25 +0100 Message-ID: Subject: `fill-paragraph' works differently depending on whether Emacs is run in batch mode or not To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary="0000000000005a157605ed371050" Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=pogonyshev@gmail.com; helo=mail-ej1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --0000000000005a157605ed371050 Content-Type: text/plain; charset="UTF-8" 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 --0000000000005a157605ed371050 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Tested with Emacs 28 and a recent Emacs 29 build.

To reproduce:

=C2=A0 =C2=A0 $ emacs --b= atch --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 ni= l t) (buffer-string)) 'external-debugging-output)"
<= br>
Prints the text in one line, i.e. `fill-paragraph' appear= s to have done nothing.

If you replace `--batch= 9; in the command line with `-Q' without changing anything=C2=A0= else:

=C2=A0 =C2=A0 $ emacs -Q --eval "(= princ (with-temp-buffer (insert \"Lorem ipsum dolor sit amet, consecte= tur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore m= agna 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-parag= raph' does its work.

In both cases the code is= exactly the same and the function is called non-interactively. The only di= fference, as far as I see, is the batch mode.

Paul=
--0000000000005a157605ed371050-- From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 12 06:17:12 2022 Received: (at 59201) by debbugs.gnu.org; 12 Nov 2022 11:17:12 +0000 Received: from localhost ([127.0.0.1]:47399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otoVc-0008Ly-0d for submit@debbugs.gnu.org; Sat, 12 Nov 2022 06:17:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60196) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otoVW-0008LK-DE; Sat, 12 Nov 2022 06:17:10 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otoVQ-0002YX-HL; Sat, 12 Nov 2022 06:17:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=rF9K21WzflKuhHTEMQ1zH+lwdm42AsD+dK/XgmZY0bs=; b=MyZcNfVhBKVWci4S07a2 Kg3sBWwRxUHGYc6gql4zSE+9zFXv7EJi+32a9gDF72SLMya06pMnU9l/IlL+Pk+FsR3FeKuVwt5l4 k36TTVBwW4W4DxN2IijUMzPmzt8yKCheQ4gfGU7au2CDQL336AbOFHjdIVcJIjpybp+qLCpJ5Xcgg z4pNF7cuIodcSYDlG/NkPtjLTADd5dlrWKjKyC/F9+6HONH8FPsNmTZLUWoKewgMaO82zo+NO/28o fes16+qNJee5XzSbNrTnlJTO2pGDNQ0moe8/xBmDWTeR9JuR1mj7qyGiG6A1BH+/ldcU+h+jhe5rc IJMzOlgfyG1+DQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otoVP-00057T-NF; Sat, 12 Nov 2022 06:17:00 -0500 Date: Sat, 12 Nov 2022 13:17:05 +0200 Message-Id: <83cz9so21a.fsf@gnu.org> From: Eli Zaretskii To: Paul Pogonyshev In-Reply-To: (message from Paul Pogonyshev on Fri, 11 Nov 2022 20:40:25 +0100) Subject: Re: bug#59201: `fill-paragraph' works differently depending on whether Emacs is run in batch mode or not References: MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59201 Cc: 59201@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) tags 59201 notabug thanks > From: Paul Pogonyshev > 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)" From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 12 06:26:33 2022 Received: (at 59201) by debbugs.gnu.org; 12 Nov 2022 11:26:34 +0000 Received: from localhost ([127.0.0.1]:47412 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otoef-0000IE-DL for submit@debbugs.gnu.org; Sat, 12 Nov 2022 06:26:33 -0500 Received: from mail-ed1-f51.google.com ([209.85.208.51]:42851) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otoec-0000I0-FW for 59201@debbugs.gnu.org; Sat, 12 Nov 2022 06:26:31 -0500 Received: by mail-ed1-f51.google.com with SMTP id z18so10899503edb.9 for <59201@debbugs.gnu.org>; Sat, 12 Nov 2022 03:26:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=lvvVIEi5+8qDBZT3Kpd28Vk7dWVX3sZzEffZMXEHrrk=; b=SlX+MnIDgk5/81ffyixz4YSXqIJopj8EqmFhrD4EBuhfwaUVS541I8hLP+p6Iy1HmZ FEpLCWxxxncK9dozo6AsydJREFppHGDjIQ4lxPteaWW13Bl3ELDmAqwjzqjcYJgOWh8+ z1kQBx+wndl5vAdLDoGFx6k2Qx+JHMSZS9rJL3vVqbi3QWDaM9yNsVaay/ZnaAu9Gdns k2eI3d0Zn1cCTdZVNedbU7SkLUNGm+uuJFQ0ZGuyf3736c7iXUb/yAMo2U0qSuEP8Fwh 84y4wDs9zLAtiEa1sBhVN63IIWa2t5ZgR/wQaKEy/rMWCHTop6dBL92SdsHpbNF9VWwI SVug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lvvVIEi5+8qDBZT3Kpd28Vk7dWVX3sZzEffZMXEHrrk=; b=Sndj05mvY/vWAmgyY3v2N+Sq8BLLifn5dxQh6di0PwQamOQmlfAenjB8JjrBwsSzOU Y+FCDcz2/XYPdNq5algMl/wXRRYDwMJjQsQwmT5ls3Anxmv48AWHz/yn56LNy5hMCAN6 M+zN/WN6/dOxyBc1SYbX+mZnEYCVCtHiciq3WbCHowqlwrFdlE1kKFLa+YC3neV1dyGI he9b9HY6Y1j05feeFXIzimhp2GXUHF+/uaYMj6ai2fRsNx7eB0v0QK6kdaPA108yspQl 0tMpugDsvNL93p11rQ3jopfiPfLU+0LRFjkBAbvuKVP6bPtyGmjp9feL4tQFR6Lt8QZX 8Hyg== X-Gm-Message-State: ANoB5pl744ls4euWP1Iwvrwu2z9dPBObN81RfUBBXrnIjFL2DJxMJ2/8 8tIKmzr919BAXBJQv4zBSNHUOFszY9DryK1zvg== X-Google-Smtp-Source: AA0mqf7+QZ5R9CGK14gbrEj2p/3UrQBZGPPyB3ePs0XcqhdcQjaDE6gEc3z/FWyB3nrVQ/ZknwIYd3z45Epk00Udw8Q= X-Received: by 2002:aa7:dc1a:0:b0:461:8a43:e93 with SMTP id b26-20020aa7dc1a000000b004618a430e93mr4805974edu.275.1668252384566; Sat, 12 Nov 2022 03:26:24 -0800 (PST) MIME-Version: 1.0 References: <83cz9so21a.fsf@gnu.org> In-Reply-To: <83cz9so21a.fsf@gnu.org> From: Paul Pogonyshev Date: Sat, 12 Nov 2022 12:26:12 +0100 Message-ID: Subject: Re: bug#59201: `fill-paragraph' works differently depending on whether Emacs is run in batch mode or not To: Eli Zaretskii Content-Type: multipart/alternative; boundary="000000000000c7245205ed444611" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59201 Cc: 59201@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --000000000000c7245205ed444611 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks, please close this then. Paul On Sat, 12 Nov 2022 at 12:17, Eli Zaretskii wrote: > tags 59201 notabug > thanks > > > From: Paul Pogonyshev > > 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 =E2=80=98fill-region=E2=80=99 to fill each of the paragraphs in th= e 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)" > --000000000000c7245205ed444611 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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
>
>=C2=A0 =C2=A0 =C2=A0$ emacs --batch --eval "(princ (with-temp-buff= er (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:
>
>=C2=A0 =C2=A0 =C2=A0$ emacs -Q --eval "(princ (with-temp-buffer (i= nsert \"Lorem ipsum dolor sit amet, consectetur adipiscing
> elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqu= a...\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-p= aragraph' 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<= br> inserted text.=C2=A0 Thus, point is left at EOB, where there's no parag= raph
that fill-paragraph can work on.=C2=A0 The doc string of fill-paragraph
says:

=C2=A0 Fill paragraph at or after point.
=C2=A0 [...]
=C2=A0 The REGION argument is non-nil if called interactively; in that
=C2=A0 case, if Transient Mark mode is enabled and the mark is active,
=C2=A0 call =E2=80=98fill-region=E2=80=99 to fill each of the paragraphs in= the active
=C2=A0 region, instead of just filling the current paragraph.

If you modify the program as follows:

=C2=A0 $ emacs --batch --eval "(princ (with-temp-buffer (insert \"= ;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod te= mpor incididunt ut labore et dolore magna aliqua...\n\") (goto-char (p= oint-min)) (set-mark 1) (fill-paragraph nil t) (buffer-string)) 'extern= al-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:

=C2=A0 $ emacs --batch --eval "(princ (with-temp-buffer (insert \"= ;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod te= mpor incididunt ut labore et dolore magna aliqua...\n\") (transient-ma= rk-mode 1) (set-mark 1) (fill-paragraph nil t) (buffer-string)) 'extern= al-debugging-output)"
--000000000000c7245205ed444611-- From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 12 06:33:57 2022 Received: (at 59201-done) by debbugs.gnu.org; 12 Nov 2022 11:33:57 +0000 Received: from localhost ([127.0.0.1]:47417 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otolp-0002gd-Hv for submit@debbugs.gnu.org; Sat, 12 Nov 2022 06:33:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56210) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1otoln-0002gP-Q5 for 59201-done@debbugs.gnu.org; Sat, 12 Nov 2022 06:33:56 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otoli-0006sk-G0; Sat, 12 Nov 2022 06:33:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Yo/lM2JzI7bZl4ZYY0tkpkKsje/n985qgeemrKyrVmk=; b=YmM87FTGqOo2 yQI8rUXuXYW+mFrQ20vDmC52lhTHuGyZ9jnpxDd+cSJW0rHjn3uzqgEymLHEIFalacNzYc+XjuffE 0b7txIzalS1K1MVcFVbGkpE9vIPUFFqBVmrSOAyA/dqtSBfJ9xSiJRuzZEKNLYpDVYGJHwJnKMgMv Uu1QKcXNo47XyQOjEpvxC6p0IpI10EbW/BSpW9+472bSg5g1/w65EobMcLWTSHYeo9XBWiCMRz4pm /rODQiomIXvB+KUKG+2zkcdedlpG+f5VeOmgdkSdvZ+BE7VhY0KGJDA/y3sRw4nv4behN/K4fLbO0 uRIluJqdx/nZDmeXIRmWqw==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otolf-0006C6-Kx; Sat, 12 Nov 2022 06:33:49 -0500 Date: Sat, 12 Nov 2022 13:33:53 +0200 Message-Id: <838rkgo19a.fsf@gnu.org> From: Eli Zaretskii To: Paul Pogonyshev In-Reply-To: (message from Paul Pogonyshev on Sat, 12 Nov 2022 12:26:12 +0100) Subject: Re: bug#59201: `fill-paragraph' works differently depending on whether Emacs is run in batch mode or not References: <83cz9so21a.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59201-done Cc: 59201-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Paul Pogonyshev > Date: Sat, 12 Nov 2022 12:26:12 +0100 > Cc: 59201@debbugs.gnu.org > > Thanks, please close this then. Done. From unknown Thu Jun 19 16:23:35 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 10 Dec 2022 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator