emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Bug: org-archive-subtree-save-file-p logic [9.3.6 (release_9.3.6-399


From: No Wayman
Subject: Re: Bug: org-archive-subtree-save-file-p logic [9.3.6 (release_9.3.6-399-ge6df03 @ /home/n/.emacs.d/straight/build/org/)]
Date: Tue, 07 Apr 2020 15:00:47 -0400
User-agent: mu4e 1.3.10; emacs 28.0.50


Kyle Meyer <address@hidden> writes:

Thanks for the suggestion. The code is somewhat oddly formatted, at least on my end. Could you send a proper git-format-patch output to
this thread (either via git-send-email or as an attachment)?

Apologies, I pasted that from an Org buffer without reformatting.
Attaching a proper patch with your suggested revisions here.

I suppose the main argument against from-org is that it's not clear from the name alone that it's referring to a non-agenda Org buffer because "org" is of course a bit overloaded. Considered alongside
from-agenda, I don't think it's too bad though.


I agree. 'from-org is pretty vague. That, combined with the old saving logic was
part of the reason for my initial confusion.
I don't mind keeping it if you feel it's satisfactory, though.
I'm more after the proper functionality.

This current buffer bit also applies to unless-agenda/from-org. Perhaps it'd make sense to just mention the current buffer behavior in the main
docstring, given it applies to all options (even though for
only-agenda/from-agenda, it's never the case that the archive buffer is
the current buffer).

I've dropped the mention of the current-buffer case in the docstring altogether.

In summary

* I'd prefer to make a more minimal change on top of 3d0282ef8, keeping the names chosen there. Functionally that comes down to adjusting the condition that guards the save-buffer call to consider
    from-org.

* I think it'd be good to expand the docstring (along the lines of what you suggested) as well as trim and clarify the tag text a bit.

Took a look at `org-archive-save-context-info' as you suggested. The new docstring is similar to that.



===File /home/n/.emacs.d/straight/repos/org/0001-org-archive.el-fix-org-archive-subtree-save-file-p.patch===
From 289d3ff93c9f7f56ee54d98fd7d6294c4472a37b Mon Sep 17 00:00:00
2001
From: Nicholas Vollmer <address@hidden>
Subject: [PATCH] org-archive.el: fix org-archive-subtree-save-file-p

Consider case of 'from-org setting in saving logic.
Improve docstring.
Remove dead code comment.
---
lisp/org-archive.el | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/lisp/org-archive.el b/lisp/org-archive.el
index 10a5eb501..5e11c3743 100644
--- a/lisp/org-archive.el
+++ b/lisp/org-archive.el
@@ -92,14 +92,20 @@ When a string, a %s formatter will be replaced by the file name."
          (const :tag "Always" t)))

(defcustom org-archive-subtree-save-file-p 'from-org
- "Non-nil means save the archive file after archiving a subtree."
+  "Conditionally save the archive file after archiving a subtree.
+This variable can be any of the following symbols:
+
+t              saves in all cases.
+`from-org'     prevents saving from an agenda-view.
+`from-agenda' saves only when the archive is initiated from an agenda-view.
+nil            prevents saving in all cases."
  :group 'org-archive
  :package-version '(Org . "9.4")
  :type '(choice
-         (const :tag "Always save the archive buffer" t)
- (const :tag "Save target buffer when archiving from an agenda view" from-agenda) - (const :tag "Save target buffer when archiving from an org buffer" from-org)
-         (const :tag "Do not save the archive buffer")))
+         (const :tag "from-org"    from-org)
+         (const :tag "from-agenda" from-agenda)
+         (const :tag "t" t)
+         (const :tag "nil")))

(defcustom org-archive-save-context-info '(time file olpath category todo itags) "Parts of context info that should be stored as properties when archiving.
@@ -373,14 +379,13 @@ direct children of this heading."
                     value))))
              ;; Save and kill the buffer, if it is not the same
;; buffer and depending on `org-archive-subtree-save-file-p'
-             (unless (eq this-buffer buffer)
-               (when (or (eq org-archive-subtree-save-file-p t)
-                         (and (boundp 'org-archive-from-agenda)
-                              (eq org-archive-subtree-save-file-p 
'from-agenda)))
-                 (save-buffer)))
-             ;; (unless (or (not org-archive-subtree-save-file-p)
-             ;;                  (eq this-buffer buffer))
-             ;;        (save-buffer))
+              (unless (eq this-buffer buffer)
+                (when (or (eq org-archive-subtree-save-file-p t)
+                          (and (boundp 'org-archive-from-agenda)
+ (eq org-archive-subtree-save-file-p 'from-agenda)) + (and (not (boundp 'org-archive-from-agenda)) + (eq org-archive-subtree-save-file-p 'from-org)))
+                  (save-buffer)))
              (widen))))
        ;; Here we are back in the original buffer.  Everything seems
        ;; to have worked.  So now run hooks, cut the tree and finish
--
2.26.0

============================================================



reply via email to

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