emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* 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/)]
@ 2019-07-28 14:08 Gustavo Barros
  2019-07-29  2:09 ` Samuel Wales
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo Barros @ 2019-07-28 14:08 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

I document here some behaviors of =org-capture-refile= which occur when 
settings
involve multiple files as refile targets, with respect to saving and 
killing
buffers.  Most of them are designed to show some more integration 
between
=org-capture= and =org-capture-refile= would be welcome, and one of them 
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 =:no-save= flag, so we expect the 
default
behavior of buffers getting saved.

Now, we start a capture of an arbitrary task, and leave the capture 
process by
refiling it to the heading =* Home tasks=.

If we then list-buffers ("C-x C-b"), we find that =home.org= has been 
killed as
expected, given the template's =:kill-buffer= flag. But =work.org=, 
which was
opened to get the refile targets, is still there.

Now we do the same operation, but refile it to the heading =* Work 
tasks=
instead.

If we then list-buffers again, we find that =work.org= is not only 
trailing, but
has been left unsaved.

Now we first visit =home.org= and start a capture and end it refiling to 
the
heading =* Work tasks=.

Notice here in particular that =home.org= is killed, even though it was 
being
visited before the capture process started.  This does not correspond to
documented behavior of =:kill-buffer=.

Summing up:
1. When refiling anywhere, all agenda files (as we set them as refile 
targets)
   are visited to supply refile targets, so any of those which are not 
   the
   base of a capture template are left open, even when option 
   :kill-buffer is
   set.
2. In this same case, if the refile operation is done to a file which is 
not
   the capture base file, the other file is left both modified and 
   trailing.
3. In this same case, even if =:kill-buffer= is not set, the other file 
is left
   unsaved after refile.
4. Furthermore, when =:kill-buffer= is set, when leaving the capture 
operation
   with =org-capture-refile= the capture base file is killed 
   independently of
   whether it was opened before or not (contrary to what is stated in 
   the
   documentation about it).

I understand, of course, that the refile operation is an independent one 
which
is layered upon =org-capture=.  So items 1-3 there would, in this sense 
be
"expected".  But, I meant to show with these cases, which I don’t think 
can be
labeled "corner" ones, that some further integration between 
=org-capture= and
=org-capture-refile= would be welcome.  Item 4, is indeed a behavior 
that does
not correspond to documentation and, to my understanding, should be 
considered
a bug.

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:
==============
(setq
 org-src-mode-hook '(org-src-babel-configure-edit-buffer 
 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 
 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-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 
 "\n\n(fn ENTRY)"]
 org-babel-pre-tangle-hook '(save-buffer)
 org-tab-first-hook '(org-babel-hide-result-toggle-maybe 
 org-babel-header-arg-expand)
 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-optimize-window-after-visibility-change)
 org-speed-command-hook '(org-speed-command-activate 
 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 
 :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")
		       ("elfeed" :follow elfeed-link-open :store 
		       elfeed-link-store-link)
		       ("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/home.org" "Capture") "* TODO %?"
			  :kill-buffer t)
			 )
 )

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: 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/)]
  2019-07-28 14:08 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/)] Gustavo Barros
@ 2019-07-29  2:09 ` Samuel Wales
  0 siblings, 0 replies; 2+ messages in thread
From: Samuel Wales @ 2019-07-29  2:09 UTC (permalink / raw)
  To: Gustavo Barros; +Cc: emacs-orgmode

for ehalth reasons unable to comprehend this, but incase it is useful
will point out that i do o9nt need teh refile feature.

i always refile, and then finalizet he acpture.  which is a no-op.

-- 
The Kafka Pandemic

What is misopathy?
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html

The disease DOES progress. MANY people have died from it. And ANYBODY
can get it at any time.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-29  2:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-28 14:08 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/)] Gustavo Barros
2019-07-29  2:09 ` Samuel Wales

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).