[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/add-vdiff 7c87360 244/258: vdiff: Add vdiff-current-file
From: |
Justin Burkett |
Subject: |
[elpa] scratch/add-vdiff 7c87360 244/258: vdiff: Add vdiff-current-file |
Date: |
Wed, 17 May 2017 08:14:01 -0400 (EDT) |
branch: scratch/add-vdiff
commit 7c87360194dd171674c5ecdddc9466beba5268ef
Author: Justin Burkett <address@hidden>
Commit: Justin Burkett <address@hidden>
vdiff: Add vdiff-current-file
---
vdiff.el | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/vdiff.el b/vdiff.el
index 9761aeb..4607274 100644
--- a/vdiff.el
+++ b/vdiff.el
@@ -1755,6 +1755,49 @@ you will be asked to select two files."
(find-file-noselect file-c)
on-quit))
+;;;###autoload
+(defun vdiff-current-file ()
+ "Start vdiff between current buffer and its file on disk.
+This command can be used instead of `revert-buffer'. If there is
+nothing to revert then this command fails."
+ (interactive)
+ ;; Taken from `ediff-current-file'
+ (unless (or (not (eq revert-buffer-function 'revert-buffer--default))
+ (not (eq revert-buffer-insert-file-contents-function
+ 'revert-buffer-insert-file-contents--default-function))
+ (and buffer-file-number
+ (or (buffer-modified-p)
+ (not (verify-visited-file-modtime
+ (current-buffer))))))
+ (error "Nothing to revert"))
+ (let* ((auto-save-p (and (recent-auto-save-p)
+ buffer-auto-save-file-name
+ (file-readable-p buffer-auto-save-file-name)
+ (y-or-n-p
+ "Buffer has been auto-saved recently. Compare
with auto-save file? ")))
+ (file-name (if auto-save-p
+ buffer-auto-save-file-name
+ buffer-file-name))
+ (revert-buf-name (concat "FILE=" file-name))
+ (revert-buf (get-buffer revert-buf-name))
+ (current-major major-mode))
+ (unless file-name
+ (error "Buffer does not seem to be associated with any file"))
+ (when revert-buf
+ (kill-buffer revert-buf)
+ (setq revert-buf nil))
+ (setq revert-buf (get-buffer-create revert-buf-name))
+ (with-current-buffer revert-buf
+ (insert-file-contents file-name)
+ ;; Assume same modes:
+ (funcall current-major))
+ (vdiff-buffers revert-buf (current-buffer)
+ nil
+ (lambda (rbuf cbuf)
+ (when (buffer-live-p rbuf)
+ (kill-buffer rbuf)))
+ t)))
+
;; (defvar vdiff-quit-hook nil)
(defun vdiff-quit ()
- [elpa] scratch/add-vdiff 816fe2a 182/258: Fix subtraction string width, (continued)
- [elpa] scratch/add-vdiff 816fe2a 182/258: Fix subtraction string width, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 582d13d 180/258: Fix compiler warnings, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff cd9dad4 191/258: Fix refresh function call sequence, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 2847cd6 183/258: Add callback support on quit, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 90f81f0 175/258: Make sure hook functions execute in vdiff bufs, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 2d48cb5 229/258: vdiff-magit: Simplify resolve, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff c31755a 220/258: vdiff-magit: Port show stash, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff cfb90d7 233/258: vdiff-magit: Add note to README, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff f5fdcaa 241/258: vdiff-magit: Simplify exit from stage, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff e8d3d26 236/258: vdiff-magit: Try to switch resolve functions gracefully, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 7c87360 244/258: vdiff: Add vdiff-current-file,
Justin Burkett <=
- [elpa] scratch/add-vdiff 8b32329 245/258: vdiff: Filter out killed buffers better, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 8aa5c45 250/258: vdiff-magit: Fix paren, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 466b852 173/258: Fix subtraction overlay addition, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff f3b6cec 179/258: Center on start, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 667a7e4 144/258: Generalize data structures to prepare for diff3, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 059d288 208/258: Update gitignore, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff cfad650 207/258: Provide missing function for emacs-nox users, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff e567468 221/258: vdiff-magit: Port show-working-tree, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 30b0f9c 213/258: Add vdiff-magit.el with two functions, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 64430c3 215/258: Cleanup merge, Justin Burkett, 2017/05/17