emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Emacs bug 37890; killing capture buffer


From: Michael Heerdegen
Subject: Re: Emacs bug 37890; killing capture buffer
Date: Tue, 17 Dec 2019 00:00:08 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Michael Heerdegen <address@hidden> 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 via email to

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