emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: org-indent-indentation-per-level may be broken


From: David Lukeš
Subject: Re: org-indent-indentation-per-level may be broken
Date: Tue, 31 Aug 2021 17:24:22 +0200

Hi Timothy,

Thanks for getting back to me!

> Is the patch in your original email a good fix for this?

Basically yes, though I've simplified it to this:

--8<--------------------------------------------------------------->8--

diff --git a/lisp/org-indent.el b/lisp/org-indent.el
index ea7ea07..2091083 100644
--- a/lisp/org-indent.el
+++ b/lisp/org-indent.el
@@ -126,6 +126,7 @@ 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))
+  (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)
@@ -150,7 +151,7 @@ useful to make it ever so slightly different."
                (concat (make-string (+ n indentation) ?\s)
                        (and (> n 0)
                             (char-to-string org-indent-boundary-char)))
-               nil 'face 'org-indent)))))
+               nil 'face 'org-indent))))))

 (defsubst org-indent-remove-properties (beg end)
   "Remove indentations between BEG and END."

--8<--------------------------------------------------------------->8--

It turns org-indent--compute-prefixes into a no-op, except for
initializing the various prefix vectors, on the assumption that when
org-indent-indentation-per-level is 0, there should simply be no
prefixes.

Disclaimer: I didn't really try to understand the entire reasoning
behind how the prefixes are computed, why it's done the way it's done,
what are the various edge cases etc. But AFAICS, my patch shouldn't
break anything that was working before: when
org-indent-indentation-per-level is greater than 0, everything runs as
before. And when it's 0, then instead of an error, something reasonable
now happens.

If there are disagreements about the details of what should happen, then
they can probably be discussed after this stopgap patch gets merged. For
instance, maybe there's a feature of Org Mode I don't use and which
should get some special treatment when org-indent-indentation-per-level
is 0. But seeing as no one seems to have been inconvenienced by the fact
that it didn't work at all until now, I'm not expecting much of an
uproar :)

Also, maybe it would still make sense to change (if (<= n 1) 0 ...) to
(max 0 ...), as a more catch-all way to ensure that indentation is
reliably greater than 0 (so that (make-string indentation ?*) doesn't
fail)? It's not needed with the when-condition placed as it is in the
patch above, but maybe just to be on the safe side. Dunno.

Best,

David



reply via email to

[Prev in Thread] Current Thread [Next in Thread]