From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id iPuuIrJv02BxkgAAgWs5BA (envelope-from ) for ; Wed, 23 Jun 2021 19:30:26 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id gI93HrJv02D6fAAA1q6Kng (envelope-from ) for ; Wed, 23 Jun 2021 17:30:26 +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 90855214A6 for ; Wed, 23 Jun 2021 19:30:25 +0200 (CEST) Received: from localhost ([::1]:38796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lw6hk-0002yH-4x for larch@yhetil.org; Wed, 23 Jun 2021 13:30:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lw6hE-0002y8-7R for emacs-orgmode@gnu.org; Wed, 23 Jun 2021 13:29:52 -0400 Received: from mout02.posteo.de ([185.67.36.66]:44673) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lw6hA-00086Y-Gx for emacs-orgmode@gnu.org; Wed, 23 Jun 2021 13:29:52 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id D7DF22400FE for ; Wed, 23 Jun 2021 19:29:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.eu; s=2017; t=1624469383; bh=lr4jQibqUgXU7H02xOUN3s0CMXf9KOx2j3f1xGgF4L4=; h=Subject:To:Cc:From:Date:From; b=jXDVkZFrVc4MNn1BgUk6LUSY3nSPpMhG/KJSg/4mySySKtERKWyWdIAjqwEAbVJFw oQwBhMHwP0QPjoCLrMIfdeow1/QDDP07sHIeqdSA7U6HGLNteaLzz1FL/6R81st+x0 X3H3YstUpvxMu25RKgQ5rQQr0ujUgUntLA+rw9BCrczOiWNfxgagxPrJeCyhbispe8 6B3rqRRAEYVR1WwflN3KUjEfrC7eymISw2pQuyxz/lpfpQapdNwfaxUtcXtcTp5slB iNZ/E3MlkweuChPLHHwpMr94+i3JYhjCKDQnKf3t1pS3qwfcfFIPdQ+xnwPfOnVyFm VF8WAeUhsNFMQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4G99Hq0kPpz6tm9; Wed, 23 Jun 2021 19:29:42 +0200 (CEST) Subject: Re: [PATCH] extra space at the end of lines in source To: Greg Minshall References: <2701993.1624421325@apollo2.minshall.org> From: =?UTF-8?Q?S=c3=a9bastien_Miquel?= Message-ID: Date: Wed, 23 Jun 2021 17:29:42 +0000 MIME-Version: 1.0 In-Reply-To: <2701993.1624421325@apollo2.minshall.org> Content-Type: multipart/mixed; boundary="------------E52DDCBDAAD5BF5DF449B558" Content-Language: fr Received-SPF: pass client-ip=185.67.36.66; envelope-from=sebastien.miquel@posteo.eu; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: , Reply-To: sebastien.miquel@posteo.eu Cc: org-mode-email 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=1624469426; h=from:from:sender:sender:reply-to: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=+ZfS0pe8+Lt/rZQ4c6m8+x6ecBHKhSsIPYIHJyok12Q=; b=dZjjb2Q0HWxqG3TiA/jsH6DFDdtjxQFLmwwjD133pmvv1AB/EsQSE6Kpo9t8zVv8u7n+eS G0GTUFk1dBowJNMPRntH36qxoLOKRHEzuz3Zkg224m/6SvOqjtqnJomnQzG4NX7H8UpEX6 Xv/ozWl21tPSuGtoASyCtVIVKo9CMil45V0NlpZrClsR5qmwsVMTglxDSRxHIA6KWR1BIU 0WDULSPVaIZ5CE+vkhP7fhhcbJB+epLSX43BnYShk+0g0C64KFbfdDA4J1tImMNRH24VYW In4+/y+BCgXObVGB1wpHx5IxJxVPG2WNwbU0M3zAU44QdvJmzhAgfYw8YrkQRQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624469426; a=rsa-sha256; cv=none; b=UIxYztNjPgNSwcq85Q6q02TmGMcT+VfhPITh0TsDvj0yWXoloTC3DXfutv20AQEFtc74h1 rnNd+fczeAmol9VOHOZDta6PlXkrou9oZh4OU7JDNoYIn90ZaKumAtTKRZVVt36iyu0tHL d9CucNWPyQG91O9VEDEgheQeYr/Fmq8u43mGHOB1lc0zgxxWwvIHuCE9yVc1fVslFbzzvf WKtsi5hXeF6kAZCJCa4N5kfsgczqnup2GWkzJvY5J7yQI7VkrnSAUC3+dgOvFmauIN1gWL aUCT8T5cRM1mvLvg44b4PIf1TF226AhW4CrXy5TlnjJsf27m7W/o8RtzdSIC1Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.eu header.s=2017 header.b=jXDVkZFr; dmarc=pass (policy=none) header.from=posteo.eu; 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: -3.13 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.eu header.s=2017 header.b=jXDVkZFr; dmarc=pass (policy=none) header.from=posteo.eu; 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: 90855214A6 X-Spam-Score: -3.13 X-Migadu-Scanner: scn0.migadu.com X-TUID: YuokyH8cWm3M This is a multi-part message in MIME format. --------------E52DDCBDAAD5BF5DF449B558 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Greg Minshall writes: > - the next time i open the Org Src buffer, whatever lint-like process is > running for that language may complain about extra spaces at the end > of a line. (does that mean my experience is different from yours, or > at least from your expectation?) If I try your original examples with `emacs -q' I do not get extra whitespace in the org src buffer. Those two spaces in the original org buffer -- that are due to `org-edit-src-content-indentation' -- are removed in the org src buffer. If you do not find it to be the case, then I'm missing something. Anyway, here's a patch that cleans up blank lines, except the current one. It preserves the fix for the original issue. Can you try it out ? Regards, -- Sébastien Miquel --------------E52DDCBDAAD5BF5DF449B558 Content-Type: text/x-patch; charset=UTF-8; name="0001-org-src.el-org-src-contents-for-write-back-Do-not-in.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-org-src.el-org-src-contents-for-write-back-Do-not-in.pa"; filename*1="tch" >From 405c2be7487c564e72a9f01a940f96dc19ff16ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= Date: Wed, 23 Jun 2021 15:25:58 +0200 Subject: [PATCH] org-src.el (org-src--contents-for-write-back): Do not indent blank lines * lisp/org-src.el (org-src--contents-for-write-back): Do not indent blank lines, except for the current line. This was the original behaviour for all blank lines, before `857ae366b3`. --- lisp/org-src.el | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index 79f002e56..faacb53e3 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -443,14 +443,20 @@ Assume point is in the corresponding edit buffer." 0)))) (use-tabs? (and (> org-src--tab-width 0) t)) (source-tab-width org-src--tab-width) - (contents (org-with-wide-buffer (buffer-string))) - (write-back org-src--allow-write-back)) + (contents (org-with-wide-buffer + (let ((eol (progn (end-of-line) (point)))) + (list (buffer-substring (point-min) eol) + (buffer-substring eol (point-max)))))) + (write-back org-src--allow-write-back) + marker) (with-current-buffer write-back-buf ;; Reproduce indentation parameters from source buffer. (setq indent-tabs-mode use-tabs?) (when (> source-tab-width 0) (setq tab-width source-tab-width)) ;; Apply WRITE-BACK function on edit buffer contents. - (insert (org-no-properties contents)) + (insert (org-no-properties (car contents))) + (setq marker (point-marker)) + (insert (org-no-properties (car (cdr contents)))) (goto-char (point-min)) (when (functionp write-back) (save-excursion (funcall write-back))) ;; Add INDENTATION-OFFSET to every line in buffer, @@ -458,10 +464,13 @@ Assume point is in the corresponding edit buffer." (when (> indentation-offset 0) (while (not (eobp)) (skip-chars-forward " \t") - (let ((i (current-column))) - (delete-region (line-beginning-position) (point)) - (indent-to (+ i indentation-offset))) - (forward-line)))))) + (when (or (not (eolp)) ; ignore blank lines + (eq (point) (marker-position marker))) + (let ((i (current-column))) + (delete-region (line-beginning-position) (point)) + (indent-to (+ i indentation-offset)))) + (forward-line))) + (set-marker marker nil)))) (defun org-src--edit-element (datum name &optional initialize write-back contents remote) -- 2.32.0 --------------E52DDCBDAAD5BF5DF449B558--