From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id SG78H7F6L2GUiAAAgWs5BA (envelope-from ) for ; Wed, 01 Sep 2021 15:05:53 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id kKOhG7F6L2EUTwAAB5/wlQ (envelope-from ) for ; Wed, 01 Sep 2021 13:05:53 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C7E341043A for ; Wed, 1 Sep 2021 15:05:52 +0200 (CEST) Received: from localhost ([::1]:55244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLPw7-00037B-Mg for larch@yhetil.org; Wed, 01 Sep 2021 09:05:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLPq9-0006Ed-Hq for emacs-orgmode@gnu.org; Wed, 01 Sep 2021 08:59:41 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:40861) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mLPq7-0000jB-UN for emacs-orgmode@gnu.org; Wed, 01 Sep 2021 08:59:41 -0400 Received: by mail-pf1-x42d.google.com with SMTP id r13so1976406pff.7 for ; Wed, 01 Sep 2021 05:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=6d52au+pPMj3899Do3N+3eHH1Z4fKO1pQASAXZY1Kv8=; b=DzAKlzkcMoYiMtWzHN1lF79OhxWL/XnguHZsTZg6ZT5ipzirw25jl97p5bOdX1MSQZ jX590UjWJ3hZVc4wMg8a65spMa0vu8MilMU7j8GQT/p9M/exfGhPwa92LjrZZ8t+1zdA hFSQbx6CLE20+NMjr+tsWcyPEnf+FpDH+kxqOwtoX5fK7Hnpp4eOEiJ/KX+ommKzoraY jgyV5QaELuWXfK8JAfgGEL3MMp1Udn/OalYZtQefc3b3ldo5Y3d4z0IImuAcyf+d+jaA 5r7P66tSdEStSup9Pc1J2P2HLxu3wiU2ze/p/IqmYww60fKTWtcVZJd4BkiUaVubxTcF igww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=6d52au+pPMj3899Do3N+3eHH1Z4fKO1pQASAXZY1Kv8=; b=q2pZ/vnDQRZ7i1FvYjzVZovPeSS9XTWJufJOw4YEWZ3Obl9rZt8p6AfxN8ZwyaD4x6 /4vfwxh3bukBPo4u4se3okjHyZJA5J6EhXNRzSjaSpWXVs6paJt1m51kr6knnjBU3Xp6 XdUm1egn1ZOEK49JBVoW0SfqrkMPVHJmLLIvT3sh9fzMjhfdVmI/eWeQhytmKHLMSgQl 1FcixuHpx2m93vrYd6Ub3d0T9FCx4cQprfeQXdgPvh2U1igzh+TN5pJLAFE/xCgAXaQv Zi9i7MJCWu1jef6Loy98BrGIT4pLqR9mJT4c+5Qt5jxBn7D/IRmyZgknPtqlBV06250M S+xQ== X-Gm-Message-State: AOAM532j990hVN+AWSHHwC6h4jRdJbSzblC0hOlXDtPX9VipL+rI/P2+ SGl/f8EFS6vTzGSD3wlzb3o= X-Google-Smtp-Source: ABdhPJzcRhjjv9t1zs4fnka8oGmOxPFpeu0qEFPiwD+zCEn+XiFMh3k6mWXjwSldkQ7hdT5PjSK6Ng== X-Received: by 2002:a63:1b53:: with SMTP id b19mr31989264pgm.160.1630501177880; Wed, 01 Sep 2021 05:59:37 -0700 (PDT) Received: from localhost ([60.249.92.70]) by smtp.gmail.com with ESMTPSA id f137sm21045173pfa.160.2021.09.01.05.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 05:59:36 -0700 (PDT) From: Ihor Radchenko To: Timothy Subject: [PATCH] Re: Bug: `org-fill-paragraph' relies on M-q being bound to `fill-paragraph' [9.4.6 (9.4.6-12-gdcc3a8-elpa @ /home/mwj/.emacs.d/elpa/org-20210809/)] In-Reply-To: <87o89doi2m.fsf@gmail.com> References: <87o89doi2m.fsf@gmail.com> Date: Wed, 01 Sep 2021 21:00:33 +0800 Message-ID: <87r1e8xxfy.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=yantar92@gmail.com; helo=mail-pf1-x42d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=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-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org, "Marvin J." Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1630501552; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=6d52au+pPMj3899Do3N+3eHH1Z4fKO1pQASAXZY1Kv8=; b=WMDK9BUwPHprQqrl/L49SYpb9+lQhyooXXmPvP9/OAyrgv5UrnOVkoM1SxO0DYsZvfFaJg 80HG2zchAfFclGpRI6TK9p52e8nqZH+KdwO2uoGSto5sLiClpa/Pvoej51/ivvy5E9psLP 3wwmMuw7WS3BYCLsVl4U53OAs4qwbM7nmVe7XjI+eGXocKojN+two5VqPWJw+kJwz2Ht0f 1USf2GD2G6xi0dh2DdjvlcXJzAVqDw3JXECcreJthPCMcFAnJZ+dmdIt+tSZA000pOA2B6 h64ipz4ES2rzJeRbPeh6J9DMvAgKsDoirdVaCLRdcHdmaZIH8zI04FxwTR02UA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630501552; a=rsa-sha256; cv=none; b=EP7xD35iHiEe042LCZkfq3cXHurJr+th/RUp0j9/vgsjeeS1oS6dpzGwS7D0RDzRzic6vg 3fJ5Fxr3XakC+bIbXtiQ0D/Q25R8SsxQyB4GIiAHUT26YdAY0c4AoWMe0Z6GXyil2zyPgt 0XsYILnlRZYb+dYhOVJX9tsGhYqJRuVZDZrI/VR2NX5Na/p9H6ikOeWYT+GoE4BlkVVi2m HML/ussiSlZA7Ttzbo0x76lxNMvpnQQ8uVfP0PNwlOztlgHmv83s8NGQxJ89bW/N3eNh3H X0wYb/gJy852pV9yPMNTpUdH10PBbtydEDislddcpVt8LdZtalXrQC0Hutz2SQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=DzAKlzkc; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -0.82 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=DzAKlzkc; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: C7E341043A X-Spam-Score: -0.82 X-Migadu-Scanner: scn1.migadu.com X-TUID: HG6APxVAVlRQ --=-=-= Content-Type: text/plain Timothy writes: > With regards to triggering M-q in the edit buffer, > considering that different modes can have different fill commands, might > you have any suggestions on what command this could be replaced by? I think simply calling `fill-paragraph' (bound to "M-q" by default) should do. From it's docstring, it should take care about mode-specific fill functions: >> If fill-paragraph-function is non-nil, we call it (passing our >> argument to it), and if it returns non-nil, we simply return its value. Also, the docstring says that fill-paragraph-function is expected to return non-nil when the filling is done there. For some reason, it is not done in org-fill-paragraph. The attached is patch solving the "M-q" problem and making sure the org-fill-paragraph returns non-nil. Beware that I am not very familiar with fill.el. It would be great if someone more knowledgeable take a look at the patch. Best, Ihor --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Do-not-rely-on-M-q-binding-for-filling-src-block.patch >From 2ff317ece235890da5e1f8246dba08d585b0fbaa Mon Sep 17 00:00:00 2001 Message-Id: <2ff317ece235890da5e1f8246dba08d585b0fbaa.1630500712.git.yantar92@gmail.com> From: Ihor Radchenko Date: Wed, 1 Sep 2021 20:42:05 +0800 Subject: [PATCH] Do not rely on M-q binding for filling src-block * lisp/org.el (org-fill-element): Use `fill-paragraph' instead of simulating "M-q" binding. (org-fill-paragraph): Return t as described in `fill-paragraph' docstring. Fixes https://orgmode.org/list/CAH7LOt0PO3js6_+Cbinm6EYNx0KFvpfiSS7Dwc1EXsfHfHkHVA@mail.gmail.com/ --- lisp/org.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index ce68f4692..601526e84 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -19486,7 +19486,9 @@ (defun org-fill-element (&optional justify) ;; the buffer. In that case, ignore filling. (cl-case (org-element-type element) ;; Use major mode filling function is source blocks. - (src-block (org-babel-do-key-sequence-in-edit-buffer (kbd "M-q"))) + (src-block (org-babel-do-in-edit-buffer + (mark-whole-buffer) + (funcall-interactively #'fill-paragraph justify 'region))) ;; Align Org tables, leave table.el tables as-is. (table-row (org-table-align) t) (table @@ -19621,7 +19623,9 @@ (defun org-fill-paragraph (&optional justify region) ;; previously unmodified), then flip the modification status back ;; to "unchanged". (when (and hash (equal hash (org-buffer-hash))) - (set-buffer-modified-p nil)))) + (set-buffer-modified-p nil)) + ;; Return non-nil. + t)) (defun org-auto-fill-function () "Auto-fill function." -- 2.31.1 --=-=-=--