From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#71017: fill-flowed-encode Date: Sat, 29 Jun 2024 22:44:09 -0700 Message-ID: References: <87v83cfaqx.fsf@ellen.idiomdrottning.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21888"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 71017@debbugs.gnu.org To: Sandra Snan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 30 07:46:24 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 1sNnOJ-0005YC-Vo for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 Jun 2024 07:46:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNnO0-000167-Vu; Sun, 30 Jun 2024 01:46:05 -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 1sNnNz-00015u-61 for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 01:46:03 -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 1sNnNy-0005Zn-Ty for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 01:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sNnNy-0006rP-It for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 01:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Jun 2024 05:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71017 X-GNU-PR-Package: emacs Original-Received: via spool by 71017-submit@debbugs.gnu.org id=B71017.171972631819383 (code B ref 71017); Sun, 30 Jun 2024 05:46:02 +0000 Original-Received: (at 71017) by debbugs.gnu.org; 30 Jun 2024 05:45:18 +0000 Original-Received: from localhost ([127.0.0.1]:54536 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sNnNF-00051M-CC for submit@debbugs.gnu.org; Sun, 30 Jun 2024 01:45:18 -0400 Original-Received: from mail-ed1-f48.google.com ([209.85.208.48]:55649) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sNnND-0004e1-FU for 71017@debbugs.gnu.org; Sun, 30 Jun 2024 01:45:16 -0400 Original-Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-57d1d45ba34so2339312a12.3 for <71017@debbugs.gnu.org>; Sat, 29 Jun 2024 22:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719726250; x=1720331050; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:from:to:cc:subject:date :message-id:reply-to; bh=sd6qnd+OyvkN07DJryFTTSAaftrzkwtzuRoPVcN53Ro=; b=kCZsYKxHBFFrllkETckVduA5sSPlPNx3BKIfK5kXkPJCiIY0IyH0aTpPu8T5wIpTLD NEcmpAjZpDNSlg9LX3EJoKEIfJcfOigiKhivU5ev4S8YrYr0P9qI6KiZLFOZR0eu70uo 2p7VcfZIJLr7I+RAlmoULO2HWWpZRvW2I+xM/F9vpsuAIxOUj2ql6AVv0HFczDxJn5Jf eJDthdEcICyOYwmvNZwHV6s7qCIJBQF69+90PTK2em7waAtA/Ee5vSRcBFVsEiXDQbLg ApqQEp+RjfGkRL3Lx9qvyxMRxvpl8qxglePMcAZMwB+gyJ7nqGyq8hN5sLzTz+BqeZnl l73Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719726250; x=1720331050; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=sd6qnd+OyvkN07DJryFTTSAaftrzkwtzuRoPVcN53Ro=; b=RXu+FnCmAZ4OUZG5I2OGavs84UmlpZehDATmnXpPDUKMvDL8xdkZ32QlY7p8nr9ZNc UefxlHyo8f43MKlUrzFP7juZBX09Zdw/OJsb/S/K14tPdVwWXWSRBDfWlQxwLMbInP87 fZikI36Nm+WurJDUugzQpslfg4mTZFwXl1wyqXTKUyEjUV9kQdUZVhjo0f/HB8sGs6lu GXD+cFF93SOYUjZGJoVUYCIWDzlpQtJaq5MCuNqEXTSknzcGOh3Rn3lnyofQViOCusnP /jrvuK68f6s4/f9k6NrvztlgBPXLoiM5ccaG7g4I3q9I1OY5GC7t6JyuK0VDiBsFoOSi Ye3Q== X-Gm-Message-State: AOJu0YxRQQ9XMnOdlI71gCmhbYHqKGAPgcL+7IbPFq0ajIxBNb4t3H7i H3Ch4uBZObBmDcQ5qjYD8qaZw5JjGxWlrE+N4rHifTpTiHdm/fLbMabXG+07UW8aFXZwmA+UXzg Jo0zyMeU3KvHPq+brNNsJyWx9xjUIWo3ZILM= X-Google-Smtp-Source: AGHT+IH5kV9nxgj/jh12zTBY466KRzzldJi78weHBjoAnHo6fj79Z2e61SYkOuHJoV8banEx20J5AcxlMOfBXNJckPI= X-Received: by 2002:a05:6402:37b:b0:57c:c712:a3c7 with SMTP id 4fb4d7f45d1cf-587a10d9892mr1164219a12.36.1719726249827; Sat, 29 Jun 2024 22:44:09 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 29 Jun 2024 22:44:09 -0700 In-Reply-To: <87v83cfaqx.fsf@ellen.idiomdrottning.org> (Sandra Snan's message of "Fri, 17 May 2024 22:23:50 +0200") 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:288154 Archived-At: Sandra Snan writes: > Hi y'all. Hi Sandra, > flow-fill.el.gz has a pair of functions, fill-flowed-encode and > fill-flowed-fill-buffer (the latter is only called from the former). > > Here is a fixed version of the former that then also deprecates the latte= r (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 all unl= ess > there was at least one hard newline EOF. > > Second, the old code borked up code indented with tabs and spaces (iff th= at code > had overly long lines), such as the Lisp code in this email. It could som= etimes > insert extra in the middle of such 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 ut labore= et > dolore magna aliqua)) > (ut enim ad minim veniam > (quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea com= modo > 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)))) > > 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 have ext= ra > whitespace in the mkddle of lines. Could you please resend the above as patches formatted by git format-patch -1 ? It will make it easier for us to review and install the proposed changes. Thanks in advance.