From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Sharon Kimble Newsgroups: gmane.emacs.help Subject: Re: backup abbrev_defs Date: Thu, 19 Dec 2019 18:18:40 +0000 Message-ID: <87woas89hb.fsf@skimble.plus.com> References: <87sglnt4jx.fsf@skimble.plus.com> <875zihy135.fsf@web.de> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="211702"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Michael Heerdegen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 19 19:20:26 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ii0PS-000svS-58 for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Dec 2019 19:20:26 +0100 Original-Received: from localhost ([::1]:46286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ii0PO-0000lh-O9 for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Dec 2019 13:20:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45797) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ii0OC-0008Dl-LC for help-gnu-emacs@gnu.org; Thu, 19 Dec 2019 13:19:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ii0OA-0004CQ-Vq for help-gnu-emacs@gnu.org; Thu, 19 Dec 2019 13:19:08 -0500 Original-Received: from avasout02.plus.net ([212.159.14.17]:54635) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ii0OA-0003jk-89 for help-gnu-emacs@gnu.org; Thu, 19 Dec 2019 13:19:06 -0500 Original-Received: from london.london ([213.31.73.207]) by smtp with ESMTPA id i0O0iZPgi1R8pi0O1iRO2K; Thu, 19 Dec 2019 18:18:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019; t=1576779537; bh=x2ora18LSuB6vnJ6drBKB4bRX9Nq/Otek2bOn8bZ71Y=; h=From:To:Cc:Subject:References:Date:In-Reply-To; b=pSDqAp1Tq32fbHmvDJmoAZ5l8wVqvVB0Def0OVKQ0NTYeqKrUx6pgwYVhUObtcyN8 u0TvdomYR3YU5D9CQNi1TGd3T72jscBY2lxGoaH/+4EA2o7u8oMuqsYAUxOvBJEj9t w4rXfRrlRH+xgNz1fm8eSe93qKOt2qv2ygAZeqp3IP1zOQ/fS4ahpoTGMvwqq9QvUe UgKfHqlraO9Ih0C0/nBNkpj0UyxjVkT0d3KsIW6xV8GEypXHbvWj5VUUDxNqDveH87 LO0axQ8WRivvEJ3KNFlPeHTy+rSqfdvEeIFZXWpEZnOP+w1cWILwTNCIepv7ti7r/1 rxMSML/FdlLyw== X-Clacks-Overhead: "GNU Terry Pratchett" X-CM-Score: 0.00 X-CNFS-Analysis: v=2.3 cv=PtXtkDE3 c=1 sm=1 tr=0 a=EYS24WPHC3N1uGPJu5o6Ng==:117 a=EYS24WPHC3N1uGPJu5o6Ng==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=EBOSESyhAAAA:8 a=LlzXLoV6AAAA:8 a=bAHfVwKlAAAA:8 a=Ln3gWW83tCKJCt8R2VUA:9 a=lrrsY0MJmjtl7Ix9:21 a=GEv9PmVdDXvttTo0:21 a=36Ped_SIIogA:10 a=vAljq51LMRRZ-SzsBnIA:9 a=FfaGCDsud1wA:10 a=yJM6EZoI5SlJf8ks9Ge_:22 a=diwpeB1DDhFXqWA7J4Up:22 a=fjrkRJ71zQ2jzMzczd-K:22 a=pHzHmUro8NiASowvMSCR:22 a=nt3jZW36AmriUCFCBwmW:22 X-AUTH: skimble@:2500 In-Reply-To: <875zihy135.fsf@web.de> (Michael Heerdegen's message of "Sun, 15 Dec 2019 18:01:50 +0100") X-CMAE-Envelope: MS4wfBJ5bwZaJAQR8SDXLLCnjY2ao0HotpfOzLAeYPlTyaR1S8cK0p+WnPwDfZ7IuNt5vuJzddJSzHmw85/3ytpajuDexcye/oHS0x/aTttCfzCW/uLK5nnY zAG1+9WIw48WIKpt4st0QMXZ2gqD1opbNHcbC6e9OUtDah5tary6gHetJ8QA1pVbPdBLLy+f6GRuSA== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 212.159.14.17 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:122071 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Michael Heerdegen writes: > Sharon Kimble writes: > >> How can I backup my abbrev_defs file every time it is changed, just >> like any other file in emacs, please? And, logically, to the same >> place, my '~/.emacs.d/backups' directory? > > Recently I had a similar requirement for the Gnus Registry save file. > Like `write-abbrev-file' saving is done there with a `write-region' call > from within a temporary helper buffer so no backups are created > automatically. > > My solution (canonical I think) was to register a file name handler for > that save file and the `write-region` operation. For information about > `file-name-handler-alist' see > > (info "(elisp) Magic File Names") > > Code: > > #+begin_src emacs-lisp > (setf (alist-get (regexp-quote ".gnus.registry.eieio") > file-name-handler-alist nil nil #'equal) > (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)))) > ;; Invoke original handler > (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 > > It should be obvious how to translate it for your file. > > The backup is created with `backup-buffer' which doesn't refer to the > temp buffer but to the file named by `buffer-file-name' (thus the > let-binding). > > Since `backup-buffer' is a high-level function, all your settings > concerning backup creation are respected. To control where the backup > is created `backup-directory-alist' is consulted - you can also add a > binding in the above defun of course. The `kept-new-versions' binding > to 300 I use above is only because Gnus registry saving is currently > still a bit buggy and I want to force the creation of so many backup > files that I can be sure I don't lose anything even if I notice problems > after a longer time has passed. > > I don't know if the above solution is the simplest one btw, it's just > the one that came to my mind at first. > Thanks for replying Michael. I've been trying out various things, and I've finally settled on rewriting my 'abbrev_defs' code, and also backing up my emacs to my server hourly, as well as with rsnapshot every 3 hours. My code is now - #+BEGIN_SRC emacs-lisp ;; turn on abbrev mode globally (setq-default abbrev-mode t) (setq save-abbrevs 'silently) (setq abbrev-file-name "~/.emacs.d/abbrev_defs") (read-abbrev-file "~/.emacs.d/abbrev_defs") (abbrev-table-put global-abbrev-table :case-fixed t) #+END_SRC I did try adapting your code above but wasn't able to get it to work successfully, sorry! Thanks Sharon. =2D-=20 A taste of linux =3D http://www.sharons.org.uk DrugFacts =3D https://www.drugfacts.org.uk Debian 10.1, fluxbox 1.3.7, emacs 26.3, org 9.3 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEELSc/6QwVBIYugJDbNoGAGQr4g1sFAl37vwIACgkQNoGAGQr4 g1uFAw/+LCOwXP+QVcRzV7PrfdouNmW5b9Ljh8f12HuthzNp5qQfuXUEFoO3G33W lzapVdo/66rCrwVXQfzhNNep3ZKaoGV3MFgI+2hBpR5dKL9gm5doO1qqtXpHLlUQ n+lKo2+4j1qyelR7uKw80jvgS2qawRy96wo89iaS9Fxx1QgL10CFDs+VLaKeV9Sr I1JRR7xu4qX5+Deh6/Yz3tHVQwJ2v38zkn6WNivGStWIBeWn4q9XqKPM+WrdYu8z JXjT3Ho2dX6M9qG9VzAqyDKtUzydY7B+oWfa+3x3sWeGevPBePdh8tdRO0cMXgFT 8YiXk47I+Md/1N2PjU611vkMGLorK6xDlEz3SAl6R9eVV/uOyXDAhKLyRjIgMsoU u6PKg8afiY/7reoXLM3b7amGSh50wpBg31b4HNf2LecOE0n8stZro16nOBlKLjWl 8qzefciMWLtDJjBABv5PrIxmax//ULDXeA9g32s4IvLeaGCDSUAe+FMsHSsTvBjE wrCcLcJ5jWK10QMQQRrMMrS1HxLGzjx3nXbbIbQVDGrf3aBwsbr9MRqFfHvgNzd9 I+uDZt+4+zxzhuUO+dUsqmpMl07/qT7ybKkXbQ/TqMskHcY1J4qME8YV+BCQCFGy mn6WflOTdk92ChUIYty98oQ0khp19mbEROu0svemTtJXJlg32rI= =kJPP -----END PGP SIGNATURE----- --=-=-=--