emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[ELPA-diffs] /srv/bzr/emacs/elpa r241: Update undo-tree to version 0.5.3


From: Toby S. Cubitt
Subject: [ELPA-diffs] /srv/bzr/emacs/elpa r241: Update undo-tree to version 0.5.3
Date: Wed, 18 Jul 2012 12:41:28 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 241
committer: Toby S. Cubitt <address@hidden>
branch nick: elpa
timestamp: Wed 2012-07-18 12:41:28 +0200
message:
  Update undo-tree to version 0.5.3
  
  * undo-tree.el: Cope gracefully with undo boundaries being deleted
    (cf. bug#11774). Allow customization of directory to which undo history is
    saved.
modified:
  packages/undo-tree/undo-tree.el
=== modified file 'packages/undo-tree/undo-tree.el'
--- a/packages/undo-tree/undo-tree.el   2012-05-24 08:49:41 +0000
+++ b/packages/undo-tree/undo-tree.el   2012-07-18 10:41:28 +0000
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2009-2012  Free Software Foundation, Inc
 
 ;; Author: Toby Cubitt <address@hidden>
-;; Version: 0.5.2
+;; Version: 0.5.3
 ;; Keywords: convenience, files, undo, redo, history, tree
 ;; URL: http://www.dr-qubit.org/emacs.php
 ;; Repository: http://www.dr-qubit.org/git/undo-tree.git
@@ -690,6 +690,14 @@
 
 ;;; Change Log:
 ;;
+;; Version 0.5.3
+;; * modified `undo-list-transfer-to-tree' and `undo-list-pop-changeset' to
+;;   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
 ;; * avoid error in `undo-tree-save-history' when undo is disabled in buffer
@@ -1010,6 +1018,31 @@
          '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.
@@ -1673,7 +1706,8 @@
               (undo-tree-move-GC-elts-to-pool (car p))
               (while (and discard-pos (integerp (car buffer-undo-list)))
                 (setq buffer-undo-list (cdr buffer-undo-list)))
-              (car buffer-undo-list))
+              (and (car buffer-undo-list)
+                   (not (eq (car buffer-undo-list) 'undo-tree-canary))))
         (setcdr p (list (pop buffer-undo-list)))
        (setq p (cdr p)))
       changeset)))
@@ -1711,7 +1745,8 @@
   (when (null buffer-undo-list)
     (setq buffer-undo-list '(nil undo-tree-canary)))
 
-  (unless (eq (cadr buffer-undo-list) 'undo-tree-canary)
+  (unless (or (eq (cadr buffer-undo-list) 'undo-tree-canary)
+             (eq (car buffer-undo-list) 'undo-tree-canary))
     ;; create new node from first changeset in `buffer-undo-list', save old
     ;; `buffer-undo-tree' current node, and make new node the current node
     (let* ((node (undo-tree-make-node nil (undo-list-pop-changeset)))
@@ -1727,7 +1762,8 @@
       ;; if no undo history has been discarded from `buffer-undo-list' since
       ;; last transfer, splice new tree fragment onto end of old
       ;; `buffer-undo-tree' current node
-      (if (eq (cadr buffer-undo-list) 'undo-tree-canary)
+      (if (or (eq (cadr buffer-undo-list) 'undo-tree-canary)
+             (eq (car buffer-undo-list) 'undo-tree-canary))
          (progn
            (setf (undo-tree-node-previous node) splice)
            (push node (undo-tree-node-next splice))
@@ -2974,9 +3010,18 @@
 
 
 
-(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)
@@ -3000,7 +3045,7 @@
       (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
@@ -3029,7 +3074,7 @@
   (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


reply via email to

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