emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "David Lukeš" <dafydd.lukes@gmail.com>
To: Timothy <tecosaur@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: org-indent-indentation-per-level may be broken
Date: Tue, 31 Aug 2021 17:24:22 +0200	[thread overview]
Message-ID: <CAEPTPEy7izC9iPk=TihwX=1Y0aQb9_qBCRhXLH-3HV1W=q5i=Q@mail.gmail.com> (raw)
In-Reply-To: <87lf4hoh5c.fsf@gmail.com>

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:


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."


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

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.



  reply	other threads:[~2021-08-31 15:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11  8:48 org-indent-indentation-per-level may be broken David Lukeš
2021-08-11 10:31 ` David Lukeš
2021-08-31 13:49   ` Timothy
2021-08-31 15:24     ` David Lukeš [this message]
2021-08-31 15:30       ` Timothy
2021-08-31 22:50         ` David Lukeš

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:

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to='CAEPTPEy7izC9iPk=TihwX=1Y0aQb9_qBCRhXLH-3HV1W=q5i=Q@mail.gmail.com' \
    --to=dafydd.lukes@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=tecosaur@gmail.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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 read-only IMAP folder(s) and NNTP newsgroup(s).