Thanks Ramon,

Regarding your question, probably the bug is related to running a for
with all the buffers that are open. To get what you want you can try
something creating a minor mode for gpg files and adding a hook that
adds the buffer name of the gpg file that you open to a list of buffers
to kill:

  #+BEGIN_SRC emacs-lisp
    (define-minor-mode gpg-killing-mode
      "A mode to kill gpg files"
      :after-hook 
      (add-to-list 'gpg-buffers (buffer-name)))

    (add-to-list 'auto-mode-alist '("\\.gpg$" . gpg-killing-mode))

    (setq gpg-buffers nil)

    (run-at-time t 120 '(lambda () 
                         (mapcar 'kill-buffer gpg-buffers)
                         (setq gpg-buffers nil)))
      
  #+END_SRC

Instead killing all at the same time, I would probably kill each one
after a certain time, to avoid opening a file and have it right away
killed it was close to the end of the 2 min cycle:

  #+BEGIN_SRC emacs-lisp
    (define-minor-mode gpg-killing-mode
      "A mode to kill gpg files"
      :after-hook 
      (progn
        (setq gpg-buffers (append gpg-buffers (list (buffer-name))))
        (run-at-time 120 nil '(lambda () 
                                (kill-buffer (car gpg-buffers))
                                (setq gpg-buffers (cdr gpg-buffers))))))

    (add-to-list 'auto-mode-alist '("\\.gpg$" . gpg-killing-mode))  

    (setq gpg-buffers nil)
  #+END_SRC

Best,

Jorge.


Reply via email to