From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nick Helm Newsgroups: gmane.emacs.help Subject: Changing name format for backup files Date: Tue, 12 Jan 2016 11:21:33 +1300 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1452552970 29923 80.91.229.3 (11 Jan 2016 22:56:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 11 Jan 2016 22:56:10 +0000 (UTC) To: Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jan 11 23:56:02 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aIlNZ-0002yS-MS for geh-help-gnu-emacs@m.gmane.org; Mon, 11 Jan 2016 23:56:01 +0100 Original-Received: from localhost ([::1]:57139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIlNZ-0007EV-5a for geh-help-gnu-emacs@m.gmane.org; Mon, 11 Jan 2016 17:56:01 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51299) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIlNN-0007EO-QH for help-gnu-emacs@gnu.org; Mon, 11 Jan 2016 17:55:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIlNJ-0001rm-Kc for help-gnu-emacs@gnu.org; Mon, 11 Jan 2016 17:55:49 -0500 Original-Received: from mail-hk2apc01on0135.outbound.protection.outlook.com ([104.47.124.135]:24096 helo=APC01-HK2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIlNI-0001p3-UM for help-gnu-emacs@gnu.org; Mon, 11 Jan 2016 17:55:45 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=nick@tenpoint.co.nz; Original-Received: from nitrogen.local (125.239.120.90) by MEXPR01MB0278.ausprd01.prod.outlook.com (10.162.52.150) with Microsoft SMTP Server (TLS) id 15.1.361.13; Mon, 11 Jan 2016 22:21:41 +0000 User-agent: mu4e 0.9.15; emacs 24.5.1 X-Originating-IP: [125.239.120.90] X-ClientProxiedBy: SYXPR01CA0010.ausprd01.prod.outlook.com (25.162.69.20) To MEXPR01MB0278.ausprd01.prod.outlook.com (25.162.52.150) X-Microsoft-Exchange-Diagnostics: 1; MEXPR01MB0278; 2:br4K4VqpLzBKP/hdMjCqivcEsEzJOb0Yf9aoW85gD5AlMEbgIcXHTasAbCoQlLVaZtvgIyYZge6HAkMirNw6ZX0pqyAn38FRh5pIG6eZn4YKebcK5ORH2JVLxv+LvXbhyhHDtctvOf926CFMTWM0TQ==; 3:Tp90bCpI/Vm7p23i0Whj3YCpaXKG54V1tL0/Dry9doz6PhOzss3oto4vq/Basw4ruUwzrE8NqC6IKTOHhjteNyB9Q0GjTLIfqHIDg+/bFEkqO1hL7+6FbW0Wzq+s5v+E; 25:FpBwr2Yk7KB24IZXCwGOwQ/UHHPj3KJDNYS0pwCX2h+dhGwtadtCfZ78PmfZ40mGCOJe8iB+5k4aWbDBS2PFVH4A2Gbkgzzt4JGXdx1ZWg55sVZTmVa6Kn56wfgfmmO/DrFOvBH3Nm+JTt7/yB7ATg6APVMKuLksy2LDfBP5PIgfKRy2T/6aBZPBzm4lC2j9rlXLBMwz1cx0skmg8rSvh2OuFGpPuXoF5KiR8og5o0UhcA3Q7B3NMJTFvFzpWZ7P; 4:upmZAJQ3tpymQRgAg8R0I7yDVHSPBr3rQfr7Cy+SQQJXCsBTY91qJCaaoh/kqKcULrXv2jo2IN8e8yh4TJnmMeACXDkAZ6sDG/4GOfSwzcNoC01SshVyAtwRL/Md2ksoe7OjtWI4mwrwnZPaH6YDDzgmx2Ynp1j1H3IdXAhIjq+gilWpIN1/R6FJ9Z1Pk4TQC4oTMdoXTe6wztxVgMy3upXUTgBv7N4mix9/I73Fbe69cKKC1v2RbOEFhGE0rknBEQ5Aiy9IguVinbjIF7ByvaZ1GqrohBB6CNqXX X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:MEXPR01MB0278; X-MS-Office365-Filtering-Correlation-Id: a11a834f-392d-4d33-13ac-08d31ad594ce X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(2401047)(5005006)(8121501046)(520078)(10201501046)(3002001); SRVR:MEXPR01MB0278; BCL:0; PCL:0; RULEID:; SRVR:MEXPR01MB0278; X-Forefront-PRVS: 0818724663 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(164054003)(87976001)(586003)(450100001)(4001350100001)(83506001)(189998001)(5004730100002)(33646002)(86362001)(6116002)(122386002)(5001960100002)(107886002)(48376002)(3846002)(42186005)(40100003)(229853001)(50986999)(54356999)(110136002)(81156007)(2351001)(50466002)(77096005)(74482002)(5008740100001)(101416001)(105586002)(1096002)(2906002)(36756003)(5003940100001)(47776003)(92566002)(66066001)(106356001)(97736004); DIR:OUT; SFP:1102; SCL:1; SRVR:MEXPR01MB0278; H:nitrogen.local; FPR:; SPF:None; PTR:InfoNoRecords; A:3; MX:3; LANG:en; Received-SPF: None (protection.outlook.com: tenpoint.co.nz does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MEXPR01MB0278; 23:7RH4Vy19iIALm2gvVk+hYMnpRhbZ6UAlFoOBPquuY?= =?us-ascii?Q?niXgAg/QvumHtiYXe+ZRdCnxKxV54mnY/TXVoWIHtf+ymXhnJqng2yySo3GF?= =?us-ascii?Q?7a0sqjYGxAzfkRRqucLuMPiLYxkI132SFwDyBgo9CT+eCqtFrte44uYRUwXy?= =?us-ascii?Q?oeePAy67cozlBoHzkT3kZ66xvSP5+SJhIQp+hKW7yeUHe9Ux4cJSoleD0ziM?= =?us-ascii?Q?ilTQ/RgkYih3jxx9+ii8BsG8DYdGx8NlyUqypohe8DEVHRHYLgUj2BeN/NHR?= =?us-ascii?Q?J66yU+YAC4u9UVJWP2I0OCu8rdSYuNOTZnrdD0Q8dLdfekCqWYW5FJC886St?= =?us-ascii?Q?2p3vGHXqjqjxkKgIsCqisgQ3xOSjcsJhtO9ivHBGfzPK6E46RHsoE/wXnJNe?= =?us-ascii?Q?HNuhirH8XxD1VrJeLtKoBpINA0hf6khjnmwg+3vM21SrMlZB5BTzH2YXLm1m?= =?us-ascii?Q?JMgFzfqB3A9135RrWjyePINf/25pApiyn1bwTKGKKhQ+W542ObXILpWVrkAB?= =?us-ascii?Q?ylBv4fJTu5MqNznFivRIrKVEQMms4IDdZYrwsSULyiEfR8lSY66OhyX6lQDR?= =?us-ascii?Q?SeV1UQl13ovawXmN7gqVacn6V8hHkXorV6/xLaiB4pplrcbRt+D51Qa2bw7R?= =?us-ascii?Q?uS2 X-Microsoft-Exchange-Diagnostics: 1; MEXPR01MB0278; 5:I5oCEyxDB6pYgjm9ExBqmgrmgVuETGBalsNDfrbpczMOysFURBgQKEseZufDzRJVm1WpDJyolLRgftNZ71zuJ0+lapDJfrLuHb2sYdE4kXlmnSPAHMEZQGMrKvgjPt9PHhyVAffi0TwQvXuNy1HiWw==; 24:UwQ5d9jqvI6in7hyiu8iVhbZ+kPujdyy69CdmpktP2Clqe0t4JgvUQkGoYA8sHFkF/7h8HuwWvVunFddMDF1WJjZi96njjcE7eBhJHvsNHk= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: tenpoint.co.nz X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2016 22:21:41.4542 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: MEXPR01MB0278 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.124.135 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:108697 Archived-At: I like to keep my emacs backup files in the same directory as the file I'm editing, but I want the backups to be hidden in the GUI by default. I achieve this by adding a prefix dot to the backup filenames by tweaking `make-backup-file-name-1' like this: (defun make-backup-file-name-1 (file) "Subroutine of `make-backup-file-name--default-function'. The function `find-backup-file-name' also uses this." (let ((alist backup-directory-alist) elt backup-directory abs-backup-directory) (while alist (setq elt (pop alist)) (if (string-match (car elt) file) (setq backup-directory (cdr elt) alist nil))) ;; If backup-directory is relative, it should be relative to the ;; file's directory. By expanding explicitly here, we avoid ;; depending on default-directory. (if backup-directory (setq abs-backup-directory (expand-file-name backup-directory (file-name-directory file)))) (if (and abs-backup-directory (not (file-exists-p abs-backup-directory))) (condition-case nil (make-directory abs-backup-directory 'parents) (file-error (setq backup-directory nil abs-backup-directory nil)))) (if (null backup-directory) ;; -----------8<------------------CHANGE HERE-----------------8<------------- ;; file (let* ((file-path (file-name-directory file)) (file-name (file-name-nondirectory file))) (concat file-path "." file-name)) ;; -----------8<------------------CHANGE HERE-----------------8<------------- (if (file-name-absolute-p backup-directory) (progn (when (memq system-type '(windows-nt ms-dos cygwin)) ;; Normalize DOSish file names: downcase the drive ;; letter, if any, and replace the leading "x:" with ;; "/drive_x". (or (file-name-absolute-p file) (setq file (expand-file-name file))) ; make defaults explicit ;; Replace any invalid file-name characters (for the ;; case of backing up remote files). (setq file (expand-file-name (convert-standard-filename file))) (if (eq (aref file 1) ?:) (setq file (concat "/" "drive_" (char-to-string (downcase (aref file 0))) (if (eq (aref file 2) ?/) "" "/") (substring file 2))))) ;; Make the name unique by substituting directory ;; separators. It may not really be worth bothering about ;; doubling `!'s in the original name... (expand-file-name (subst-char-in-string ?/ ?! (replace-regexp-in-string "!" "!!" file)) backup-directory)) (expand-file-name (file-name-nondirectory file) (file-name-as-directory abs-backup-directory)))))) I do something similar to `make-auto-save-file-name' to achieve the same result for auto save files. Redefining core functions seems like a pretty heavy handed approach to the problem though. Is there better way to achieve the same result? Or perhaps there's a user option I missed in the manual? Thanks, Nick