From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 2HmIIOj7m2RumwAASxT56A (envelope-from ) for ; Wed, 28 Jun 2023 11:22:48 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id IJ2VIOj7m2RCzQAA9RJhRA (envelope-from ) for ; Wed, 28 Jun 2023 11:22:48 +0200 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 10BB5FC30 for ; Wed, 28 Jun 2023 11:22:47 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qERNF-0004JK-7K; Wed, 28 Jun 2023 05:22:05 -0400 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 1qERMv-0004An-KK for emacs-orgmode@gnu.org; Wed, 28 Jun 2023 05:21:48 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qERMn-0000Zf-KM for emacs-orgmode@gnu.org; Wed, 28 Jun 2023 05:21:40 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 474F9240027 for ; Wed, 28 Jun 2023 11:21:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1687944095; bh=VxcurIgxZw77csyehoTNh8fcrKkj93IKRM3f31Pk8GI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=dm9KYc9kmYmQhLFkSjtNBnNMD2vnPSaNJR7UI7gxtvzhCTG+76nP6nPSmOOa2zsJh HLjMeiHKtvnNdURhwbEdT9jOSTh2j/FZOR+UBeqAryL1so316VAJ+svcQiAhfLkNks pGeeL12nYNGnJbbtBKDhlYvKLoMHMraQNZHY2hts5MQsMWZY/XROmp07HoHqf0befL 78uAvoQoXvZkCP9QFNxYsoaQArhJ8P4m1ZgkYQ4BEtm3HN5Bkm/5Hqtg45bjsTzg5y xdrA/6XT7nMOF1iBujPipzUraUe+/UewW3fFyrSORT2HsJNp2U2k5DnTNlbqTIQmkJ bGP9oldH8n8bw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QrbgL1lGPz9rxF; Wed, 28 Jun 2023 11:21:34 +0200 (CEST) From: Ihor Radchenko To: sebastien.miquel@posteo.eu Cc: wolf , emacs-orgmode@gnu.org Subject: Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)] In-Reply-To: References: <87ttva8chx.fsf@localhost> <8d8642c9-ced3-b254-0f49-f7b9c06311ff@posteo.eu> <87352p9g13.fsf@localhost> <87zg4vsof6.fsf@localhost> <37d86bbf-c0e2-6337-efc2-cdf63dbf4580@posteo.eu> <87sfamsb7m.fsf@localhost> <274bbd61-790d-8e19-d3a0-0793126c3bb0@posteo.eu> <87cz1itp8k.fsf@localhost> <1a97917c-bbab-4d7f-b629-0c84807448f2@posteo.eu> <87a5wmtmug.fsf@localhost> Date: Wed, 28 Jun 2023 09:21:28 +0000 Message-ID: <87o7l0vt5z.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1687944168; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=iHF2WZafD2UXE3GpQ1DXhOa1YDMQnwFNPToLDZXUwqo=; b=NHdxJtiz/v1rlzthq+Yl8c1eNhS1sloetFExXFhEs6mIL8jrbGvZ93jHgKEVF+kqkL4ZLa rB2Pu6n8b2WK1sCOyC4nOW70Tid/zpObcEgEmjzKVjBDVP8yBfeXcm/njQ3eFzOIhMWHRq UcFwmUnA2iwCOZMZUwN+mVG1JHJd2U9FpJJZuPpSG6ipXoday05TcVxnjV/X066fnh14fy Ae1FFzRIddDw2InKnptGFk01jLeCNEhAfzH0BeY+ufPv8F2Y4lF9XiutP54zLCDvjwx0aH yEYHw2ZoOO+SeerpjgQKS7b9M3GQ57wpyhM77YaFmhU3whI38dGljxuPN9LDTQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=dm9KYc9k; dmarc=pass (policy=none) header.from=posteo.net; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1687944168; a=rsa-sha256; cv=none; b=u6gQJqs4mW5L/ALXRqm0Fvc8eXgQl4kgADFmwcqwEPBucJsVt77qB843bL1vAuNeGpU4vZ WO7JdasFy4NLvZKgaZvOgTvCzqQbRvoGzeYadxkpKShrRw5ThN7CT2+muEuU6fIVKz+8jl M9Wq/IIgZNwnl37/iVI6Nr1b0CKXHBsqxoLXe/su3zF4aqilcU5R17AKqP+fDt1UQsZz82 4kUHfj0VOy1wtpDUyPy7Bx6tnLHhhTXwGEXi99fxDxciOGixVeTT029QOW98iEZSBD2jzM jBbrBMlu7qGcPgze/T19PN61aIa21iK+S2rXL32ihkAq7oKwkrguVM4jiCIprA== X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -4.72 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=dm9KYc9k; dmarc=pass (policy=none) header.from=posteo.net; 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: 10BB5FC30 X-Spam-Score: -4.72 X-TUID: 4zUNNcKwumO/ S=C3=A9bastien Miquel writes: > Here are two patches, the first that removes the special case logic > for LaTeX fragments, and the second that implements what you suggest, > and applies on top of the first one. Does that look ok to you ? Thanks! > + ;; Apply WRITE-BACK function on edit buffer contents. > + (goto-char (point-min)) > + (when (functionp write-back) (save-excursion (funcall write-back))) > (set-marker marker nil)))) `save-excursion' is no longer necessary here. > (defun org-src--edit-element > @@ -1150,7 +1149,14 @@ Throw an error when not at such a table." > (lambda () > ;; Blank lines break things, replace with a single newline. > (while (re-search-forward "\n[ \t]*\n" nil t) (replace-match "\n")) > - ;; If within a table a newline would disrupt the structure, > + ;; Trim contents. It would be nice to have a bit more context about the purpose in the comment here. > Subject: [PATCH] org-src.el: Use native value of `indent-tabs-mode' for > indentation > > * lisp/org-src.el (org-src--contents-for-write-back): Preserve the > native indentation (spaces vs tabs). If necessary, add a common org > indentation to the block according to org's `indent-tabs-mode'. > (org-src-font-lock-fontify-block): In case of mixed indentation, > display the tab characters with a fixed width, according to the native > tab width value. > * testing/lisp/test-org-src.el (test-org-src/indented-blocks): Update > tests. Indentation no longer obeys `indent-tabs-mode' from the org > buffer, but is separated in two parts. > diff --git a/lisp/org-src.el b/lisp/org-src.el > index 5c272c7f5..5a1030c42 100644 > --- a/lisp/org-src.el > +++ b/lisp/org-src.el > ... > - (skip-chars-forward " \t") > - (when (or (not (eolp)) ; not a b= lank line > - (and (eq (point) (marker-position marker)) ; current= line > + (when (or (not (eolp)) ; not an empty line > + ;; If the current line is empty, we may > + ;; want to indent it. > + (and (eq (point) (marker-position marker)) > preserve-blank-line)) Do we still need this dance with special case for current line? > + ;; Display tab indentation characters preceded by spaces as spaces > + (unless org-src-preserve-indentation unless? Don't we rather want to preserve the original indentation alignment when `org-src-preserve-indentation' is t? > + (save-excursion > + (goto-char start) > + (while (re-search-forward "^[ ]+\\([\t]+\\)" end t) Why just tabs at indentation? It would make sense to preserve width of all the tabs. > + (let* ((b (match-beginning 1)) > + (e (match-end 1)) > + (s (make-string (* (- e b) native-tab-width) ? ))) > + (add-text-properties b e `(display ,s)))))) Will the actual tab width be always equal to native-tab-width? What about tab stops? May it be more reliable to use different of column numbers in the src mode buffer after/before the tab? > @@ -318,19 +318,21 @@ This is a tab:\t. > argument2)) > #+END_SRC" > (setq-local indent-tabs-mode t) > - (let ((org-edit-src-content-indentation 2) > + (let ((tab-width 8) > + (org-edit-src-content-indentation 2) Why is setting tab-width necessary? 8 is the default value. > #+BEGIN_SRC emacs-lisp > - (progn\n (function argument1\n\t\targument2)) > + (progn\n (function argument1\n \targument2)) I think it would be a bit more readable to convert this string into actual multi-line, where the alignment is visible when reading the test source. --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at