Просмотр исходного кода

org-colview: Fix :id in columnview

* lisp/org-colview.el (org-dblock-write:columnview): Fix typo in pcase
  so ID are properly recognized in current document.

* testing/lisp/test-org-colview.el (test-org-colview/dblock): Add tests.
Nicolas Goaziou 9 лет назад
Родитель
Сommit
07e514b58b
2 измененных файлов с 43 добавлено и 1 удалено
  1. 1 1
      lisp/org-colview.el
  2. 42 0
      testing/lisp/test-org-colview.el

+ 1 - 1
lisp/org-colview.el

@@ -1400,7 +1400,7 @@ PARAMS is a property list of parameters:
 	      (setq view-file (match-string-no-properties 1 id-string))
 	      (unless (file-exists-p view-file)
 		(user-error "No such file: %S" id-string)))
-	     ((and (let idpos (org-find-entry-with-id id)) idpos)
+	     ((and (let idpos (org-find-entry-with-id id)) (guard idpos))
 	      (setq view-pos idpos))
 	     ((let `(,filename . ,position) (org-id-find id))
 	      (setq view-file filename)

+ 42 - 0
testing/lisp/test-org-colview.el

@@ -1198,6 +1198,48 @@
 <point>#+BEGIN: columnview :hlines 1 :id global
 #+END:
 * H2
+** H2.1"
+      (let ((org-columns-default-format "%ITEM")) (org-update-dblock))
+      (buffer-substring-no-properties (point) (outline-next-heading)))))
+  (should
+   (equal
+    "#+BEGIN: columnview :hlines 1 :id \"id\"
+| ITEM |
+|------|
+| H2   |
+| H2.1 |
+#+END:
+"
+    (org-test-with-temp-text
+	"
+* H
+<point>#+BEGIN: columnview :hlines 1 :id \"id\"
+#+END:
+* H2
+:PROPERTIES:
+:ID: id
+:END:
+** H2.1"
+      (let ((org-columns-default-format "%ITEM")) (org-update-dblock))
+      (buffer-substring-no-properties (point) (outline-next-heading)))))
+  (should
+   (equal
+    "#+BEGIN: columnview :hlines 1 :id id
+| ITEM |
+|------|
+| H2   |
+| H2.1 |
+#+END:
+"
+    (org-test-with-temp-text
+	"
+* H
+<point>#+BEGIN: columnview :hlines 1 :id id
+#+END:
+* H2
+:PROPERTIES:
+:ID: id
+:END:
 ** H2.1"
       (let ((org-columns-default-format "%ITEM")) (org-update-dblock))
       (buffer-substring-no-properties (point) (outline-next-heading)))))