From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id UJ4sEhxTMmU8qwAAauVa8A:P1 (envelope-from ) for ; Fri, 20 Oct 2023 12:14:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4789::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id UJ4sEhxTMmU8qwAAauVa8A (envelope-from ) for ; Fri, 20 Oct 2023 12:14:52 +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 BA59D69C40 for ; Fri, 20 Oct 2023 12:14:51 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=WuFBjsPF; 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=1697796892; a=rsa-sha256; cv=none; b=F1/+LOjlFfYNeTusMXrkpkG8T4dY2wiqyEXWsw5Kba8BXx168ZEnRiGqBGxUFBQmCGqcD+ uWO1+5817YTWK8KDXZcVPlYNgIRPpk0ATCFLrkv8WmVftrVU4nq5GxqbJ6f2L6DWurdYRr mJhyz7B9LsgFgYIR1ORTYpr6F4DvR9AZGyzXjQ/SqZUiOjcDC1DttA7iav0SjW7nFvaO4e lE8j+CVgQwD4Pg0ixYH9lVBB4LVdNFeqE79/5B0t4evXUz+ZB2KSsi8X2a1cOEC2pr6z5+ ZRPIrVr2kw8Z0QOKDqhCVGH6TlLHMl9Dm/XsKHst30MEu5ygWAl/AFaRvj+z2w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=WuFBjsPF; 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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1697796892; 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=PETjsW9xrZQxSIOVkI4XvzpdDpNMy3fjREaq2fT72wI=; b=kGLj582RHBEZwuSh97icYhTKrx3dIMtfHI/D279P+jbdOrY2aq/PJzN6FM0g9S8vWxZ1xi 8hkJfw709RpF0iu0jigGdXRWAIXrH0LxJ7VuNVa0/Yy5EvVsm4o3kd/yP7297UOCz6O5HZ c00kT9u5wSRUSVilBQZvbdn8p21P+3orII6j8Ss5WYQA/uGAMR2c+clfOgZ2KJYlx4J1Ib JlYJLOXXzZg3MlG1mGo5RAzFCQQhZW3f0P5oWqaG1LwCtWD9iiicrFBnqH1wDHZ5YeED4f PlCz78Y4LJ4hxgpMaQOwWFtWBW8DdcdLmoobSsv0UYTiTKiV9jWyif7YwlnSHw== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtmW4-0005gT-0f; Fri, 20 Oct 2023 06:14:04 -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 1qtmVx-0005Zu-Ox for emacs-orgmode@gnu.org; Fri, 20 Oct 2023 06:13:58 -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 1qtmVr-0001Cx-FR for emacs-orgmode@gnu.org; Fri, 20 Oct 2023 06:13:57 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 7BCDA240028 for ; Fri, 20 Oct 2023 12:13:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1697796827; bh=ogxugyVXPyC3th/VqgpDpMbiUkEeWCTFwonDO6zQ/BQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=WuFBjsPFjUClYTHNJhbQ5S25gYa2FOv/k6KfwMhXkCeXvLa44q68xN8uYrqQn3U3+ W0OM/715xa+JL4uXVwHprqsrDsoqHbtKehM0HF/LEcvN/WEMpdzFPsXfjmqPhsOah0 5lMTsCb9622BjkxCLkYedSMWMKSG0bIqET0HdyEW/GKOXOwcbD3i4/wxTui6bkTr90 Y5E5OQTsa9AqX6/uk/j6mdj1Rz1EVRs3nOLwJH9hRk1yIlExcfVJfopW8cpTYbZOx2 ih+cG1vNJM8jao/e5QfyuG4Ziw8YKCunkqAcAzprDEUsZsnkO6EffV10ANMi6BS94R XG6ooD4PzNTXg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SBgQz0MjXz6twx; Fri, 20 Oct 2023 12:13:46 +0200 (CEST) From: Ihor Radchenko To: Tom Alexander Cc: emacs-orgmode@gnu.org Subject: [PATCH] [DISCUSSION] Force `tab-width' to be 8 in Org mode (was: COUNTER-SET for alphabetical ordered lists ignored for utf-8 exporter) In-Reply-To: <2c9a6cbd-21c0-45bf-8fbb-4f7eccac4ae7@app.fastmail.com> References: <36a62fbf-6484-456f-9537-a7aa40530068@app.fastmail.com> <87o7hazpxg.fsf@localhost> <2c9a6cbd-21c0-45bf-8fbb-4f7eccac4ae7@app.fastmail.com> Date: Fri, 20 Oct 2023 10:15:31 +0000 Message-ID: <8734y5d2gs.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=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 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 X-Migadu-Scanner: mx1.migadu.com X-Migadu-Spam-Score: -6.36 X-Spam-Score: -6.36 X-Migadu-Queue-Id: BA59D69C40 X-TUID: 7xsilLtXo/BO --=-=-= Content-Type: text/plain "Tom Alexander" writes: > Thanks! > >> We aim to reduce config-dependent Org syntax in the long term. > > Thats wonderful news! Sometimes this stuff can really surprise you. For example, the structure of the document created by running `echo "1. foo\n 1.bar\n 1.baz\n\t1.lorem"` changes based on the user's **tab-width**!! > ... > Absolute madness! I always considered tab-width to be a personal aesthetic choice and not something that would functionally change how documents other people wrote will be parsed. I agree. See the attached tentative patches for Org mode and org-syntax. This is a breaking change, so I encourage people who might be affected reply if they have objections. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-lisp-org.el-org-mode-Force-tab-width-to-be-8.patch >From 423cf9aef588ed93cbc06d6033feaf6bf1a91dfc Mon Sep 17 00:00:00 2001 Message-ID: <423cf9aef588ed93cbc06d6033feaf6bf1a91dfc.1697796750.git.yantar92@posteo.net> From: Ihor Radchenko Date: Fri, 20 Oct 2023 13:10:30 +0300 Subject: [PATCH] * lisp/org.el (org-mode): Force `tab-width' to be 8 * lisp/org-macs.el (org-current-text-column): Assert `tab-width' to be 8 to ensure consistency of the parser across user configurations. * etc/ORG-NEWS (~tab-width~ value is now assumed to be 8): Document the breaking change. This breaking change is made to standardize Org mode format for list items. With variable `tab-width', indentation in lists may depend on user settings leading to inconsistent Org documents when open by different users. Link: https://orgmode.org/list/2c9a6cbd-21c0-45bf-8fbb-4f7eccac4ae7@app.fastmail.com --- etc/ORG-NEWS | 34 ++++++++++++++++++++++++++++++++++ lisp/org-macs.el | 13 ++++++++++--- lisp/org.el | 3 +++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 78b75b578..ea8ebd3af 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -13,6 +13,40 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org. * Version 9.7 (not released yet) ** Important announcements and breaking changes +*** ~tab-width~ value is now assumed to be 8 + +Org mode now assumes tab width to be 8 characters, when calculating +list and other indentation. ~tab-width~ is also set to 8 when Org +major mode is loaded. + +This is done to improve consistency of the markup for lists, where +indentation affects list items. + +Users with non-default values of ~tab-width~ should avoid overriding +the value of 8 set by Org mode. If the custom ~tab-width~ value is +_smaller_ than 8, the existing Org documents can be converted to the +new standard tab width using the following helper command: + +#+begin_src emacs-lisp +(defun org-compat-adjust-tab-width-in-buffer (old-width) + "Adjust visual indentation from `tab-width' equal OLD-WIDTH to 8." + (interactive "nOld `tab-width': ") + (cl-assert (derived-mode-p 'org-mode)) + (unless (= old-width 8) + (org-with-wide-buffer + (goto-char (point-min)) + (let (bound + (repl (if (< old-width 8) + (make-string old-width ?\s) + (concat "\t" (make-string (- old-width 8) ?\s))))) + (while (re-search-forward "^ *\t" nil t) + (skip-chars-forward " \t") + (setq bound (point-marker)) + (forward-line 0) + (while (search-forward "\t" bound t) + (replace-match repl))))))) +#+end_src + *** New export option ~org-export-expand-links~ The new option makes Org expand environment variables in link and INCLUDE paths. diff --git a/lisp/org-macs.el b/lisp/org-macs.el index fd0f508c5..1fd7dd704 100644 --- a/lisp/org-macs.el +++ b/lisp/org-macs.el @@ -1148,9 +1148,16 @@ (defun org-string-width (string &optional pixels) (/ pixel-width symbol-width))))))) (defmacro org-current-text-column () - "Like `current-column' but ignore display properties." - `(string-width (buffer-substring-no-properties - (line-beginning-position) (point)))) + "Like `current-column' but ignore display properties. +Throw an error when `tab-width' is not 8. + +This function forces `tab-width' value because it is used as a part of +the parser, to ensure parser consistency when calculating list +indentation." + `(progn + (cl-assert (= 8 tab-width)) + (string-width (buffer-substring-no-properties + (line-beginning-position) (point))))) (defun org-not-nil (v) "If V not nil, and also not the string \"nil\", then return V. diff --git a/lisp/org.el b/lisp/org.el index bda64bb6c..671dfbe38 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4846,6 +4846,9 @@ (define-derived-mode org-mode outline-mode "Org" \\{org-mode-map}" (setq-local org-mode-loading t) + ;; Force tab width - indentation is significant in lists, so we need + ;; to make sure that it is consistent across configurations. + (setq-local tab-width 8) (org-load-modules-maybe) (when org-agenda-file-menu-enabled (org-install-agenda-files-menu)) -- 2.42.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-syntax.org-Indentation-Clarify-that-tabs-occupy-.patch >From 1ce9ef2f8e475bcb8b9be7367bb30aa0983da6ea Mon Sep 17 00:00:00 2001 Message-ID: <1ce9ef2f8e475bcb8b9be7367bb30aa0983da6ea.1697637104.git.yantar92@posteo.net> From: Ihor Radchenko Date: Wed, 18 Oct 2023 16:51:26 +0300 Subject: [PATCH] * org-syntax.org (Indentation): Clarify that tabs occupy 8 characters --- org-syntax.org | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/org-syntax.org b/org-syntax.org index 9e9b0420..3089ddcf 100644 --- a/org-syntax.org +++ b/org-syntax.org @@ -240,7 +240,9 @@ ** Indentation Indentation consists of a series of space and tab characters at the beginning of a line. Most elements can be indentated, with the exception of [[#Headings][headings]], [[#Inlinetasks][inlinetasks]], [[#Footnote_Definitions][footnote definitions]], and [[#Diary_Sexp][diary -sexps]]. Indentation is only syntactically meaningful in plain lists. +sexps]]. Indentation is only syntactically meaningful in plain lists, +where indentation is calculated assuming that space characters occupy +a single character and tab characters occupy 8 characters. The common indentation of all the lines within an element is discarded. This also applies to single-line elements. -- 2.42.0 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--