emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: No Wayman <iarchivedmywholelife@gmail.com>
To: Kyle Meyer <kyle@kyleam.com>
Cc: emacs-orgmode@gnu.org
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: Mon, 06 Apr 2020 12:49:36 -0400	[thread overview]
Message-ID: <87zhbov9sw.fsf@gmail.com> (raw)
In-Reply-To: <87lfn917rx.fsf@kyleam.com>


Kyle Meyer <kyle@kyleam.com> writes:

> Based on the history above, I believe the main purpose is to 
> give users
> a way to reverse the "no saving" behavior made in 63f6e851b (Do 
> not save
> target buffer after archiving subtree, 2017-11-25).  I'm 
> _guessing_
> that, on top of that, the idea adding a from-agenda value was 
> that some
> users may want to save only when archiving from the agenda, 
> because in
> that case they're a bit removed from the buffer and might not 
> think to
> save it, or something along those lines.

> Assuming what I said above is true, I think what you propose 
> here loses
> the ability to save only when archiving from the agenda.  And 
> more
> importantly, users would not be able to give a blanket "don't 
> save" in
> order to retain the behavior introduced by 63f6e851b (Do not 
> save target
> buffer after archiving subtree, 2017-11-25).


Thanks for the explanation, Kyle. I understand the intent of the 
variable better now.
What do you think of something like this?

#+begin_src emacs-lisp
(defcustom org-archive-subtree-save-file-p 'unless-agenda
  "Conditionally save the archive file after archiving a subtree.
The value 'unless-agenda prevents saving from the agenda-view.
The value 'only-agenda saves only when the archive is initiated 
from the agenda-view.
The value t saves in all cases where the archive target buffer is 
not the current buffer.
The value nil prevents saving in all cases."
  :group 'org-archive
  :package-version '(Org . "9.4")
  :type '(choice
          (const :tag "Do not save archive buffer when archiving 
          from an agenda view" unless-agenda)
          (const :tag "Only save archive buffer when archiving 
          from an agenda view"   only-agenda)
          (const :tag "Save the archive buffer unless it is the 
          current buffer" t)
          (const :tag "Do not save the archive buffer")))
#+end_src

#+begin_src emacs-lisp
;;don't save when target buffer is current buffer
(unless (eq buffer this-buffer)
  ;;t always saves
  (when (or (eq org-archive-subtree-save-file-p t)
            ;;'unless-agenda saves unless archive initiated from 
            agenda
            (and (eq org-archive-subtree-save-file-p 
            'unless-agenda)
                 (not (boundp 'org-archive-from-agenda)))
            ;;'only-agenda saves iff archive initiated from agenda
            (and (eq org-archive-subtree-save-file-p 'only-agenda)
                 (boundp 'org-archive-from-agenda)))
    (save-buffer)))
#+end_src

This should result in the following scenarios:

| org-archive-subtree-save-file-p | called-from-agenda? | buffer 
  saved? |
|---------------------------------+---------------------+---------------|
| t                               | nil                 | t 
  |
| t                               | t                   | t 
  |
| only-agenda                     | nil                 | nil 
  |
| only-agenda                     | t                   | t 
  |
| unless-agenda                   | nil                 | t 
  |
| unless-agenda                   | t                   | nil 
  |
| nil                             | nil                 | nil 
  |
| nil                             | t                   | nil 
  |


  reply	other threads:[~2020-04-06 16:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02 20:05 Bug: org-archive-subtree-save-file-p logic [9.3.6 (release_9.3.6-399-ge6df03 @ /home/n/.emacs.d/straight/build/org/)] No Wayman
2020-04-06  5:51 ` Kyle Meyer
2020-04-06 16:49   ` No Wayman [this message]
2020-04-07  0:37     ` Kyle Meyer
2020-04-07 19:00       ` No Wayman
2020-04-07 19:06         ` No Wayman
2020-04-08  2:58           ` Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zhbov9sw.fsf@gmail.com \
    --to=iarchivedmywholelife@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=kyle@kyleam.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).