bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#33005: 27.0.50; Data loss with Gnus registry


From: Michael Heerdegen
Subject: bug#33005: 27.0.50; Data loss with Gnus registry
Date: Sun, 15 Dec 2019 18:07:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> > #+begin_src emacs-lisp
> > (setf (alist-get (regexp-quote ".gnus.registry.eieio") 
> > file-name-handler-alist)
> >       (defun my-gnus-registry-save-file-handler (operation &rest args)
> >         (pcase-let ((`(,_start ,_end ,filename . ,_rest) args))
> >           (when (eq operation 'write-region)
> >             (let ((buffer-backed-up nil)
> >                   (buffer-file-name filename)
> >                   (file-precious-flag t)
> >                   (kept-new-versions 300))
> >               (backup-buffer))))
> >         (let ((inhibit-file-name-handlers
> >                (cons 'my-gnus-registry-save-file-handler
> >                      inhibit-file-name-handlers))
> >               (inhibit-file-name-operation operation))
> >           (apply operation args))))
> > #+end_src
>
> Huh. Seems like a fair amount of work, but it's certainly low level!
> Nice to have it integrated into all of Emacs' regular save-file
> mechanisms.

Caveat: if anybody wants to use this: please specify a `testfn' argument
(e.g. `equal') of `alist-get' to prevent repeated pushing to
`file-name-handler-alist' when the code is loaded repeatedly (which is
the case for the gnus init file AFAIK).

Michael.





reply via email to

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