From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gustavo Barros Subject: Bug: Saving and killing buffers with org-capture-refile and multiple agenda files [9.2.4 (9.2.4-11-g1c3eae-elpaplus @ /home/gustavo/.emacs.d/elpa/org-plus-contrib-20190722/)] Date: Sun, 28 Jul 2019 11:08:21 -0300 Message-ID: <87ef2afe0a.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:41198) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hrjqe-0008JJ-R0 for emacs-orgmode@gnu.org; Sun, 28 Jul 2019 10:08:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hrjqd-0003vS-4g for emacs-orgmode@gnu.org; Sun, 28 Jul 2019 10:08:28 -0400 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]:35280) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hrjqc-0003rO-W7 for emacs-orgmode@gnu.org; Sun, 28 Jul 2019 10:08:27 -0400 Received: by mail-qt1-x833.google.com with SMTP id d23so57213535qto.2 for ; Sun, 28 Jul 2019 07:08:26 -0700 (PDT) Received: from gusbrs-laptop (ip-68-2-52-196.nyc.us.northamericancoax.com. [196.52.2.68]) by smtp.gmail.com with ESMTPSA id q73sm12602819qke.90.2019.07.28.07.08.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 28 Jul 2019 07:08:24 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Hi all, I document here some behaviors of =3Dorg-capture-refile=3D which occur when= =20 settings involve multiple files as refile targets, with respect to saving and=20 killing buffers. Most of them are designed to show some more integration=20 between =3Dorg-capture=3D and =3Dorg-capture-refile=3D would be welcome, and one of= them=20 actually does not correspond to documented behavior. Consider the following scenario. We have two agenda files, one for work, another for personal tasks. They have the following content: #+name: ~/org/home.org #+begin_src org ,* Home tasks ,* Capture #+end_src #+name: ~/org/work.org #+begin_src org ,* Work tasks #+end_src We start ~emacs -Q~, and do some basic setup: #+begin_src emacs-lisp (package-initialize) (global-set-key (kbd "C-c c") 'org-capture) (setq org-agenda-files '("~/org/home.org" "~/org/work.org")) (setq org-refile-targets '((org-agenda-files :maxlevel . 2))) (setq org-capture-templates '(("t" "TODO entry" entry (file+headline "~/org/home.org" "Capture") "* TODO %?" :kill-buffer t))) #+end_src In particular, we are not setting the =3D:no-save=3D flag, so we expect the= =20 default behavior of buffers getting saved. Now, we start a capture of an arbitrary task, and leave the capture=20 process by refiling it to the heading =3D* Home tasks=3D. If we then list-buffers ("C-x C-b"), we find that =3Dhome.org=3D has been=20 killed as expected, given the template's =3D:kill-buffer=3D flag. But =3Dwork.org=3D,= =20 which was opened to get the refile targets, is still there. Now we do the same operation, but refile it to the heading =3D* Work=20 tasks=3D instead. If we then list-buffers again, we find that =3Dwork.org=3D is not only=20 trailing, but has been left unsaved. Now we first visit =3Dhome.org=3D and start a capture and end it refiling t= o=20 the heading =3D* Work tasks=3D. Notice here in particular that =3Dhome.org=3D is killed, even though it was= =20 being visited before the capture process started. This does not correspond to documented behavior of =3D:kill-buffer=3D. Summing up: 1. When refiling anywhere, all agenda files (as we set them as refile=20 targets) are visited to supply refile targets, so any of those which are not=20 the base of a capture template are left open, even when option=20 :kill-buffer is set. 2. In this same case, if the refile operation is done to a file which is=20 not the capture base file, the other file is left both modified and=20 trailing. 3. In this same case, even if =3D:kill-buffer=3D is not set, the other file= =20 is left unsaved after refile. 4. Furthermore, when =3D:kill-buffer=3D is set, when leaving the capture=20 operation with =3Dorg-capture-refile=3D the capture base file is killed=20 independently of whether it was opened before or not (contrary to what is stated in=20 the documentation about it). I understand, of course, that the refile operation is an independent one=20 which is layered upon =3Dorg-capture=3D. So items 1-3 there would, in this sense= =20 be "expected". But, I meant to show with these cases, which I don=E2=80=99t t= hink=20 can be labeled "corner" ones, that some further integration between=20 =3Dorg-capture=3D and =3Dorg-capture-refile=3D would be welcome. Item 4, is indeed a behavior=20 that does not correspond to documentation and, to my understanding, should be=20 considered a bug. Best regards, Gustavo Barros. Emacs : GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version=20 3.22.30) of 2019-04-19 Package: Org mode version 9.2.4 (9.2.4-11-g1c3eae-elpaplus @=20 /home/gustavo/.emacs.d/elpa/org-plus-contrib-20190722/) current state: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (setq org-src-mode-hook '(org-src-babel-configure-edit-buffer=20 org-src-mode-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/home.org" "~/org/work.org") org-mode-hook '(#[0 "\300\301\302\303\304$\207" [add-hook=20 change-major-mode-hook org-show-all append local] 5] #[0 "\300\301\302\303\304$\207" [add-hook change-major-mode-hook=20 org-babel-show-result-all append local] 5] org-babel-result-hide-spec org-babel-hide-all-hashes=20 org-eldoc-load) 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=20 "\n\n(fn ENTRY)"] org-babel-pre-tangle-hook '(save-buffer) org-tab-first-hook '(org-babel-hide-result-toggle-maybe=20 org-babel-header-arg-expand) org-src-lang-modes '(("arduino" . arduino) ("redis" . redis) ("php"=20 . php) ("C" . c) ("C++" . c++) ("asymptote" . asy) ("bash" . sh) ("beamer"=20 . latex) ("calc" . fundamental) ("cpp" . c++) ("ditaa" . artist) ("dot" . fundamental) ("elisp"=20 . emacs-lisp) ("ocaml" . tuareg) ("screen" . shell-script) ("shell" . sh) ("sqlite"=20 . sql)) org-occur-hook '(org-first-headline-recenter) org-cycle-hook '(org-cycle-hide-archived-subtrees=20 org-cycle-show-empty-lines org-optimize-window-after-visibility-change) org-speed-command-hook '(org-speed-command-activate=20 org-babel-speed-command-activate) org-confirm-shell-link-function 'yes-or-no-p org-link-parameters '(("id" :follow org-id-open) ("eww" :follow eww=20 :store org-eww-store-link) ("rmail" :follow org-rmail-open :store=20 org-rmail-store-link) ("mhe" :follow org-mhe-open :store=20 org-mhe-store-link) ("irc" :follow org-irc-visit :store=20 org-irc-store-link :export org-irc-export) ("info" :follow org-info-open :export=20 org-info-export :store org-info-store-link) ("gnus" :follow org-gnus-open :store=20 org-gnus-store-link) ("docview" :follow org-docview-open :export=20 org-docview-export :store org-docview-store-link) ("bibtex" :follow org-bibtex-open :store=20 org-bibtex-store-link) ("bbdb" :follow org-bbdb-open :export=20 org-bbdb-export :complete org-bbdb-complete-link :store org-bbdb-store-link) ("w3m" :store org-w3m-store-link) ("file+sys")=20 ("file+emacs") ("elfeed" :follow elfeed-link-open :store=20 elfeed-link-store-link) ("doi" :follow org--open-doi-link) ("elisp"=20 :follow org--open-elisp-link) ("file" :complete org-file-complete-link) ("ftp" :follow (lambda (path) (browse-url (concat=20 "ftp:" path)))) ("help" :follow org--open-help-link) ("http" :follow (lambda (path) (browse-url=20 (concat "http:" path)))) ("https" :follow (lambda (path) (browse-url=20 (concat "https:" path)))) ("mailto" :follow (lambda (path) (browse-url=20 (concat "mailto:" path)))) ("news" :follow (lambda (path) (browse-url=20 (concat "news:" path)))) ("shell" :follow org--open-shell-link)) org-capture-templates '(("t" "TODO entry" entry (file+headline=20 "~/org/home.org" "Capture") "* TODO %?" :kill-buffer t) ) )