瀏覽代碼

Fix diary sexp indentation

* lisp/org.el (org--get-expected-indentation): Diary sexps are to be
  indented at column 0.
* testing/lisp/test-org.el (test-org/indent-line): Add test.
Nicolas Goaziou 10 年之前
父節點
當前提交
707d52cff7
共有 2 個文件被更改,包括 11 次插入6 次删除
  1. 4 4
      lisp/org.el
  2. 7 2
      testing/lisp/test-org.el

+ 4 - 4
lisp/org.el

@@ -22752,7 +22752,7 @@ ELEMENT."
      (cond
       (contentsp
        (case type
-	 (footnote-definition 0)
+	 ((diary-sexp footnote-definition) 0)
 	 ((headline inlinetask nil)
 	  (if (not org-adapt-indentation) 0
 	    (let ((level (org-current-level)))
@@ -22771,7 +22771,7 @@ ELEMENT."
        (if (save-excursion (beginning-of-line) (looking-at "[ \t]*$"))
 	   (org--get-expected-indentation element t)
 	 0))
-      ((eq type 'footnote-definition) 0)
+      ((memq type '(diary-sexp footnote-definition)) 0)
       ;; First paragraph of a footnote definition or an item.
       ;; Indent like parent.
       ((< (line-beginning-position) start)
@@ -22858,8 +22858,8 @@ Alignment is done according to `org-property-format', which see."
 
 Indentation is done according to the following rules:
 
-  - Footnote definitions, headlines and inline tasks have to
-    start at column 0.
+  - Footnote definitions, diary sexps, headlines and inline tasks
+    have to start at column 0.
 
   - On the very first line of an element, consider, in order, the
     next rules until one matches:

+ 7 - 2
testing/lisp/test-org.el

@@ -578,10 +578,10 @@
 
 (ert-deftest test-org/indent-line ()
   "Test `org-indent-line' specifications."
-  ;; Do not indent footnote definitions or headlines.
+  ;; Do not indent diary sexps, footnote definitions or headlines.
   (should
    (zerop
-    (org-test-with-temp-text "* H"
+    (org-test-with-temp-text "%%(org-calendar-holiday)"
       (org-indent-line)
       (org-get-indentation))))
   (should
@@ -589,6 +589,11 @@
     (org-test-with-temp-text "[fn:1] fn"
       (let ((org-adapt-indentation t)) (org-indent-line))
       (org-get-indentation))))
+  (should
+   (zerop
+    (org-test-with-temp-text "* H"
+      (org-indent-line)
+      (org-get-indentation))))
   ;; Do not indent before first headline.
   (should
    (zerop