From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id gEBXKdcW22H2mwAAgWs5BA (envelope-from ) for ; Sun, 09 Jan 2022 18:09:43 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id AET5IdcW22GvQQEAG6o9tA (envelope-from ) for ; Sun, 09 Jan 2022 18:09:43 +0100 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 407763C467 for ; Sun, 9 Jan 2022 18:09:43 +0100 (CET) Received: from localhost ([::1]:52230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bhM-0007FM-Na for larch@yhetil.org; Sun, 09 Jan 2022 12:09:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6bbr-0003ju-K4 for emacs-orgmode@gnu.org; Sun, 09 Jan 2022 12:03:59 -0500 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:46967) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6bbl-0004x5-Fa for emacs-orgmode@gnu.org; Sun, 09 Jan 2022 12:03:55 -0500 Received: (Authenticated sender: me@fabionatali.com) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id ED43B60003 for ; Sun, 9 Jan 2022 17:03:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fabionatali.com; s=gm1; t=1641747829; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+cwJHR60azc5583OFn8q5kbsoTFG9Pdj8ak3zKx7/Uo=; b=H9ecyDNWPYKOJtALTlWhifdBsSkaOyQm4qkFHkNvBg5iS2lhC+Oc6qkZdnPMD7bfUFz8T3 eTK4dHQXamsUm8+81zLv0/Hc0o3oyg2zik7l/3uLuCvi1Owbrl0QGGVYCpbhKSpn/syf8A ALEv+hM//o1v4ci1aeq0rau1LzSQIK2ScM8AXmoIYLX3DNDFjn5shOS6jTBYCIo1NMXx3k KXGpYOdRRXjEy/WcUftxJYqdSXHLEDVaE6SV9OHQH/25Ew1ESYdwkbuL996AnP57zwAKyF F+WyoTfa3NtxNPEoSHGjDc8L2w9nor/ZxMK4/vgv+Q0BbuyKuPVEXRXu3QsIHA== Date: Sun, 9 Jan 2022 17:03:47 +0000 From: Fabio Natali To: emacs-orgmode@gnu.org Subject: `org-fill-paragraph' (`M-q') in Org Mode source blocks Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=217.70.183.195; envelope-from=me@fabionatali.com; helo=relay3-d.mail.gandi.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1641748183; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=+cwJHR60azc5583OFn8q5kbsoTFG9Pdj8ak3zKx7/Uo=; b=KTzbjZuNFV5z7lDsnY0gZkOkqbbWHg/s5/vTV+WBXS31R1nLoQthSBIj4OlekyHEsxB+pe goPzyAKBcsVsjbO35QMCjs37tTSBgImgEDcXETYp9eKkvkx9Pm9sicWCG76fHZ19HSjdlU 969AkEAd18VGuZoZTTSe8KeWSUFl0eFtLZkfZGGtmpM+EoXAuHWobjDzzy9gjTqEWCPzNw xOTQ1dXg7T1cYhqV834HsWCOm6eO9gZf/6mGM3zgWxfFfteRDCjx5HkIhuVAlR0V67ZquC mGuyMfgRBaGUwwylYunSiQmCQLa+CEUa02/SnkjVz/PC4xKlPYLOqpudRm+L2w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1641748183; a=rsa-sha256; cv=none; b=YbCMNrFoj2n7acZvF3AODuKgN07BmJg4tanjAVNdYGpsMwzc1pHM8P4LWsVS0wp+tQSNvj XZASFv+iHHm2KMl5aLRARuXJPVwQ5seAYWjrh5IHmoatSNcUJSwjtpPzQX3aTyfeCP6j0w W0i6YdU102QWKpJnAkGYduohul5oVrDxCnMOBGHarLJPHhNh3nwrhyRQAKDDZTp9MiyGlv mTdpa8XIE6gRzwW82sJslJPshMMubQsY9iDdi3zWO7ekEgOgKUSDWnRpy5Q1s9e7dqtxOd RhrQ7jo10HhYEAitYCitf1ZkCaiVwPblap7Dx5lUQgfdcLt7uYac9csB4suI+w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=fabionatali.com header.s=gm1 header.b=H9ecyDNW; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -8.21 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=fabionatali.com header.s=gm1 header.b=H9ecyDNW; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 407763C467 X-Spam-Score: -8.21 X-Migadu-Scanner: scn0.migadu.com X-TUID: 0hhVbrJd85V8 Hello, I'm having some issues with `M-q' (`org-fill-paragraph') within a Org Mode source block. Consider, for instance, a Org Mode file that contains the following source block. ┌──── │ #+BEGIN_SRC elisp │ ;; A comment │ (+ 2 2) │ #+END_SRC └──── What happens: when calling `M-q' from within the block, the content is handled like generic text and transformed as follows. ┌──── │ #+BEGIN_SRC elisp │ ;; A comment (+ 2 2) │ #+END_SRC └──── What I'd be ideally expecting: the code to be potentially transformed the same way it'd be in Emacs Lisp major mode. What I'm actually expecting: the above might be too much of a high expectation (i.e. for Org Mode to be aware of different `fill-paragraph' mechanisms for different languages). As a second best, I'd be expecting Org Mode to simply ignore my `M-q' command. Here are some further considerations: • Things work as expected when editing the block with the relevant major mode, e.g. Emacs Lisp; I know that this can be easily activated with `org-edit-special' (`C-c ''). • This can be replicated over different languages, i.e. it doesn't seem to be related to Emacs Lisp code in any way. • I was able to reproduce this with a minimal `init.el' that only contains `(org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t)))'. • I've been testing this with GNU Emacs 27.2 and Org Mode 9.5.1. Also, I can see `M-q' is bound to `org-fill-paragraph'. The [source code] for that function says: This function only applies to comment blocks, comments, example blocks and paragraphs. This would seem to confirm my expectation, i.e. that the command shouldn't be doing anything within a source block. Instead, `org-fill-paragraph' seems to be calling `org-fill-element' and then ultimately `fill-paragraph', [here]. This might be a relevant section: ┌──── │ (cl-case (org-element-type element) │ ;; Use major mode filling function is source blocks. │ (src-block (org-babel-do-in-edit-buffer │ (push-mark (point-min)) │ (goto-char (point-max)) │ (setq mark-active t) │ (funcall-interactively #'fill-paragraph justify 'region))) └──── In order to honour its promise of only applying "to comment blocks, comments, example blocks and paragraphs", shouldn't rather the function do nothing in this case? Is there anything obvious that you think I'm missing here? Is anyone able to replicate the above behaviour and, if so, do you also find it slightly problematic? Any thoughts and feedback on the above will be greatly appreciated. :) Thanks, best, F. [source code] [here]