From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Sandra Snan via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#71017: fill-flowed-encode Date: Fri, 17 May 2024 22:23:50 +0200 Message-ID: <87v83cfaqx.fsf@ellen.idiomdrottning.org> Reply-To: Sandra Snan Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36462"; mail-complaints-to="usenet@ciao.gmane.io" To: 71017@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 17 22:25:15 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s848g-0009HO-NV for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 17 May 2024 22:25:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s848T-0000Ke-50; Fri, 17 May 2024 16:25:01 -0400 Original-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 1s848S-0000KK-3U for bug-gnu-emacs@gnu.org; Fri, 17 May 2024 16:25:00 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s848R-0004sF-Qh for bug-gnu-emacs@gnu.org; Fri, 17 May 2024 16:24:59 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s848U-0000vn-Oi for bug-gnu-emacs@gnu.org; Fri, 17 May 2024 16:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Sandra Snan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 17 May 2024 20:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 71017 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.17159774433558 (code B ref -1); Fri, 17 May 2024 20:25:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 May 2024 20:24:03 +0000 Original-Received: from localhost ([127.0.0.1]:57098 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s847X-0000vK-CP for submit@debbugs.gnu.org; Fri, 17 May 2024 16:24:03 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:55324) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s847V-0000ux-Aw for submit@debbugs.gnu.org; Fri, 17 May 2024 16:24:01 -0400 Original-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 1s847R-0000EU-VQ for bug-gnu-emacs@gnu.org; Fri, 17 May 2024 16:23:57 -0400 Original-Received: from halsen.idiomdrottning.org ([2600:3c02:e000:179::7]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s847Q-0004lQ-4Y for bug-gnu-emacs@gnu.org; Fri, 17 May 2024 16:23:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=idiomdrottning.org; s=idiomdrottningorg; t=1715977433; bh=625oJ9asc1AuPwGhH9RwhVYK9NzLY3xmpBPfbkPpI+E=; h=From:To:Subject:Date:From; b=pg3mNRuaT//9hc8v+j0IwS3ME5IA19lyOTEkm83NIlIjGV32xCHCPT+FeVMIeBdR8 KcdQZCDNsVV34q7AJeDz/Pm9tgw5tivj6JwYY9cxYJxnb4MClAzxDwcARmduB/xD3U Z4f/2Bz0xeCEg0seheu4Kfh8KF3gP1RcNNnLDnPTiV4ElYHMY3fcVXh/DNASVnzSwi CX5UkJEuvtDEefBcFanO46IdQCrt9xCUatrhxIQUCZ2nuRQeEXdo2DItbUPjc08gie eeVfdf3Wj/AYfj0nwH9sq2/C1U3PFlfL5BR0w34A9IkJPSigKH0CkB4qfuPgcjOZib 6PVZa7K0v87cw== Original-Received: from localhost (31-211-247-254.customers.ownit.se [31.211.247.254]) by halsen.idiomdrottning.org (Postfix) with ESMTPSA id 427281FB6B; Fri, 17 May 2024 22:23:52 +0200 (CEST) Autocrypt: addr=sandra.snan@idiomdrottning.org; prefer-encrypt=mutual; keydata= mDMEZWEIEhYJKwYBBAHaRw8BAQdAahVPtpoqkiV62AL3GSY4JaPS0i3Bu3fhbe5WIFQG9pa0LFNh bmRyYSBTbmFuIDxzYW5kcmEuc25hbkBpZGlvbWRyb3R0bmluZy5vcmc+iJMEExYIADsCGwMFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AWIQSM+QwgZjV9IBEt0Difw0TKEvFISgUCZWJbSgIZAQAKCRCf w0TKEvFIShsYAPsFMXn+tFcAwdI2hrkqqQY8I5EC9UWYC9t57VjiYv2uYQD+PUNVHVSBGQDycf3V /nXqXvZvTfcFMOz0PVMzibPl0AiIkAQTFggAOBYhBIz5DCBmNX0gES3QOJ/DRMoS8UhKBQJlYQgS AhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEJ/DRMoS8UhK07EA/iV2B5e3r8t8/StJT38d x9YbuoSBmbYZJ6JHH9hoyv0hAPwMiH1M8zZUeQK/TQDqkg2Hjk0xL+U7i9ggocLJEAWQDbg4BGVh CBISCisGAQQBl1UBBQEBB0BqHjRRmoXeZmeeUZOqL1ebAflzYFA3jHwxl2sLMLlMCgMBCAeIeAQY FggAIBYhBIz5DCBmNX0gES3QOJ/DRMoS8UhKBQJlYQgSAhsMAAoJEJ/DRMoS8UhK4o0BAOB7ChkN Jc0oxRDg9WvrbUCnpLU/QdjMFcC8ymLRdzxaAP4gZVL0JQfxulc/JAxotCevk1PAF+UXpY8QalTI dooaAA== Received-SPF: pass client-ip=2600:3c02:e000:179::7; envelope-from=sandra.snan@idiomdrottning.org; helo=halsen.idiomdrottning.org 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:285264 Archived-At: Hi y'all. flow-fill.el.gz has a pair of functions, fill-flowed-encode and=20 fill-flowed-fill-buffer (the latter is only called from the=20 former). Here is a fixed version of the former that then also deprecates=20 the latter (I have signed FSF copyright papers): (defun fill-flowed-encode (&optional buffer) (with-current-buffer (or buffer (current-buffer)) ;; No point in doing this unless hard newlines is used. (when use-hard-newlines (let ((start (point-min)) end) ;; Go through each paragraph, filling it and adding SPC ;; as the last character on each line. (while (and (< start (point-max)) (setq end (or (text-property-any start (point-max) 'hard 't) (point-max)))) (save-restriction (narrow-to-region start end) (let ((fill-column (eval fill-flowed-encode-column t)) (prefix (concat "\n" (or (and (looking-at ">[> ]*") (match-string 0)) "")))) (while (search-forward prefix nil t) (replace-match " " t t)) (goto-char start) (while (< (+ (point) fill-column) (point-max)) (forward-char fill-column) (search-backward " ") (forward-char) (insert prefix))) (setq start (1+ (point-max)))))) t))) This fixes two bugs when sending RFC 2646=E2=80=93formatted email. First, the old code didn't refill or encode the last paragraph at=20 all unless there was at least one hard newline EOF. Second, the old code borked up code indented with tabs and spaces=20 (iff that code had overly long lines), such as the Lisp code in=20 this email. It could sometimes insert extra in the middle of such=20 long lines. Here is an example of what it would do. It would turn this: (defun lorem (ipsum) (dolor sit amet) (consectetur adipiscing elit (sed do eiusmod tempor incididunt=20 ut labore et dolore magna aliqua)) (ut enim ad minim veniam (quis nostrud exercitation ullamco laboris nisi ut aliquip=20 ex ea commodo consequat (duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur) excepteur sint occaecat cupidatat non proident (sunt in culpa qui officia deserunt mollit anim id est=20 laborumd)))) into this: (defun lorem (ipsum) (dolor sit amet) (consectetur adipiscing elit (sed do eiusmod tempor incididunt ut labore et dolore magna aliqua)) (ut enim ad minim veniam (quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat (duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur) excepteur sint occaecat cupidatat non proident (sunt in culpa qui officia deserunt mollit anim id est laborumd)))) It was breaking lines awkwardly so when they're reconnected they=20 have extra whitespace in the mkddle of lines.=20