help-gnu-emacs
[Top][All Lists]
Advanced

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

diff-autosaved


From: Andreas Röhler
Subject: diff-autosaved
Date: Sat, 30 Apr 2011 10:57:11 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9

Hi,

occassionally want to compare a file with its auto-saved version.

Couldn't find a function doing this.
Tweaked diff-backup for the purpose.

The result:


(defun diff-autosaved (&optional switches)
  "Diff this file with its auto-saved version or vice versa.
With prefix arg, prompt for diff switches."
  (interactive (list (diff-switches)))
  (let ((dir default-directory)
(file (file-name-nondirectory (replace-regexp-in-string "#" "" (buffer-file-name))))
        bak ori)
    (if (string-match "^#" file)
        (setq bak file
              ori (replace-regexp-in-string "#" "" file))
      (setq bak (concat "#" file "#")
            ori file))
    (setq bak (concat dir bak))
    (setq ori (concat dir ori))
    (diff bak ori switches)))


Comments welcome.

Andreas

--
https://code.launchpad.net/~a-roehler/python-mode/components-python-mode
https://code.launchpad.net/s-x-emacs-werkstatt/



reply via email to

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