all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Customizable fixed indentation column
@ 2020-05-10 17:42 Panagiotis Vlantis
  2020-05-14 13:52 ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Panagiotis Vlantis @ 2020-05-10 17:42 UTC (permalink / raw)
  To: emacs-orgmode

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 <panagiotis.vlantis.mc@gmail.com>
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))
+          (org-insert-property-drawer))
          (buffer-string))))
    ;; Insert drawer in document header with existing comment and
    ;; keyword.
@@ -504,13 +521,24 @@
    (should
     (equal "* H\n:PROPERTIES:\n:END:\nParagraph"
        (org-test-with-temp-text "* H\nParagraph<point>"
-        (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 "* H\n     :PROPERTIES:\n     :END:\nParagraph"
+      (org-test-with-temp-text "* H\nParagraph<point>"
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5))
+          (org-insert-property-drawer))
          (buffer-string))))
    (should
     (equal "* H\nDEADLINE: <2014-03-04 
tue.>\n:PROPERTIES:\n:END:\nParagraph"
        (org-test-with-temp-text
            "* H\nDEADLINE: <2014-03-04 tue.>\nParagraph<point>"
-        (let ((org-adapt-indentation nil)) (org-insert-property-drawer))
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0))
+          (org-insert-property-drawer))
          (buffer-string))))
    ;; Indent inserted drawer.
    (should
@@ -522,7 +550,16 @@
    (should
     (equal "* H\n:PROPERTIES:\n:END:\n"
        (org-test-with-temp-text "* H"
-        (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 "* H\n     :PROPERTIES:\n     :END:\n"
+      (org-test-with-temp-text "* H"
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5))
+          (org-insert-property-drawer))
          (buffer-string))))
    ;; Skip inlinetasks before point.
    (when (featurep 'org-inlinetask)
@@ -531,6 +568,7 @@
          (org-test-with-temp-text
          "* H\n*************** I\n*************** END\nP<point>"
            (let ((org-adapt-indentation nil)
+            (org-fixed-indentation 0)
              (org-inlinetask-min-level 15))
          (org-insert-property-drawer))
            (buffer-string)))))
@@ -541,6 +579,7 @@
          (org-test-with-temp-text
          "* H\n*************** I\nP<point>\n*************** END"
            (let ((org-adapt-indentation nil)
+            (org-fixed-indentation 0)
              (org-inlinetask-min-level 15))
          (org-insert-property-drawer))
            (buffer-string))))))
@@ -850,7 +889,16 @@
    (should
     (zerop
      (org-test-with-temp-text "* H\n<point>A"
-      (let ((org-adapt-indentation nil)) (org-indent-line))
+      (let ((org-adapt-indentation nil)
+        (org-fixed-indentation 0))
+    (org-indent-line))
+      (org-get-indentation))))
+  (should
+   (= 5
+    (org-test-with-temp-text "* H\n<point>A"
+      (let ((org-adapt-indentation nil)
+        (org-fixed-indentation 5))
+    (org-indent-line))
        (org-get-indentation))))
    ;; Indenting preserves point position.
    (should
@@ -1083,14 +1131,32 @@
     (equal "* H\n:PROPERTIES:\n:key:      value\n:END:"
        (org-test-with-temp-text "* H\n<point>:PROPERTIES:\n:key: 
value\n:END:"
          (let ((org-property-format "%-10s %s")
-          (org-adapt-indentation nil))
+          (org-adapt-indentation nil)
+          (org-fixed-indentation 0))
+          (org-indent-region (point) (point-max)))
+        (buffer-string))))
+  (should
+   (equal "* H\n  :PROPERTIES:\n  :key:      value\n  :END:"
+      (org-test-with-temp-text "* H\n<point>:PROPERTIES:\n:key: 
value\n:END:"
+        (let ((org-property-format "%-10s %s")
+          (org-adapt-indentation nil)
+          (org-fixed-indentation 2))
            (org-indent-region (point) (point-max)))
          (buffer-string))))
    (should
     (equal "* H\n:PROPERTIES:\n:key:\n:END:"
        (org-test-with-temp-text "* H\n<point>:PROPERTIES:\n:key:\n:END:"
          (let ((org-property-format "%-10s %s")
-          (org-adapt-indentation nil))
+          (org-adapt-indentation nil)
+          (org-fixed-indentation 0))
+          (org-indent-region (point) (point-max)))
+        (buffer-string))))
+  (should
+   (equal "* H\n     :PROPERTIES:\n     :key:\n     :END:"
+      (org-test-with-temp-text "* H\n<point>:PROPERTIES:\n:key:\n:END:"
+        (let ((org-property-format "%-10s %s")
+          (org-adapt-indentation nil)
+          (org-fixed-indentation 5))
            (org-indent-region (point) (point-max)))
          (buffer-string))))
    ;; Indent plain lists.
@@ -4647,11 +4713,24 @@ Text.
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
           nil nil 1))))
-  ;; Create deadline when `org-adapt-indentation' is nil.
+  ;; Create deadline when `org-adapt-indentation' is nil and
+  ;; `org-fixed-indentation' is 0.
    (should
     (equal "* H\nDEADLINE: <2015-06-25>\nParagraph"
        (org-test-with-temp-text "* H\nParagraph<point>"
-        (let ((org-adapt-indentation nil))
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0))
+          (org-add-planning-info 'deadline "<2015-06-25 Thu>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
+  ;; Create deadline when `org-adapt-indentation' is nil and
+  ;; `org-fixed-indentation' is 5.
+  (should
+   (equal "* H\n     DEADLINE: <2015-06-25>\nParagraph"
+      (org-test-with-temp-text "* H\nParagraph<point>"
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5))
            (org-add-planning-info 'deadline "<2015-06-25 Thu>"))
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
@@ -4668,14 +4747,31 @@ Paragraph<point>"
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
           nil nil 1))))
-  ;; Update deadline when `org-adapt-indentation' is nil.
+  ;; Update deadline when `org-adapt-indentation' is nil and
+  ;; `org-fixed-indentation' is 0.
+  (should
+   (equal "* H\nDEADLINE: <2015-06-25>\nParagraph"
+      (org-test-with-temp-text "\
+* H
+DEADLINE: <2015-06-24 Wed>
+Paragraph<point>"
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0))
+          (org-add-planning-info 'deadline "<2015-06-25 Thu>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
+  ;; Update deadline when `org-adapt-indentation' is nil and
+  ;; `org-fixed-indentation' is 5.
+  ;; (current mechanism respects existing indentation).
    (should
     (equal "* H\nDEADLINE: <2015-06-25>\nParagraph"
        (org-test-with-temp-text "\
  * H
  DEADLINE: <2015-06-24 Wed>
  Paragraph<point>"
-        (let ((org-adapt-indentation nil))
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5))
            (org-add-planning-info 'deadline "<2015-06-25 Thu>"))
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
@@ -4689,11 +4785,24 @@ Paragraph<point>"
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
           nil nil 1))))
-  ;; Schedule when `org-adapt-indentation' is nil.
+  ;; Schedule when `org-adapt-indentation' is nil and
+  ;; `org-fixed-indentation' is 0.
    (should
     (equal "* H\nSCHEDULED: <2015-06-25>\nParagraph"
        (org-test-with-temp-text "* H\nParagraph<point>"
-        (let ((org-adapt-indentation nil))
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0))
+          (org-add-planning-info 'scheduled "<2015-06-25 Thu>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
+  ;; Schedule when `org-adapt-indentation' is nil and
+  ;; `org-fixed-indentation' is 5.
+  (should
+   (equal "* H\n     SCHEDULED: <2015-06-25>\nParagraph"
+      (org-test-with-temp-text "* H\nParagraph<point>"
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5))
            (org-add-planning-info 'scheduled "<2015-06-25 Thu>"))
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
@@ -4767,14 +4876,43 @@ Paragraph<point>"
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
           nil nil 1))))
-  ;; Remove closed when `org-adapt-indentation' is nil.
+  ;; Remove closed when `org-adapt-indentation' is nil and
+  ;; `org-fixed-indentation' is 0.
+  (should
+   (equal "* H\nDEADLINE: <2015-06-25>\nParagraph"
+      (org-test-with-temp-text "\
+* H
+CLOSED: [2015-06-25 Thu] DEADLINE: <2015-06-25 Thu>
+Paragraph<point>"
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0))
+          (org-add-planning-info nil nil 'closed))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
+  (should
+   (equal "* H\nParagraph"
+      (org-test-with-temp-text "\
+* H
+  CLOSED: [2015-06-25 Thu]
+Paragraph<point>"
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0))
+          (org-add-planning-info nil nil 'closed))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
+  ;; Remove closed when `org-adapt-indentation' is nil and
+  ;; `org-fixed-indentation' is 5
+  ;; (current mechanism respects existing indentation).
    (should
     (equal "* H\nDEADLINE: <2015-06-25>\nParagraph"
        (org-test-with-temp-text "\
  * H
  CLOSED: [2015-06-25 Thu] DEADLINE: <2015-06-25 Thu>
  Paragraph<point>"
-        (let ((org-adapt-indentation nil))
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5))
            (org-add-planning-info nil nil 'closed))
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
@@ -4785,7 +4923,8 @@ Paragraph<point>"
  * H
    CLOSED: [2015-06-25 Thu]
  Paragraph<point>"
-        (let ((org-adapt-indentation nil))
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5))
            (org-add-planning-info nil nil 'closed))
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
@@ -4824,6 +4963,17 @@ Paragraph<point>"
     (equal "* H\nDEADLINE: <2012-03-29>"
        (org-test-with-temp-text "* H"
          (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0)
+          (org-last-inserted-timestamp nil))
+          (org-deadline nil "<2012-03-29 Tue>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
+  (should
+   (equal "* H\n     DEADLINE: <2012-03-29>"
+      (org-test-with-temp-text "* H"
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5)
            (org-last-inserted-timestamp nil))
            (org-deadline nil "<2012-03-29 Tue>"))
          (replace-regexp-in-string
@@ -4844,6 +4994,17 @@ Paragraph<point>"
        (org-test-at-time "2014-03-04"
          (org-test-with-temp-text "* H"
            (let ((org-adapt-indentation nil)
+            (org-fixed-indentation 0)
+            (org-last-inserted-timestamp nil))
+        (org-deadline nil "+1y"))
+          (replace-regexp-in-string
+           "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1)))))
+  (should
+   (equal "* H\n     DEADLINE: <2015-03-04>"
+      (org-test-at-time "2014-03-04"
+        (org-test-with-temp-text "* H"
+          (let ((org-adapt-indentation nil)
+            (org-fixed-indentation 5)
              (org-last-inserted-timestamp nil))
          (org-deadline nil "+1y"))
            (replace-regexp-in-string
@@ -4853,6 +5014,16 @@ Paragraph<point>"
     (equal "* H\nDEADLINE: <2012-03-29 +2y>"
        (org-test-with-temp-text "* H"
          (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0)
+          (org-last-inserted-timestamp nil))
+          (org-deadline nil "<2012-03-29 Tue +2y>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\) " "" (buffer-string) nil nil 1))))
+  (should
+   (equal "* H\n     DEADLINE: <2012-03-29 +2y>"
+      (org-test-with-temp-text "* H"
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5)
            (org-last-inserted-timestamp nil))
            (org-deadline nil "<2012-03-29 Tue +2y>"))
          (replace-regexp-in-string
@@ -4910,6 +5081,7 @@ Paragraph<point>"
     (equal "* H1\nDEADLINE: <2012-03-29>\n* H2\nDEADLINE: <2012-03-29>"
        (org-test-with-temp-text "* H1\n* H2"
          (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0)
            (org-last-inserted-timestamp nil)
            (org-loop-over-headlines-in-active-region t))
            (transient-mark-mode 1)
@@ -4922,6 +5094,7 @@ Paragraph<point>"
     (equal "* H1\nDEADLINE: <2012-03-29>\n* H2\nDEADLINE: <2012-03-29>"
        (org-test-with-temp-text "* H1\n* H2"
          (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0)
            (org-last-inserted-timestamp nil)
            (org-loop-over-headlines-in-active-region nil))
            (transient-mark-mode 1)
@@ -4938,15 +5111,37 @@ Paragraph<point>"
     (equal "* H\nSCHEDULED: <2012-03-29>"
        (org-test-with-temp-text "* H"
          (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0)
            (org-last-inserted-timestamp nil))
            (org-schedule nil "<2012-03-29 Tue>"))
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
           nil nil 1))))
+  (should
+   (equal "* H\n     SCHEDULED: <2012-03-29>"
+      (org-test-with-temp-text "* H"
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5)
+          (org-last-inserted-timestamp nil))
+          (org-schedule nil "<2012-03-29 Tue>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
+  (should
+   (equal "* H\nSCHEDULED: <2014-03-04>"
+      (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>"
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0)
+          (org-last-inserted-timestamp nil))
+          (org-schedule nil "<2014-03-04 Thu>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
    (should
     (equal "* H\nSCHEDULED: <2014-03-04>"
        (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>"
          (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5)
            (org-last-inserted-timestamp nil))
            (org-schedule nil "<2014-03-04 Thu>"))
          (replace-regexp-in-string
@@ -4958,6 +5153,7 @@ Paragraph<point>"
        (org-test-at-time "2014-03-04"
          (org-test-with-temp-text "* H"
            (let ((org-adapt-indentation nil)
+            (org-fixed-indentation 0)
              (org-last-inserted-timestamp nil))
          (org-schedule nil "+1y"))
            (replace-regexp-in-string
@@ -4967,6 +5163,7 @@ Paragraph<point>"
     (equal "* H\nSCHEDULED: <2012-03-29 +2y>"
        (org-test-with-temp-text "* H"
          (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0)
            (org-last-inserted-timestamp nil))
            (org-schedule nil "<2012-03-29 Tue +2y>"))
          (replace-regexp-in-string
@@ -4976,6 +5173,16 @@ Paragraph<point>"
     (equal "* H\nSCHEDULED: <2012-03-29>"
        (org-test-with-temp-text "* H\nCLOSED: [2017-01-25 Wed]"
          (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0)
+          (org-last-inserted-timestamp nil))
+          (org-schedule nil "<2012-03-29 Tue>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1))))
+  (should
+   (equal "* H\nSCHEDULED: <2012-03-29>"
+      (org-test-with-temp-text "* H\nCLOSED: [2017-01-25 Wed]"
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5)
            (org-last-inserted-timestamp nil))
            (org-schedule nil "<2012-03-29 Tue>"))
          (replace-regexp-in-string
@@ -4985,6 +5192,7 @@ Paragraph<point>"
     (equal "* H\n"
        (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>"
          (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0)
            (org-last-inserted-timestamp nil))
            (org-schedule '(4)))
          (buffer-string))))
@@ -4992,6 +5200,7 @@ Paragraph<point>"
     (equal "* H"
        (org-test-with-temp-text "* H"
          (let ((org-adapt-indentation nil)
+          (org-fixed-indentation)
            (org-last-inserted-timestamp nil))
            (org-schedule '(4)))
          (buffer-string))))
@@ -5004,6 +5213,7 @@ Paragraph<point>"
                    (org-parse-time-string "2014-03-04")))))
          (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>"
            (let ((org-adapt-indentation nil)
+            (org-fixed-indentation 0)
              (org-last-inserted-timestamp nil))
          (org-schedule '(16)))
            (buffer-string)))))
@@ -5014,6 +5224,7 @@ Paragraph<point>"
                 (org-parse-time-string "2014-03-04")))))
       (org-test-with-temp-text "* H"
         (let ((org-adapt-indentation nil)
+         (org-fixed-indentation 0)
           (org-last-inserted-timestamp nil))
       (org-schedule '(16)))
         (buffer-string))))
@@ -5024,6 +5235,20 @@ Paragraph<point>"
     (equal "* H1\nSCHEDULED: <2012-03-29>\n* H2\nSCHEDULED: <2012-03-29>"
        (org-test-with-temp-text "* H1\n* H2"
          (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0)
+          (org-last-inserted-timestamp nil)
+          (org-loop-over-headlines-in-active-region t))
+          (transient-mark-mode 1)
+          (push-mark (point) t t)
+          (goto-char (point-max))
+          (org-schedule nil "2012-03-29"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1))))
+  (should
+   (equal "* H1\n     SCHEDULED: <2012-03-29>\n* H2\n SCHEDULED: 
<2012-03-29>"
+      (org-test-with-temp-text "* H1\n* H2"
+        (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 5)
            (org-last-inserted-timestamp nil)
            (org-loop-over-headlines-in-active-region t))
            (transient-mark-mode 1)
@@ -5036,6 +5261,7 @@ Paragraph<point>"
     (equal "* H1\nSCHEDULED: <2012-03-29>\n* H2\nSCHEDULED: <2012-03-29>"
        (org-test-with-temp-text "* H1\n* H2"
          (let ((org-adapt-indentation nil)
+          (org-fixed-indentation 0)
            (org-last-inserted-timestamp nil)
            (org-loop-over-headlines-in-active-region nil))
            (transient-mark-mode 1)
@@ -5050,6 +5276,7 @@ Paragraph<point>"
      "\\* H\nSCHEDULED: <2017-02-01 [.A-Za-z]* \\+\\+7d>\n"
      (org-test-with-temp-text "* H\nSCHEDULED: <2017-01-19 ++7d>\n"
                   (let ((org-adapt-indentation nil)
+                   (org-fixed-indentation 0)
                     (org-last-inserted-timestamp nil))
                     (org-schedule nil "2017-02-01"))
                   (buffer-string)))))
@@ -5144,7 +5371,27 @@ Paragraph<point>"
     (equal
      ":PROPERTIES:\n:TEST: t\n:END:\n"
      (org-test-with-temp-text ""
-      (let ((org-property-format "%s %s"))
+      (let ((org-property-format "%s %s")
+        (org-adapt-indentation t)
+        (org-fixed-indentation 5))
+    (org-set-property "TEST" "t"))
+      (buffer-string))))
+  (should
+   (equal
+    ":PROPERTIES:\n:TEST: t\n:END:\n"
+    (org-test-with-temp-text ""
+      (let ((org-property-format "%s %s")
+        (org-adapt-indentation nil)
+        (org-fixed-indentation 0))
+    (org-set-property "TEST" "t"))
+      (buffer-string))))
+  (should
+   (equal
+    ":PROPERTIES:\n:TEST: t\n:END:\n"
+    (org-test-with-temp-text ""
+      (let ((org-property-format "%s %s")
+        (org-adapt-indentation nil)
+        (org-fixed-indentation 5))
      (org-set-property "TEST" "t"))
        (buffer-string))))
    (should
@@ -5152,6 +5399,16 @@ Paragraph<point>"
      "* H\n:PROPERTIES:\n:TEST: t\n:END:\n"
      (org-test-with-temp-text "* H"
        (let ((org-adapt-indentation nil)
+        (org-fixed-indentation 0)
+        (org-property-format "%s %s"))
+    (org-set-property "TEST" "t"))
+      (buffer-string))))
+  (should
+   (equal
+    "* H\n     :PROPERTIES:\n     :TEST: t\n     :END:\n"
+    (org-test-with-temp-text "* H"
+      (let ((org-adapt-indentation nil)
+        (org-fixed-indentation 5)
          (org-property-format "%s %s"))
      (org-set-property "TEST" "t"))
        (buffer-string)))))
-- 
2.26.2




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

* Re: Customizable fixed indentation column
  2020-05-10 17:42 Customizable fixed indentation column Panagiotis Vlantis
@ 2020-05-14 13:52 ` Nicolas Goaziou
  2020-05-17 12:42   ` Panagiotis Vlantis
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2020-05-14 13:52 UTC (permalink / raw)
  To: Panagiotis Vlantis; +Cc: emacs-orgmode

Hello,

Panagiotis Vlantis <panagiotis.vlantis.mc@gmail.com> 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


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

* Re: Customizable fixed indentation column
  2020-05-14 13:52 ` Nicolas Goaziou
@ 2020-05-17 12:42   ` Panagiotis Vlantis
  2020-05-24 10:55     ` Bastien
  0 siblings, 1 reply; 5+ messages in thread
From: Panagiotis Vlantis @ 2020-05-17 12:42 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

On 5/14/20 4:52 PM, Nicolas Goaziou wrote:
> Hello,
>
> Panagiotis Vlantis <panagiotis.vlantis.mc@gmail.com> 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 <panagiotis.vlantis.mc@gmail.com>
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 a promotion command.  However,
+- When this variable is set to a non-nil, non-integer value,
+  the indentation is increased by one space in a demotion command,
+  and decreased by one in a promotion command.  However,
    in the latter case, if shifting some line in the entry body
    would alter document structure (e.g., insert a new headline),
    indentation is not changed at all.

  - Property drawers and planning information is inserted indented
-  when this variable is set.  When nil, they will not be indented.
+  when this variable is non-nil.  When nil, they will not be indented.

-- TAB indents a line relative to current level.  The lines below
-  a headline will be indented when this variable is set to t.
+- TAB indents a line relative to current level or at
+  the specified column.  The lines below
+  a headline will be indented when this variable is set to
+  a non-nil value.

  Note that this is all about true indentation, by adding and
  removing space characters.  See also \"org-indent.el\" which does
@@ -1606,8 +1613,11 @@ time in Emacs."
        (const :tag "Adapt indentation for all lines" t)
        (const :tag "Adapt indentation for headline data lines"
           'headline-data)
-      (const :tag "Do not adapt indentation at all" nil))
-  :safe #'booleanp)
+      (const :tag "Do not adapt indentation at all" nil)
+      integer)
+  :safe #'(lambda (x) (or (booleanp x)
+              (eq x 'headline-data)
+              (integerp x))))

  (defvaralias 'org-special-ctrl-a 'org-special-ctrl-a/e)

@@ -10642,7 +10652,9 @@ WHAT entry will also be removed."
       (end-of-line)
       (insert "\n")
       (when org-adapt-indentation
-       (indent-to-column (1+ (org-outline-level)))))
+       (indent-to-column (if (integerp org-adapt-indentation)
+                 (max org-adapt-indentation 0)
+                   (1+ (org-outline-level))))))
      (t nil)))
       (when what
         ;; Insert planning keyword.
@@ -18737,9 +18749,14 @@ ELEMENT."
         (cl-case type
       ((diary-sexp footnote-definition) 0)
       ((headline inlinetask nil)
-      (if (not org-adapt-indentation) 0
-        (let ((level (org-current-level)))
-          (if level (1+ level) 0))))
+      (let ((level (org-current-level)))
+        (if level
+        (if org-adapt-indentation
+            (if (integerp org-adapt-indentation)
+            (max org-adapt-indentation 0)
+              (1+ level))
+          0)
+          0)))
       ((item plain-list) (org-list-item-body-column post-affiliated))
       (t
        (goto-char start)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index d22446a09..de9f9baf2 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -455,6 +455,12 @@
          (let ((org-adapt-indentation nil))
            (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 5))
+          (org-get-property-block nil 'force))
+        (buffer-string))))
    (should
     (equal ":PROPERTIES:\n:END:\n"
        (org-test-with-temp-text ""
@@ -475,6 +481,12 @@
        (org-test-with-temp-text ""
          (let ((org-adapt-indentation nil)) (org-insert-property-drawer))
          (buffer-string))))
+  (should
+   (equal ":PROPERTIES:\n:END:\n"
+      (org-test-with-temp-text ""
+        (let ((org-adapt-indentation 5))
+          (org-insert-property-drawer))
+        (buffer-string))))
    ;; Insert drawer in document header with existing comment and
    ;; keyword.
    (should
@@ -506,6 +518,12 @@
        (org-test-with-temp-text "* H\nParagraph<point>"
          (let ((org-adapt-indentation nil)) (org-insert-property-drawer))
          (buffer-string))))
+  (should
+   (equal "* H\n     :PROPERTIES:\n     :END:\nParagraph"
+      (org-test-with-temp-text "* H\nParagraph<point>"
+        (let ((org-adapt-indentation 5))
+          (org-insert-property-drawer))
+        (buffer-string))))
    (should
     (equal "* H\nDEADLINE: <2014-03-04 
tue.>\n:PROPERTIES:\n:END:\nParagraph"
        (org-test-with-temp-text
@@ -524,6 +542,12 @@
        (org-test-with-temp-text "* H"
          (let ((org-adapt-indentation nil)) (org-insert-property-drawer))
          (buffer-string))))
+  (should
+   (equal "* H\n     :PROPERTIES:\n     :END:\n"
+      (org-test-with-temp-text "* H"
+        (let ((org-adapt-indentation 5))
+          (org-insert-property-drawer))
+        (buffer-string))))
    ;; Skip inlinetasks before point.
    (when (featurep 'org-inlinetask)
      (should
@@ -852,6 +876,12 @@
      (org-test-with-temp-text "* H\n<point>A"
        (let ((org-adapt-indentation nil)) (org-indent-line))
        (org-get-indentation))))
+  (should
+   (= 5
+    (org-test-with-temp-text "* H\n<point>A"
+      (let ((org-adapt-indentation 5))
+    (org-indent-line))
+      (org-get-indentation))))
    ;; Indenting preserves point position.
    (should
     (org-test-with-temp-text "* H\nA<point>B"
@@ -1086,6 +1116,13 @@
            (org-adapt-indentation nil))
            (org-indent-region (point) (point-max)))
          (buffer-string))))
+  (should
+   (equal "* H\n  :PROPERTIES:\n  :key:      value\n  :END:"
+      (org-test-with-temp-text "* H\n<point>:PROPERTIES:\n:key: 
value\n:END:"
+        (let ((org-property-format "%-10s %s")
+          (org-adapt-indentation 2))
+          (org-indent-region (point) (point-max)))
+        (buffer-string))))
    (should
     (equal "* H\n:PROPERTIES:\n:key:\n:END:"
        (org-test-with-temp-text "* H\n<point>:PROPERTIES:\n:key:\n:END:"
@@ -1093,6 +1130,13 @@
            (org-adapt-indentation nil))
            (org-indent-region (point) (point-max)))
          (buffer-string))))
+  (should
+   (equal "* H\n     :PROPERTIES:\n     :key:\n     :END:"
+      (org-test-with-temp-text "* H\n<point>:PROPERTIES:\n:key:\n:END:"
+        (let ((org-property-format "%-10s %s")
+          (org-adapt-indentation 5))
+          (org-indent-region (point) (point-max)))
+        (buffer-string))))
    ;; Indent plain lists.
    (should
     (equal "- A\n  B\n  - C\n\n    D"
@@ -4665,6 +4709,15 @@ Text.
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
           nil nil 1))))
+  ;; Create deadline when `org-adapt-indentation' is nil.
+  (should
+   (equal "* H\n     DEADLINE: <2015-06-25>\nParagraph"
+      (org-test-with-temp-text "* H\nParagraph<point>"
+        (let ((org-adapt-indentation 5))
+          (org-add-planning-info 'deadline "<2015-06-25 Thu>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
    ;; Update deadline when `org-adapt-indentation' is non-nil.
    (should
     (equal "* H\n  DEADLINE: <2015-06-25>\nParagraph"
@@ -4689,6 +4742,19 @@ Paragraph<point>"
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
           nil nil 1))))
+  ;; Update deadline when `org-adapt-indentation' is nil.
+  ;; (current mechanism respects existing indentation).
+  (should
+   (equal "* H\nDEADLINE: <2015-06-25>\nParagraph"
+      (org-test-with-temp-text "\
+* H
+DEADLINE: <2015-06-24 Wed>
+Paragraph<point>"
+        (let ((org-adapt-indentation 5))
+          (org-add-planning-info 'deadline "<2015-06-25 Thu>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
    ;; Schedule when `org-adapt-indentation' is non-nil.
    (should
     (equal "* H\n  SCHEDULED: <2015-06-25>\nParagraph"
@@ -4707,6 +4773,15 @@ Paragraph<point>"
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
           nil nil 1))))
+  ;; Schedule when `org-adapt-indentation' is nil.
+  (should
+   (equal "* H\n     SCHEDULED: <2015-06-25>\nParagraph"
+      (org-test-with-temp-text "* H\nParagraph<point>"
+        (let ((org-adapt-indentation 5))
+          (org-add-planning-info 'scheduled "<2015-06-25 Thu>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
    ;; Add deadline when scheduled.
    (should
     (equal "\
@@ -4799,6 +4874,29 @@ Paragraph<point>"
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
           nil nil 1))))
+  ;; Remove closed when `org-adapt-indentation' is nil.
+  (should
+   (equal "* H\nDEADLINE: <2015-06-25>\nParagraph"
+      (org-test-with-temp-text "\
+* H
+CLOSED: [2015-06-25 Thu] DEADLINE: <2015-06-25 Thu>
+Paragraph<point>"
+        (let ((org-adapt-indentation 5))
+          (org-add-planning-info nil nil 'closed))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
+  (should
+   (equal "* H\nParagraph"
+      (org-test-with-temp-text "\
+* H
+  CLOSED: [2015-06-25 Thu]
+Paragraph<point>"
+        (let ((org-adapt-indentation 5))
+          (org-add-planning-info nil nil 'closed))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
    ;; Remove closed entry and delete empty line.
    (should
     (equal "\
@@ -4838,6 +4936,15 @@ Paragraph<point>"
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
           nil nil 1))))
+  (should
+   (equal "* H\n     DEADLINE: <2012-03-29>"
+      (org-test-with-temp-text "* H"
+        (let ((org-adapt-indentation 5)
+          (org-last-inserted-timestamp nil))
+          (org-deadline nil "<2012-03-29 Tue>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
    (should
     (equal "* H\nDEADLINE: <2014-03-04>"
        (org-test-with-temp-text "* H\nDEADLINE: <2012-03-29>"
@@ -4857,6 +4964,15 @@ Paragraph<point>"
          (org-deadline nil "+1y"))
            (replace-regexp-in-string
             "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1)))))
+  (should
+   (equal "* H\n     DEADLINE: <2015-03-04>"
+      (org-test-at-time "2014-03-04"
+        (org-test-with-temp-text "* H"
+          (let ((org-adapt-indentation 5)
+            (org-last-inserted-timestamp nil))
+        (org-deadline nil "+1y"))
+          (replace-regexp-in-string
+           "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1)))))
    ;; Preserve repeater.
    (should
     (equal "* H\nDEADLINE: <2012-03-29 +2y>"
@@ -4866,6 +4982,14 @@ Paragraph<point>"
            (org-deadline nil "<2012-03-29 Tue +2y>"))
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\) " "" (buffer-string) nil nil 1))))
+  (should
+   (equal "* H\n     DEADLINE: <2012-03-29 +2y>"
+      (org-test-with-temp-text "* H"
+        (let ((org-adapt-indentation 5)
+          (org-last-inserted-timestamp nil))
+          (org-deadline nil "<2012-03-29 Tue +2y>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\) " "" (buffer-string) nil nil 1))))
    ;; Remove CLOSED keyword, if any.
    (should
     (equal "* H\nDEADLINE: <2012-03-29>"
@@ -4952,6 +5076,15 @@ Paragraph<point>"
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
           nil nil 1))))
+  (should
+   (equal "* H\n     SCHEDULED: <2012-03-29>"
+      (org-test-with-temp-text "* H"
+        (let ((org-adapt-indentation 5)
+          (org-last-inserted-timestamp nil))
+          (org-schedule nil "<2012-03-29 Tue>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
    (should
     (equal "* H\nSCHEDULED: <2014-03-04>"
        (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>"
@@ -4961,6 +5094,15 @@ Paragraph<point>"
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string)
           nil nil 1))))
+  (should
+   (equal "* H\nSCHEDULED: <2014-03-04>"
+      (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>"
+        (let ((org-adapt-indentation 5)
+          (org-last-inserted-timestamp nil))
+          (org-schedule nil "<2014-03-04 Thu>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string)
+         nil nil 1))))
    ;; Accept delta time, e.g., "+2d".
    (should
     (equal "* H\nSCHEDULED: <2015-03-04>"
@@ -4989,6 +5131,14 @@ Paragraph<point>"
            (org-schedule nil "<2012-03-29 Tue>"))
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1))))
+  (should
+   (equal "* H\nSCHEDULED: <2012-03-29>"
+      (org-test-with-temp-text "* H\nCLOSED: [2017-01-25 Wed]"
+        (let ((org-adapt-indentation 5)
+          (org-last-inserted-timestamp nil))
+          (org-schedule nil "<2012-03-29 Tue>"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1))))
    ;; With C-u argument, remove SCHEDULED keyword.
    (should
     (equal "* H\n"
@@ -5041,6 +5191,18 @@ Paragraph<point>"
            (org-schedule nil "2012-03-29"))
          (replace-regexp-in-string
           "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1))))
+  (should
+   (equal "* H1\n     SCHEDULED: <2012-03-29>\n* H2\n SCHEDULED: 
<2012-03-29>"
+      (org-test-with-temp-text "* H1\n* H2"
+        (let ((org-adapt-indentation 5)
+          (org-last-inserted-timestamp nil)
+          (org-loop-over-headlines-in-active-region t))
+          (transient-mark-mode 1)
+          (push-mark (point) t t)
+          (goto-char (point-max))
+          (org-schedule nil "2012-03-29"))
+        (replace-regexp-in-string
+         "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1))))
    (should-not
     (equal "* H1\nSCHEDULED: <2012-03-29>\n* H2\nSCHEDULED: <2012-03-29>"
        (org-test-with-temp-text "* H1\n* H2"
@@ -5153,14 +5315,38 @@ Paragraph<point>"
     (equal
      ":PROPERTIES:\n:TEST: t\n:END:\n"
      (org-test-with-temp-text ""
-      (let ((org-property-format "%s %s"))
+      (let ((org-property-format "%s %s")
+        (org-adapt-indentation 0))
+    (org-set-property "TEST" "t"))
+      (buffer-string))))
+  (should
+   (equal
+    ":PROPERTIES:\n:TEST: t\n:END:\n"
+    (org-test-with-temp-text ""
+      (let ((org-property-format "%s %s")
+        (org-adapt-indentation nil))
+    (org-set-property "TEST" "t"))
+      (buffer-string))))
+  (should
+   (equal
+    ":PROPERTIES:\n:TEST: t\n:END:\n"
+    (org-test-with-temp-text ""
+      (let ((org-property-format "%s %s")
+        (org-adapt-indentation 5))
      (org-set-property "TEST" "t"))
        (buffer-string))))
    (should
     (equal
      "* H\n:PROPERTIES:\n:TEST: t\n:END:\n"
      (org-test-with-temp-text "* H"
-      (let ((org-adapt-indentation nil)
+      (let ((org-adapt-indentation nil) (org-property-format "%s %s"))
+    (org-set-property "TEST" "t"))
+      (buffer-string))))
+  (should
+   (equal
+    "* H\n     :PROPERTIES:\n     :TEST: t\n     :END:\n"
+    (org-test-with-temp-text "* H"
+      (let ((org-adapt-indentation 5)
          (org-property-format "%s %s"))
      (org-set-property "TEST" "t"))
        (buffer-string)))))
-- 
2.26.2




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

* Re: Customizable fixed indentation column
  2020-05-17 12:42   ` Panagiotis Vlantis
@ 2020-05-24 10:55     ` Bastien
  2020-05-24 12:34       ` Panagiotis Vlantis
  0 siblings, 1 reply; 5+ messages in thread
From: Bastien @ 2020-05-24 10:55 UTC (permalink / raw)
  To: Panagiotis Vlantis; +Cc: emacs-orgmode

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


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

* Re: Customizable fixed indentation column
  2020-05-24 10:55     ` Bastien
@ 2020-05-24 12:34       ` Panagiotis Vlantis
  0 siblings, 0 replies; 5+ messages in thread
From: Panagiotis Vlantis @ 2020-05-24 12:34 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

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,
>


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

end of thread, other threads:[~2020-05-24 12:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-10 17:42 Customizable fixed indentation column Panagiotis Vlantis
2020-05-14 13:52 ` Nicolas Goaziou
2020-05-17 12:42   ` Panagiotis Vlantis
2020-05-24 10:55     ` Bastien
2020-05-24 12:34       ` Panagiotis Vlantis

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.