Org-mode mailing list
 help / color / mirror / Atom feed
From: David Lukes <dafydd.lukes@gmail.com>
To: emacs-orgmode@gnu.org
Cc: David Lukes <dafydd.lukes@gmail.com>
Subject: [PATCH] org-indent: Allow indentation per level to be 0
Date: Wed,  1 Sep 2021 01:06:51 +0200
Message-ID: <20210831230651.82962-1-dafydd.lukes@gmail.com> (raw)

* lisp/org-indent.el (org-indent--compute-prefixes): Prefixes should
only be computed when `org-indent-indentation-per-level' is greater than
0.  For one thing, the current algorithm leads to an error otherwise,
and for another, this makes it possible to use org-indent just to
preserve indentation on continuation lines, without adding any
additional indentation per level (by setting the option to 0).

TINYCHANGE
---
 lisp/org-indent.el | 49 +++++++++++++++++++++++-----------------------
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/lisp/org-indent.el b/lisp/org-indent.el
index ea7ea071b..b87cc4e5f 100644
--- a/lisp/org-indent.el
+++ b/lisp/org-indent.el
@@ -126,31 +126,32 @@ useful to make it ever so slightly different."
 	(make-vector org-indent--deepest-level nil))
   (setq org-indent--text-line-prefixes
 	(make-vector org-indent--deepest-level nil))
-  (dotimes (n org-indent--deepest-level)
-    (let ((indentation (if (<= n 1) 0
-			 (* (1- org-indent-indentation-per-level)
-			    (1- n)))))
-      ;; Headlines line prefixes.
-      (let ((heading-prefix (make-string indentation ?*)))
-	(aset org-indent--heading-line-prefixes
+  (when (> org-indent-indentation-per-level 0)
+    (dotimes (n org-indent--deepest-level)
+      (let ((indentation (if (<= n 1) 0
+			   (* (1- org-indent-indentation-per-level)
+			      (1- n)))))
+        ;; Headlines line prefixes.
+        (let ((heading-prefix (make-string indentation ?*)))
+	  (aset org-indent--heading-line-prefixes
+	        n
+	        (org-add-props heading-prefix nil 'face 'org-indent))
+	  ;; Inline tasks line prefixes
+	  (aset org-indent--inlinetask-line-prefixes
+	        n
+	        (cond ((<= n 1) "")
+		      ((bound-and-true-p org-inlinetask-show-first-star)
+		       (concat org-indent-inlinetask-first-star
+			       (substring heading-prefix 1)))
+		      (t (org-add-props heading-prefix nil 'face 'org-indent)))))
+        ;; Text line prefixes.
+        (aset org-indent--text-line-prefixes
 	      n
-	      (org-add-props heading-prefix nil 'face 'org-indent))
-	;; Inline tasks line prefixes
-	(aset org-indent--inlinetask-line-prefixes
-	      n
-	      (cond ((<= n 1) "")
-		    ((bound-and-true-p org-inlinetask-show-first-star)
-		     (concat org-indent-inlinetask-first-star
-			     (substring heading-prefix 1)))
-		    (t (org-add-props heading-prefix nil 'face 'org-indent)))))
-      ;; Text line prefixes.
-      (aset org-indent--text-line-prefixes
-	    n
-	    (org-add-props
-		(concat (make-string (+ n indentation) ?\s)
-			(and (> n 0)
-			     (char-to-string org-indent-boundary-char)))
-		nil 'face 'org-indent)))))
+	      (org-add-props
+	       (concat (make-string (+ n indentation) ?\s)
+		       (and (> n 0)
+			    (char-to-string org-indent-boundary-char)))
+	       nil 'face 'org-indent))))))
 
 (defsubst org-indent-remove-properties (beg end)
   "Remove indentations between BEG and END."
-- 
2.32.0



                 reply	other threads:[~2021-08-31 23:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://orgmode.org

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210831230651.82962-1-dafydd.lukes@gmail.com \
    --to=dafydd.lukes@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git