emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-indent: Allow indentation per level to be 0
@ 2021-08-31 23:06 David Lukes
  2021-09-25 14:41 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: David Lukes @ 2021-08-31 23:06 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: David Lukes

* 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



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] org-indent: Allow indentation per level to be 0
  2021-08-31 23:06 [PATCH] org-indent: Allow indentation per level to be 0 David Lukes
@ 2021-09-25 14:41 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2021-09-25 14:41 UTC (permalink / raw)
  To: David Lukes; +Cc: emacs-orgmode

Hi David,

David Lukes <dafydd.lukes@gmail.com> writes:

> * 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).

Applied in main, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-25 14:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31 23:06 [PATCH] org-indent: Allow indentation per level to be 0 David Lukes
2021-09-25 14:41 ` Bastien

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).