Re: Customizable fixed indentation column

2020-05-24 Thread Panagiotis Vlantis

Hi Bastien,

Completely understandable. Thanks for taking the time to consider this 
in the first place. I hope we get to pick this topic up again in the 
near future.


Best regards to all,
Panagiotis


On 5/24/20 1:55 PM, Bastien wrote:

Hi Panagiotis,

thanks for this proposal.

I don't have a strong opinion (yet) on whether we should allow to
indent to a custom column by setting org-adapt-indentation to an
integer.  My gut feeling for now is that this is too much, but I
don't want to dismiss this possibility completely.

That said, the new customization values for org-adapt-indentation
have not yet been released, so I suggest continuing the discussion
for after 9.4 has been released and for after org-adapt-indentation
has been more widely used in its current (from master) state.

Thanks,





Re: Customizable fixed indentation column

2020-05-24 Thread Bastien
Hi Panagiotis,

thanks for this proposal.

I don't have a strong opinion (yet) on whether we should allow to
indent to a custom column by setting org-adapt-indentation to an
integer.  My gut feeling for now is that this is too much, but I 
don't want to dismiss this possibility completely.

That said, the new customization values for org-adapt-indentation
have not yet been released, so I suggest continuing the discussion
for after 9.4 has been released and for after org-adapt-indentation
has been more widely used in its current (from master) state.

Thanks,

-- 
 Bastien



Re: Customizable fixed indentation column

2020-05-17 Thread Panagiotis Vlantis

Hello,

On 5/14/20 4:52 PM, Nicolas Goaziou wrote:

Hello,

Panagiotis Vlantis  writes:


This is my first time using the mailing list so please point out if
I am going about this the wrong way.

Thank you for the patch.

You are welcome.



After searching a bit, I didn't find a way to specify a custom fixed
indentation column in org sections; the current implementation
automatically aligns content at the beginning of the line when
`org-adapt-indentation' is set to nil, which I find somewhat
restrictive (e.g., in this case, one should be careful when using
lists beginning with '*' characters).

Starting list items with "*" is a terrible idea, indeed. However, it is
unlikely to break the document because list promotion commands handle
this case.

I'm not convinced the current implementation is restrictive. OOC, do you
know any text-related mode that allows indenting contents at any column?
Also please note that if your first line is indented, all indentation
below will follow.


Maybe restrictive was a bad way to put it. Nonetheless, I find being 
able to align contents at a column other than the first handy since it 
is easy to visually distinguish between staff without steadily losing 
usable space as the node level increases. This is especially noticeable 
when one follows a fixed line width layout and somehow ends up with 7 
levels deep headings (not a good practice, I know :)) I have to admit 
that I am not aware of any text-related mode with this kind of feature 
either, although such customization (i.e., adaptive vs fixed 
indentation) is rather convenient in source code editing modes (e.g., 
`cc-mode', etc).



To that end, I modified the current implementation accordingly (and
added some tests) in order to allow one to set the desired indentation
column to something other than the 0th, where section contents will be
aligned at if adaptive indentation is disabled.

I don't know if others will find this feature useful but I'll go and
include the patch here anyway. If you find this worth merging but
should be modified somehow before that, I would be happy to do so.

Instead of creating a new variable, what about overloading
`org-adapt-indentation'? If it is a whole number, use it as indentation.
`nil' becomes an alias for 0.

WDYT?


I tried out your suggestion and overloaded `org-adapt-indentation' 
instead of introducing a new variable. The corresponding patch can be 
seen below. Clearly, I am in no position to tell which implementation is 
better, although the latter feels a bit more complicated than the first. 
What is your opinion on this?




Regards,

--
Nicolas Goaziou


Best regard,

Panagiotis Vlantis




From 7e46937d1b188f913093f0ae66914803f51441e7 Mon Sep 17 00:00:00 2001
From: Panagiotis Vlantis 
Date: Sun, 17 May 2020 14:36:21 +0300
Subject: [PATCH] org: Enable selection of custom indentation column

* lisp/org.el (org-adapt-indentation): Allow integer values to specify
custom indentation column.
(org--get-expected-indentation): Properly handle case when
`org-adapt-indentation' is integer.
(org-add-planning-info): Properly indent newly added planning info when
`org-adapt-indentation' is integer.

* testing/lisp/test-org.el (test-org/get-property-block,
test-org/insert-property-drawer, test-org/indent-line,
test-org/indent-region, test-org/add-planning-info, test-org/deadline,
test-org/schedule, test-org/set-property): Modify tests depending on
indentation and add more tests.

Introduce variable and modify indentation mechanism accordingly in
order to allow the user to specify a custom indentation column (other
than zero) to be used instead of adaptive indentation.
---
 lisp/org.el  |  47 ++
 testing/lisp/test-org.el | 190 ++-
 2 files changed, 220 insertions(+), 17 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index dcd446745..487a81617 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1575,27 +1575,34 @@ lines to the buffer:
 (defcustom org-adapt-indentation t
   "Non-nil means adapt indentation to outline node level.

-When this variable is set to t, Org assumes that you write
+When this variable is non-nil, Org assumes that you write
 outlines by indenting text in each node to align with the
 headline (after the stars).

-When this variable is set to 'headline-data, only adapt the
-indentation of the data lines right below the headline, such as
-planning/clock lines and property/logbook drawers.
+In the special case this variable is set to 'headline-data,
+only adapt the indentation of the data lines right below the headline,
+such as planning/clock lines and property/logbook drawers.
+
+In the special case this variable is set to an integer value N,
+section contents will be indented to the N-th column instead,
+independently of the the corresponding outline node's level.

 The following issues are influenced by this variable:

-- The indentation is increased by one space in a demotion
-  command, and decreased by one in 

Re: Customizable fixed indentation column

2020-05-14 Thread Nicolas Goaziou
Hello,

Panagiotis Vlantis  writes:

> This is my first time using the mailing list so please point out if
> I am going about this the wrong way.

Thank you for the patch.

> After searching a bit, I didn't find a way to specify a custom fixed
> indentation column in org sections; the current implementation
> automatically aligns content at the beginning of the line when
> `org-adapt-indentation' is set to nil, which I find somewhat
> restrictive (e.g., in this case, one should be careful when using
> lists beginning with '*' characters).

Starting list items with "*" is a terrible idea, indeed. However, it is
unlikely to break the document because list promotion commands handle
this case.

I'm not convinced the current implementation is restrictive. OOC, do you
know any text-related mode that allows indenting contents at any column?
Also please note that if your first line is indented, all indentation
below will follow.

> To that end, I modified the current implementation accordingly (and
> added some tests) in order to allow one to set the desired indentation
> column to something other than the 0th, where section contents will be
> aligned at if adaptive indentation is disabled.
>
> I don't know if others will find this feature useful but I'll go and
> include the patch here anyway. If you find this worth merging but
> should be modified somehow before that, I would be happy to do so.

Instead of creating a new variable, what about overloading
`org-adapt-indentation'? If it is a whole number, use it as indentation.
`nil' becomes an alias for 0.

WDYT?

Regards,

--
Nicolas Goaziou



Customizable fixed indentation column

2020-05-10 Thread Panagiotis Vlantis

Hello to all,

This is my first time using the mailing list so please point out if I am 
going about this the wrong way.


After searching a bit, I didn't find a way to specify a custom fixed 
indentation column in org sections; the current implementation 
automatically aligns content at the beginning of the line when 
`org-adapt-indentation' is set to nil, which I find somewhat restrictive 
(e.g., in this case, one should be careful when using lists beginning 
with '*' characters).


To that end, I modified the current implementation accordingly (and 
added some tests) in order to allow one to set the desired indentation 
column to something other than the 0th, where section contents will be 
aligned at if adaptive indentation is disabled.


I don't know if others will find this feature useful but I'll go and 
include the patch here anyway. If you find this worth merging but should 
be modified somehow before that, I would be happy to do so.


Best regards,
Panagiotis


From 9b24257aeb11fa6f1d00eae0ac48fe0f92ca2dad Mon Sep 17 00:00:00 2001
From: Panagiotis Vlantis 
Date: Sun, 10 May 2020 18:09:00 +0300
Subject: [PATCH] org: Enable selection of custom indentation column

* lisp/org.el (org--get-expected-indentation): Return value of
`org-fixed-indentation' when `org-adapt-indentation' is nil.
(org-add-planning-info): Properly indent newly added planning info.
(org-fixed-indentation): Introduce customizable variable for preferred
fixed indentation column.

* testing/lisp/test-org.el (test-org/get-property-block,
test-org/insert-property-drawer, test-org/indent-line,
test-org/indent-region, test-org/add-planning-info, test-org/deadline,
test-org/schedule, test-org/set-property): Modify tests depending on
indentation and add more tests.

Introduce variable and modify indentation mechanism accordingly in
order to allow the user to specify a custom indentation column (other
than zero) to be used when adaptive indentation is disabled.

TINYCHANGE
---
 lisp/org.el  |  18 ++-
 testing/lisp/test-org.el | 293 ---
 2 files changed, 290 insertions(+), 21 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 9b9b4376b..d87d449f7 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10639,8 +10639,9 @@ WHAT entry will also be removed."
 (what
  (end-of-line)
  (insert "\n")
-     (when org-adapt-indentation
-       (indent-to-column (1+ (org-outline-level)
+     (indent-to-column (if org-adapt-indentation
+                  (1+ (org-outline-level))
+                    (max org-fixed-indentation 0
 (t nil)))
  (when what
    ;; Insert planning keyword.
@@ -18720,6 +18721,16 @@ hierarchy of headlines by UP levels before 
marking the subtree."


 ;;; Indentation

+(defcustom org-fixed-indentation 0
+  "Preferred indentation column when adaptive indentation is disabled.
+
+When `org-adapt-indentation' is nil, the contents of sections
+shall be indented to the column specified by this variable,
+independently of the the corresponding section's level."
+  :group 'org-edit-structure
+  :type 'integer
+  :safe #'integerp)
+
 (defvar org-element-greater-elements)
 (defun org--get-expected-indentation (element contentsp)
   "Expected indentation column for current line, according to ELEMENT.
@@ -18735,7 +18746,8 @@ ELEMENT."
    (cl-case type
  ((diary-sexp footnote-definition) 0)
  ((headline inlinetask nil)
-      (if (not org-adapt-indentation) 0
+      (if (not org-adapt-indentation)
+      (if (org-current-level) (max org-fixed-indentation 0) 0)
     (let ((level (org-current-level)))
   (if level (1+ level) 0
  ((item plain-list) (org-list-item-body-column post-affiliated))
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index a0f505cbc..baaf6d800 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -452,7 +452,15 @@
   (should
    (equal "* H\n:PROPERTIES:\n:END:\n"
   (org-test-with-temp-text "* H"
-        (let ((org-adapt-indentation nil))
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0))
+      (org-get-property-block nil 'force))
+        (buffer-string
+  (should
+   (equal "* H\n :PROPERTIES:\n :END:\n"
+      (org-test-with-temp-text "* H"
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5))
   (org-get-property-block nil 'force))
     (buffer-string
   (should
@@ -473,7 +481,16 @@
   (should
    (equal ":PROPERTIES:\n:END:\n"
   (org-test-with-temp-text ""
-        (let ((org-adapt-indentation nil)) (org-insert-property-drawer))
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0))
+      (org-insert-property-drawer))
+        (buffer-string
+  (should
+   (equal ":PROPERTIES:\n:END:\n"
+      (org-test-with-temp-text ""
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5))
+