[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/undo-tree 17568c3 113/195: Allow undo history save dire
From: |
Stefan Monnier |
Subject: |
[elpa] externals/undo-tree 17568c3 113/195: Allow undo history save directory to be customized. |
Date: |
Sat, 28 Nov 2020 13:41:33 -0500 (EST) |
branch: externals/undo-tree
commit 17568c3232d8e23f635a1a489443744b4cef756f
Author: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Commit: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Allow undo history save directory to be customized.
New undo-tree-history-directory-alist customization option does for undo
history files what backup-directory-alist does for backup file.
(Does not cope with MS DOS systems without long filenames.)
---
undo-tree.el | 46 +++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 41 insertions(+), 5 deletions(-)
diff --git a/undo-tree.el b/undo-tree.el
index b650233..83c1537 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -695,6 +695,8 @@
;; cope better if undo boundary before undo-tree-canary is missing
;; (e.g. org-mode's `org-self-insert-cluster-for-undo' removes this undo
;; boundary)
+;; * added `undo-tree-history-directory-alist', the undo history file analogue
+;; of `backup-directory-alist'
;;
;; Version 0.5.2
;; * added `~' to end of default history save-file name
@@ -1016,6 +1018,31 @@ customize."
'boolean))
+(defcustom undo-tree-history-directory-alist nil
+ "Alist of filename patterns and undo history directory names.
+Each element looks like (REGEXP . DIRECTORY). Undo history for
+files with names matching REGEXP will be saved in DIRECTORY.
+DIRECTORY may be relative or absolute. If it is absolute, so
+that all matching files are backed up into the same directory,
+the file names in this directory will be the full name of the
+file backed up with all directory separators changed to `!' to
+prevent clashes. This will not work correctly if your filesystem
+truncates the resulting name.
+
+For the common case of all backups going into one directory, the
+alist should contain a single element pairing \".\" with the
+appropriate directory name.
+
+If this variable is nil, or it fails to match a filename, the
+backup is made in the original file's directory.
+
+On MS-DOS filesystems without long names this variable is always
+ignored."
+ :group 'undo-tree
+ :type '(repeat (cons (regexp :tag "Regexp matching filename")
+ (directory :tag "Undo history directory name"))))
+
+
(defcustom undo-tree-visualizer-relative-timestamps t
"When non-nil, display times relative to current time
when displaying time stamps in visualizer.
@@ -2983,9 +3010,18 @@ Argument is a character, naming the register."
-(defun undo-tree-make-history-save-file-name ()
- (concat (file-name-directory (buffer-file-name))
- "." (file-name-nondirectory (buffer-file-name)) ".~undo-tree~"))
+(defun undo-tree-make-history-save-file-name (file)
+ "Create the undo history file name for FILE.
+Normally this is the file's name with `.' prepended and
+`~undo-tree~' appended.
+
+A match for FILE is sought in `undo-tree-history-directory-alist';
+see the documentation of that variable. If the directory for the
+backup doesn't exist, it is created."
+ (let* ((backup-directory-alist undo-tree-history-directory-alist)
+ (name (make-backup-file-name-1 file)))
+ (concat (file-name-directory name) "." (file-name-nondirectory name)
+ ".~undo-tree~")))
(defun undo-tree-save-history (&optional filename overwrite)
@@ -3009,7 +3045,7 @@ without asking for confirmation."
(unless filename
(setq filename
(if buffer-file-name
- (undo-tree-make-history-save-file-name)
+ (undo-tree-make-history-save-file-name buffer-file-name)
(expand-file-name (read-file-name "File to save in: ") nil))))
(when (or (not (file-exists-p filename))
overwrite
@@ -3038,7 +3074,7 @@ signaling an error if file is not found."
(unless filename
(setq filename
(if buffer-file-name
- (undo-tree-make-history-save-file-name)
+ (undo-tree-make-history-save-file-name buffer-file-name)
(expand-file-name (read-file-name "File to load from: ") nil))))
;; attempt to read undo-tree from FILENAME
- [elpa] externals/undo-tree adca566 094/195: Allow undo-tree-visualizer-diff variable to be customized., (continued)
- [elpa] externals/undo-tree adca566 094/195: Allow undo-tree-visualizer-diff variable to be customized., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree da54994 117/195: When discarding root, erase previous link of new root., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 4c6280b 101/195: Fixed bug preventing registers being displayed in visualizer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 3ab4581 107/195: Avoid error if point was moved manually in visualizer selection mode, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 824b904 129/195: Preparatory changes for lazy tree drawing., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 40c7065 108/195: Added undo-tree-visualizer-abort command, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 107d4c8 102/195: Allow visualizer to display relative timestamps., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 1561d8f 099/195: Preserve timestamps when generating diff for visualizer diff view., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 08db836 123/195: Fix bug in undo-tree-visualizer-select-left/right., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 6e5cc0f 104/195: Generate history save filename using a function, to allow customization., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 17568c3 113/195: Allow undo history save directory to be customized.,
Stefan Monnier <=
- [elpa] externals/undo-tree 965650c 127/195: Highlight node in visualizer corresponding to unmodified buffer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree ca9ec7b 105/195: Clear visualizer data / kill visualizer before saving history., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 270bc25 110/195: Added `~' to end of default history save-file name., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree d5a6148 120/195: Don't try to auto-save undo history if undo is disabled in buffer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree cfc036a 133/195: Fix undo-tree-redo to avoid corrupting undo-tree state if redoing fails., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree bdfd73f 132/195: Ignore bogus buffer modification entries in undo changesets., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 6e0775d 139/195: Use define-derived-mode and define-minor-mode for undo-tree visualizer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree d6fa2e7 152/195: Reinstate accidentally deleted file header., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 8afead1 162/195: Add Maintainer line to package headers., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree e9a9102 164/195: Throw error if interactive commands called outside undo-tree-mode., Stefan Monnier, 2020/11/28