[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Bug: canceled capture operation results in demoted following heading

From: Gustavo Barros
Subject: [O] Bug: canceled capture operation results in demoted following heading when template ends with newline [9.2.4 (9.2.4-11-g1c3eae-elpaplus @ /home/gustavo/.emacs.d/elpa/org-plus-contrib-20190722/)]
Date: Sun, 28 Jul 2019 16:34:07 -0300
User-agent: mu4e 1.2.0; emacs 26.2

Hi all,

When the capture template ends with a newline character and the capture process is canceled, the following heading gets demoted. And it shouldn’t.

Consider the following scenario. We have an agenda file with the following content:

#+name: ~/org/agenda.org
#+begin_src org
,* Capture

,* Following heading


We start ~emacs -Q~, and do some basic setup:

#+begin_src emacs-lisp
(global-set-key (kbd "C-c c") 'org-capture)
(setq org-agenda-files
(setq org-refile-targets
     '((org-agenda-files :maxlevel . 2)))
(setq org-capture-templates
     '(("t" "TODO entry" entry
        (file+headline "~/org/agenda.org" "Capture")
        "* TODO %?\n")))

Now we start capture with "C-c c t" and cancel it with "C-c k". Examination of "agenda.org" will show:

#+name: ~/org/agenda.org
#+begin_src org
,* Capture
,** Following heading


Both the line between them is gone, and "* Following heading" got demoted, which is particularly unfortunate.

I’m not sure that I found a general rule in this respect. I had met this effect before in my workflow and vaguely associated it with a trailing "\n". Investigating it further, I could find a recipe to reproduce the effect, as shown, but I don’t really know how general it is.

This effect does not occur if "\n" is removed from the template, and I don’t know if its inclusion is to be considered bad practice, particularly as the capture templates already have a structure to handle empty lines. But, if my memory does not betray me in this respect, one will find plenty of those laying around in folks configs.

Best regards,
Gustavo Barros.

Emacs : GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
of 2019-04-19
Package: Org mode version 9.2.4 (9.2.4-11-g1c3eae-elpaplus @ /home/gustavo/.emacs.d/elpa/org-plus-contrib-20190722/)

current state:
org-src-mode-hook '(org-src-babel-configure-edit-buffer
org-metadown-hook '(org-babel-pop-to-session-maybe)
org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
org-refile-targets '((org-agenda-files :maxlevel . 2))
org-agenda-files '("~/org/agenda.org")
org-mode-hook '(#[0 "\300\301\302\303\304$\207"
[add-hook change-major-mode-hook org-show-all append local]
                 #[0 "\300\301\302\303\304$\207"
[add-hook change-major-mode-hook org-babel-show-result-all
                    append local]
                 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-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-tab-first-hook '(org-babel-hide-result-toggle-maybe
org-src-lang-modes '(("arduino" . arduino) ("redis" . redis) ("php" . php)
                      ("C" . c) ("C++" . c++) ("asymptote" . asy)
("bash" . sh) ("beamer" . latex) ("calc" . fundamental) ("cpp" . c++) ("ditaa" . artist) ("dot" . fundamental)
                      ("elisp" . emacs-lisp) ("ocaml" . tuareg)
                      ("screen" . shell-script) ("shell" . sh)
                      ("sqlite" . sql))
org-occur-hook '(org-first-headline-recenter)
org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-show-empty-lines
org-speed-command-hook '(org-speed-command-activate
org-confirm-shell-link-function 'yes-or-no-p
org-link-parameters '(("id" :follow org-id-open)
                       ("eww" :follow eww :store org-eww-store-link)
                       ("rmail" :follow org-rmail-open :store
("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
                       ("docview" :follow org-docview-open :export
org-docview-export :store org-docview-store-link)
                       ("bibtex" :follow org-bibtex-open :store
("bbdb" :follow org-bbdb-open :export org-bbdb-export
                        :complete org-bbdb-complete-link :store
                       ("w3m" :store org-w3m-store-link) ("file+sys")
                       ("elfeed" :follow elfeed-link-open :store
                       ("doi" :follow org--open-doi-link)
                       ("elisp" :follow org--open-elisp-link)
                       ("file" :complete org-file-complete-link)
                       ("ftp" :follow
(lambda (path) (browse-url (concat "ftp:" path))))
                       ("help" :follow org--open-help-link)
                       ("http" :follow
(lambda (path) (browse-url (concat "http:" path))))
                       ("https" :follow
(lambda (path) (browse-url (concat "https:" path))))
                       ("mailto" :follow
(lambda (path) (browse-url (concat "mailto:"; path))))
                       ("news" :follow
(lambda (path) (browse-url (concat "news:"; path))))
                       ("shell" :follow org--open-shell-link))
org-capture-templates '(("t" "TODO entry" entry
                          (file+headline "~/org/agenda.org" "Capture")
                          "* TODO %?\n")

reply via email to

[Prev in Thread] Current Thread [Next in Thread]