Giter Site home page Giter Site logo

Comments (1)

PythonNut avatar PythonNut commented on June 16, 2024

Partial solution:

(defun tramp-handle-make-backup-file-name (filename)
  "Like `make-backup-file-name' for Tramp files."
  (if (tramp-tramp-file-p filename)
      (with-parsed-tramp-file-name filename nil
        (let ((backup-directory-alist
	       (if tramp-backup-directory-alist
	           (mapcar
		    (lambda (x)
		      (cons
		       (car x)
		       (if (and (stringp (cdr x))
			        (file-name-absolute-p (cdr x))
			        (not (tramp-tramp-file-p (cdr x))))
		           (tramp-make-tramp-file-name v (cdr x))
		         (cdr x))))
		    tramp-backup-directory-alist)
	         backup-directory-alist)))
          (tramp-run-real-handler #'make-backup-file-name (list filename))))
    (make-backup-file-name filename)))

(defun backup-walker-get-sorted-backups (filename)
  "Return version sorted list of backups of the form:

  (prefix (list of suffixes))"
  ;; `make-backup-file-name' will get us the right directory for
  ;; ordinary or numeric backups.  It might create a directory for
  ;; backups as a side-effect, according to `backup-directory-alist'.
  (let* ((filename (file-name-sans-versions
                    (tramp-handle-make-backup-file-name (expand-file-name filename))))
         (file (file-name-nondirectory filename))
         (dir  (file-name-directory    filename))
         (comp (remove (concat file "~") (file-name-all-completions file dir)))
         (prefix-len (length file)))
    (cons filename (mapcar
                    (lambda (f)
                      (substring (cdr f) prefix-len))
                    (sort (mapcar (lambda (f)
                                    (cons (backup-walker-get-version f prefix-len)
                                          f))
                                  comp)
                          (lambda (f1 f2)
                            (not (< (car f1) (car f2)))))))))

from quark-emacs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.