Re: Bug: [PATCH] org-datetree-insert-line doesn't honor headline spacing customization [9.3 (release_9.3 @ /usr/share/emacs/27.1/lisp/org/)]
Hello Vasilij, Vasilij Schneidermann writes: >> Thanks for the patch. I tried it and these two tests fail: >> >>FAILED test-org-datetree/find-date-create >>FAILED test-org-datetree/find-iso-week-create >> >> Perhaps you can check the value of `org-blank-before-new-entry' and >> insert a blank line only if needed? > > I've looked at the tests and concluded that your proposed approach is better > and updated the patch accordingly. thanks for the updated patch, I added a changelog entry and applied it as 5082e436a in master. Best, -- Bastien
Re: Bug: [PATCH] org-datetree-insert-line doesn't honor headline spacing customization [9.3 (release_9.3 @ /usr/share/emacs/27.1/lisp/org/)]
Hello Bastien, > Thanks for the patch. I tried it and these two tests fail: > >FAILED test-org-datetree/find-date-create >FAILED test-org-datetree/find-iso-week-create > > Perhaps you can check the value of `org-blank-before-new-entry' and > insert a blank line only if needed? I've looked at the tests and concluded that your proposed approach is better and updated the patch accordingly. Vasilij From 47085037a1882a2a723076a47972feb35cc42a7b Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Tue, 8 Sep 2020 22:15:25 +0200 Subject: [PATCH] Ensure blank line if needed for datetrees --- lisp/org-datetree.el | 2 ++ testing/lisp/test-org-datetree.el | 56 +++ 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/lisp/org-datetree.el b/lisp/org-datetree.el index ce91591f1..d4ccc84bb 100644 --- a/lisp/org-datetree.el +++ b/lisp/org-datetree.el @@ -185,6 +185,8 @@ inserted into the buffer." (defun org-datetree-insert-line (year month day text) (delete-region (save-excursion (skip-chars-backward " \t\n") (point)) (point)) + (when (assq 'heading org-blank-before-new-entry) +(insert "\n")) (insert "\n" (make-string org-datetree-base-level ?*) " \n") (backward-char) (when month (org-do-demote)) diff --git a/testing/lisp/test-org-datetree.el b/testing/lisp/test-org-datetree.el index 5557d5e23..daebcaace 100644 --- a/testing/lisp/test-org-datetree.el +++ b/testing/lisp/test-org-datetree.el @@ -26,7 +26,7 @@ ;; When date is missing, create it. (should (string-match -"\\`\\* 2012\n\\*\\* 2012-03 .*\n\\*\\*\\* 2012-03-29 .*\\'" +"\\`\\* 2012\n\n\\*\\* 2012-03 .*\n\n\\*\\*\\* 2012-03-29 .*\\'" (org-test-with-temp-text "" (let ((org-datetree-add-timestamp nil)) (org-datetree-find-date-create '(3 29 2012))) @@ -34,7 +34,7 @@ ;; Do not create new year node when one exists. (should (string-match -"\\`\\* 2012\n\\*\\* 2012-03 .*\n\\*\\*\\* 2012-03-29 .*\\'" +"\\`\\* 2012\n\n\\*\\* 2012-03 .*\n\n\\*\\*\\* 2012-03-29 .*\\'" (org-test-with-temp-text "* 2012\n" (let ((org-datetree-add-timestamp nil)) (org-datetree-find-date-create '(3 29 2012))) @@ -42,24 +42,24 @@ ;; Do not create new month node when one exists. (should (string-match -"\\`\\* 2012\n\\*\\* 2012-03 .*\n\\*\\*\\* 2012-03-29 .*\\'" -(org-test-with-temp-text "* 2012\n** 2012-03 month" +"\\`\\* 2012\n\n\\*\\* 2012-03 .*\n\n\\*\\*\\* 2012-03-29 .*\\'" +(org-test-with-temp-text "* 2012\n\n** 2012-03 month" (let ((org-datetree-add-timestamp nil)) (org-datetree-find-date-create '(3 29 2012))) (org-trim (buffer-string) ;; Do not create new day node when one exists. (should (string-match -"\\`\\* 2012\n\\*\\* 2012-03 .*\n\\*\\*\\* 2012-03-29 .*\\'" -(org-test-with-temp-text "* 2012\n** 2012-03 month\n*** 2012-03-29 day" +"\\`\\* 2012\n\n\\*\\* 2012-03 .*\n\n\\*\\*\\* 2012-03-29 .*\\'" +(org-test-with-temp-text "* 2012\n\n** 2012-03 month\n\n*** 2012-03-29 day" (let ((org-datetree-add-timestamp nil)) (org-datetree-find-date-create '(3 29 2012))) (org-trim (buffer-string) ;; Sort new entry in right place. (should (string-match -"\\`\\* 2012\n\\*\\* 2012-02 .*\n\\*\\*\\* 2012-02-01 .*\n\n\\*\\* 2012-03 .*\n\\*\\*\\* 2012-03-29 .*\\'" -(org-test-with-temp-text "* 2012\n** 2012-03 month\n*** 2012-03-29 day" +"\\`\\* 2012\n\n\\*\\* 2012-02 .*\n\n\\*\\*\\* 2012-02-01 .*\n\n\\*\\* 2012-03 .*\n\n\\*\\*\\* 2012-03-29 .*\\'" +(org-test-with-temp-text "* 2012\n\n** 2012-03 month\n\n*** 2012-03-29 day" (let ((org-datetree-add-timestamp nil)) (org-datetree-find-date-create '(3 29 2012)) (org-datetree-find-date-create '(2 1 2012))) @@ -68,14 +68,14 @@ ;; in entry. When set to `inactive', insert an inactive one. (should (string-match -"\\`\\* 2012\n\\*\\* 2012-03 .*\n\\*\\*\\* \\(2012-03-29\\) .*\n[ \t]*<\\1.*?>\\'" +"\\`\\* 2012\n\n\\*\\* 2012-03 .*\n\n\\*\\*\\* \\(2012-03-29\\) .*\n[ \t]*<\\1.*?>\\'" (org-test-with-temp-text "* 2012\n" (let ((org-datetree-add-timestamp t)) (org-datetree-find-date-create '(3 29 2012))) (org-trim (buffer-string) (should (string-match -"\\`\\* 2012\n\\*\\* 2012-03 .*\n\\*\\*\\* \\(2012-03-29\\) .*\n[ \t]*\\[\\1.*?\\]\\'" +"\\`\\* 2012\n\n\\*\\* 2012-03 .*\n\n\\*\\*\\* \\(2012-03-29\\) .*\n[ \t]*\\[\\1.*?\\]\\'" (org-test-with-temp-text "* 2012\n" (let ((org-datetree-add-timestamp 'inactive)) (org-datetree-find-date-create '(3 29 2012))) @@ -91,9 +91,9 @@ (org-trim (buffer-string) (should (string-match -"\\*\\* H1.1\n:PROPERTIES:\n:DATE_TREE: t\n:END:\n\\*\\*\\* 2012" +"\\*\\* H1.1\n:PROPERTIES:\n:DATE_TREE: t\n:END:\n\n\\*\\*\\* 2012" (org-test-with-temp-text - "* H1\n** H1.1\n:PROPERTIES:\n:DATE_TREE:
Re: Bug: [PATCH] org-datetree-insert-line doesn't honor headline spacing customization [9.3 (release_9.3 @ /usr/share/emacs/27.1/lisp/org/)]
Hi Vasilij, Vasilij Schneidermann writes: > When doing org captures using the datetree format, newly added headlines > do not follow the value of `org-blank-before-new-entry'. This seems to > be the fault of `org-datetree-insert-line' using `insert' as opposed to > `org-insert-heading' to do its work. See the attachment for a proposed > fix. Thanks for the patch. I tried it and these two tests fail: FAILED test-org-datetree/find-date-create FAILED test-org-datetree/find-iso-week-create Perhaps you can check the value of `org-blank-before-new-entry' and insert a blank line only if needed? -- Bastien
Bug: [PATCH] org-datetree-insert-line doesn't honor headline spacing customization [9.3 (release_9.3 @ /usr/share/emacs/27.1/lisp/org/)]
When doing org captures using the datetree format, newly added headlines do not follow the value of `org-blank-before-new-entry'. This seems to be the fault of `org-datetree-insert-line' using `insert' as opposed to `org-insert-heading' to do its work. See the attachment for a proposed fix. Emacs : GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22) of 2020-08-13 Package: Org mode version 9.3 (release_9.3 @ /usr/share/emacs/27.1/lisp/org/) current state: == (setq org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer) org-link-shell-confirm-function 'yes-or-no-p org-metadown-hook '(org-babel-pop-to-session-maybe) org-clock-out-hook '(org-clock-remove-empty-clock-drawer) org-enforce-todo-dependencies t org-time-stamp-rounding-minutes '(0 15) org-reveal-start-hook '(org-decrypt-entry) org-blocker-hook '(org-block-todo-from-checkboxes org-block-todo-from-children-or-siblings-or-parent) org-cycle-include-plain-lists 'integrate org-mode-hook '(#[0 "\300\301\302\303\304$\207" [add-hook change-major-mode-hook org-show-all append local] 5] #[0 "\300\301\302\303\304$\207" [add-hook change-major-mode-hook org-babel-show-result-all append local] 5] org-babel-result-hide-spec org-babel-hide-all-hashes) org-archive-hook '(org-attach-archive-delete-maybe) org-confirm-elisp-link-function 'yes-or-no-p org-startup-indented t org-agenda-before-write-hook '(org-agenda-add-entry-text) org-metaup-hook '(org-babel-load-in-session-maybe) org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn ENTRY)"] org-babel-pre-tangle-hook '(save-buffer) org-file-apps '(("pdf" . system) (auto-mode . emacs) (system . "xdg-open %s") (t . system)) org-tab-first-hook '(org-babel-hide-result-toggle-maybe org-babel-header-arg-expand) org-export-backends '(ascii beamer html latex md) org-ellipsis 'org-ellipsis org-src-preserve-indentation t org-catch-invisible-edits 'error org-occur-hook '(org-first-headline-recenter) org-enforce-todo-checkbox-dependencies t org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-show-empty-lines org-optimize-window-after-visibility-change) org-speed-command-hook '(org-speed-command-activate org-babel-speed-command-activate) org-capture-mode-hook '(evil-insert-state) org-M-RET-may-split-line nil org-return-follows-link t org-confirm-shell-link-function 'yes-or-no-p org-link-parameters '(("attachment" :follow org-attach-open-link :export org-attach-export-link :complete org-attach-complete-link) ("id" :follow org-id-open) ("eww" :follow eww :store org-eww-store-link) ("rmail" :follow org-rmail-open :store org-rmail-store-link) ("mhe" :follow org-mhe-open :store org-mhe-store-link) ("irc" :follow org-irc-visit :store org-irc-store-link :export org-irc-export) ("info" :follow org-info-open :export org-info-export :store org-info-store-link) ("gnus" :follow org-gnus-open :store org-gnus-store-link) ("docview" :follow org-docview-open :export org-docview-export :store org-docview-store-link) ("bibtex" :follow org-bibtex-open :store org-bibtex-store-link) ("bbdb" :follow org-bbdb-open :export org-bbdb-export :complete org-bbdb-complete-link :store org-bbdb-store-link) ("w3m" :store org-w3m-store-link) ("file+sys") ("file+emacs") ("shell" :follow org-link--open-shell) ("news" :follow #[257 "\301\300\302Q!\207" ["news" browse-url ":"] 5 "\n\n(fn URL)"] ) ("mailto" :follow #[257 "\301\300\302Q!\207" ["mailto" browse-url ":"] 5 "\n\n(fn URL)"] ) ("https" :follow #[257 "\301\300\302Q!\207" ["https" browse-url ":"] 5 "\n\n(fn URL)"] ) ("http" :follow #[257 "\301\300\302Q!\207" ["http" browse-url ":"] 5 "\n\n(fn URL)"] ) ("ftp" :follow #[257 "\301\300\302Q!\207" ["ftp" browse-url ":"] 5