aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/diff.el
diff options
context:
space:
mode:
authorRichard M. Stallman1992-07-27 07:58:52 +0000
committerRichard M. Stallman1992-07-27 07:58:52 +0000
commit37c51f00188c270b382b4d23165e5cd115edaeff (patch)
tree1a3a24928fa1cbe0c26a78a3173f4182394237fa /lisp/diff.el
parent3d7fc2fb35e1d3587b84c0a3e0e62174039da9c2 (diff)
downloademacs-37c51f00188c270b382b4d23165e5cd115edaeff.tar.gz
emacs-37c51f00188c270b382b4d23165e5cd115edaeff.zip
*** empty log message ***
Diffstat (limited to 'lisp/diff.el')
-rw-r--r--lisp/diff.el83
1 files changed, 36 insertions, 47 deletions
diff --git a/lisp/diff.el b/lisp/diff.el
index 6a15bbb7102..885287f0ead 100644
--- a/lisp/diff.el
+++ b/lisp/diff.el
@@ -95,54 +95,43 @@ and a backup file for NEW is the default for OLD."
95 old (expand-file-name old)) 95 old (expand-file-name old))
96 (diff-internal-diff "diff" (append diff-switches (list new old)) nil)) 96 (diff-internal-diff "diff" (append diff-switches (list new old)) nil))
97 97
98(defun diff-sccs (new) 98(defun diff-backup (file)
99 "Find and display the differences between OLD and SCCS files." 99 "Diff this file with its backup file or vice versa.
100 (interactive 100Uses the latest backup, if there are several numerical backups.
101 (let (newf) 101If this file is a backup, diff it with its original.
102 (list 102The backup file is the first file given to `diff'."
103 (setq newf (buffer-file-name) 103 (interactive "fDiff (file with backup): ")
104 newf (if (and newf (file-exists-p newf)) 104 (let (bak ori)
105 (read-file-name 105 (if (backup-file-name-p file)
106 (concat "Diff new file: (" 106 (setq bak file
107 (file-name-nondirectory newf) ") ") 107 ori (file-name-sans-versions file))
108 nil newf t) 108 (setq bak (or (diff-latest-backup-file file)
109 (read-file-name "Diff new file: " nil nil t)))))) 109 (error "No backup found for %s" file))
110 110 ori file))
111 (message "Comparing SCCS file %s..." new) 111 (diff bak ori)))
112 (setq new (expand-file-name new))
113 (if (file-exists-p (concat
114 (file-name-directory new)
115 "SCCS/s."
116 (file-name-nondirectory new)))
117 (diff-internal-diff "sccs"
118 (append '("diffs") diff-switches (list new))
119 2)
120 (error "%s does not exist"
121 (concat (file-name-directory new) "SCCS/s."
122 (file-name-nondirectory new)))))
123
124(defun diff-rcs (new)
125 "Find and display the differences between OLD and RCS files."
126 (interactive
127 (let (newf)
128 (list
129 (setq newf (buffer-file-name)
130 newf (if (and newf (file-exists-p newf))
131 (read-file-name
132 (concat "Diff new file: ("
133 (file-name-nondirectory newf) ") ")
134 nil newf t)
135 (read-file-name "Diff new file: " nil nil t))))))
136 112
137 (message "Comparing RCS file %s..." new) 113(defun diff-latest-backup-file (fn) ; actually belongs into files.el
138 (let* ((fullname (expand-file-name new)) 114 "Return the latest existing backup of FILE, or nil."
139 (rcsfile (concat (file-name-directory fullname) 115 ;; First try simple backup, then the highest numbered of the
140 "RCS/" 116 ;; numbered backups.
141 (file-name-nondirectory fullname) 117 ;; Ignore the value of version-control because we look for existing
142 diff-rcs-extension))) 118 ;; backups, which maybe were made earlier or by another user with
143 (if (file-exists-p rcsfile) 119 ;; a different value of version-control.
144 (diff-internal-diff "rcsdiff" (append diff-switches (list fullname)) 4) 120 (setq fn (expand-file-name fn))
145 (error "%s does not exist" rcsfile)))) 121 (or
122 (let ((bak (make-backup-file-name fn)))
123 (if (file-exists-p bak) bak))
124 (let* ((dir (file-name-directory fn))
125 (base-versions (concat (file-name-nondirectory fn) ".~"))
126 (bv-length (length base-versions)))
127 (concat dir
128 (car (sort
129 (file-name-all-completions base-versions dir)
130 ;; bv-length is a fluid var for backup-extract-version:
131 (function
132 (lambda (fn1 fn2)
133 (> (backup-extract-version fn1)
134 (backup-extract-version fn2))))))))))
146 135
147(defun diff-internal-diff (diff-command sw strip) 136(defun diff-internal-diff (diff-command sw strip)
148 (let ((buffer-read-only nil)) 137 (let ((buffer-read-only nil))