emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: Adam Porter <adam@alphapapa.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: Emacs bug 37890; killing capture buffer
Date: Tue, 17 Dec 2019 00:00:08 +0100	[thread overview]
Message-ID: <8736dj27wn.fsf@web.de> (raw)
In-Reply-To: <87woaxw79i.fsf@web.de> (Michael Heerdegen's message of "Sun, 15 Dec 2019 23:31:21 +0100")

Michael Heerdegen <michael_heerdegen@web.de> writes:

>  - kill-buffer-hook in the capture buffer could be used to prevent the
>  user from killing such a buffer by accident.  Or it could be made
>  configurable what to do (e.g. undo the change with or without user
>  prompting, ask for what to do, etc.)
>
>  - kill-emacs-hook could be used to register a function that warns when
>  any capture buffers are left when Emacs is to be killed.  That would
>  make a difference if you have captured more stuff after having
>  forgotten about a former capture buffer.  The user would be guided to
>  finish what he would otherwise have forgotten.

That doesn't seem to be hard to implement:

#+begin_src emacs-lisp
(add-hook
 'org-capture-mode-hook
 (defun my-org-capture-mode-hook-fun ()
   (add-hook 'kill-buffer-hook
             (defun my-org-capture-inhibit-accidental-kill ()
               (user-error "Please don't just kill org capture buffers"))
             nil 'local)
   (add-hook 'kill-emacs-hook
             (defun my-org-capture-barf-for-left-capture-buffers ()
               (dolist (b (buffer-list))
                 (when (with-current-buffer b
                         (bound-and-true-p org-capture-mode))
                   (user-error "Please care about org capture buffer %s"
                               (buffer-name b))))))))

(add-hook 'org-capture-prepare-finalize-hook
          (defun my-org-capture-prepare-finalize-hook-fun ()
            (remove-hook 'kill-buffer-hook
                         'my-org-capture-inhibit-accidental-kill
                         'local)))
#+end_src

Would you consider to do something like this by default?

BTW, what about my question whether my original bug report can be
closed?

TIA,

Michael.

  reply	other threads:[~2019-12-16 23:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-13 21:48 Emacs bug 37890; killing capture buffer Michael Heerdegen
2019-12-14  5:05 ` Adam Porter
2019-12-15 22:31   ` Michael Heerdegen
2019-12-16 23:00     ` Michael Heerdegen [this message]
2019-12-17 17:40       ` Adam Porter
2019-12-17 18:24         ` Michael Heerdegen
2019-12-17 18:53           ` Adam Porter
2019-12-20  0:10             ` Michael Heerdegen
2019-12-18  1:20           ` Kyle Meyer
2019-12-18  2:16           ` Ihor Radchenko
2019-12-20  0:40             ` Michael Heerdegen
2019-12-18  0:07 ` Samuel Wales
2019-12-18  6:17   ` Fraga, Eric
2019-12-20  0:17   ` Michael Heerdegen

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=8736dj27wn.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=adam@alphapapa.net \
    --cc=emacs-orgmode@gnu.org \
    /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).