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

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

[elpa] scratch/add-vdiff 027ff92 4/4: Merge commit '702f27b5092ea0cea09c


From: Justin Burkett
Subject: [elpa] scratch/add-vdiff 027ff92 4/4: Merge commit '702f27b5092ea0cea09cf9642739df34d39a0cbe' into scratch/add-vdiff
Date: Wed, 17 May 2017 15:59:02 -0400 (EDT)

branch: scratch/add-vdiff
commit 027ff922bb393e1eaf352e87609340c14d1d9c16
Merge: 5af1640 702f27b
Author: Justin Burkett <address@hidden>
Commit: Justin Burkett <address@hidden>

    Merge commit '702f27b5092ea0cea09cf9642739df34d39a0cbe' into 
scratch/add-vdiff
---
 packages/vdiff/README.org     |  78 +++------
 packages/vdiff/vdiff-magit.el | 376 ------------------------------------------
 packages/vdiff/vdiff.el       |   8 +-
 3 files changed, 25 insertions(+), 437 deletions(-)

diff --git a/packages/vdiff/README.org b/packages/vdiff/README.org
index 42e2463..1ba7494 100644
--- a/packages/vdiff/README.org
+++ b/packages/vdiff/README.org
@@ -11,33 +11,33 @@ A tool like vimdiff for Emacs
    - [[#screenshot][Screenshot]]
    - [[#installation-and-usage][Installation and Usage]]
    - [[#hydra][Hydra]]
-   - [[#magit-integration][Magit integration]]
    - [[#further-customization][Further customization]]
 
 ** Introduction
 
-vdiff compares two or three buffers on the basis of the output from the diff
-tool. The buffers are kept synchronized so that as you move through one of the
-buffers the top of the active buffer aligns with the corresponding top of the
-other buffer(s). This is similar to how ediff works, but in ediff you use a
-third "control buffer" to move through the diffed buffers. The key difference 
is
-that in vdiff you are meant to actively edit one of the buffers and the display
-will update automatically for the other buffer. Similar to ediff, vdiff 
provides
-commands to "send" and "receive" hunks from one buffer to the other as well as
-commands to traverse the diff hunks, which are useful if you are trying to 
merge
-changes. In contrast to ediff, vdiff also provides folding capabilities to fold
-sections of the buffers that don't contain changes. This folding occurs
-automatically. Finally, you are encouraged to bind a key to `vdiff-hydra/body',
-which will use hydra.el (in ELPA) to create a convenient transient keymap
-containing most of the useful vdiff commands.
-
-This functionality is all inspired by (but not equivalent to) the vimdiff tool
-from vim.
-
-Contributions and suggestions are very welcome.
+   vdiff compares two or three buffers on the basis of the output from the diff
+   tool. The buffers are kept synchronized so that as you move through one of
+   the buffers the top of the active buffer aligns with the corresponding top 
of
+   the other buffer(s). This is similar to how ediff works, but in ediff you 
use
+   a third "control buffer" to move through the diffed buffers. The key
+   difference is that in vdiff you are meant to actively edit one of the 
buffers
+   and the display will update automatically for the other buffer. Similar to
+   ediff, vdiff provides commands to "send" and "receive" hunks from one buffer
+   to the other as well as commands to traverse the diff hunks, which are 
useful
+   if you are trying to merge changes. In contrast to ediff, vdiff also 
provides
+   folding capabilities to fold sections of the buffers that don't contain
+   changes. This folding occurs automatically. Finally, you are encouraged to
+   bind a key to `vdiff-hydra/body', which will use hydra.el (in ELPA) to 
create
+   a convenient transient keymap containing most of the useful vdiff commands.
+
+   This functionality is all inspired by (but not equivalent to) the vimdiff
+   tool from vim.
+
+   Contributions and suggestions are very welcome.
 
 ** Recent (Significant) Changes
-   - [2017-02-01] Added magit integration functions in =vdiff-magit.el=. See 
[[#magit-integration][Magit integration]].
+   - [2017-05-17] Split =vdiff-magit.el= into 
[[https://github.com/justbur/emacs-vdiff-magit][separate repository]]. 
+   - [2017-02-01] Added magit integration functions in =vdiff-magit.el=.
    - [2016-07-25] Added three-way diff support. See =vdiff-buffers3= and 
=vdiff-files3=.
    
 ** Screenshot
@@ -159,42 +159,6 @@ map. Bind =vdiff-hydra/body= directly to customize this 
key binding.
 
 [[file:img/hydra.png]]
 
-** Magit integration
-   #+NAME: #magit-integration
-
-Loading =vdiff-magit= will pull in functions that will allow vdiff to be used
-with [[https://github.com/magit/magit][magit]]. In order to use these 
functions you need to call the vdiff functions
-instead of the magit-ediff ones. Here is a very basic setup which replaces the
-basic ediff key bindings in magit.
-
-#+BEGIN_SRC emacs-lisp
-  (require 'vdiff-magit)
-  (define-key magit-mode-map "e" 'vdiff-magit-dwim)
-  (define-key magit-mode-map "E" 'vdiff-magit-popup)
-  (setcdr (assoc ?e (plist-get magit-dispatch-popup :actions))
-          '("vdiff dwim" 'vdiff-magit-dwim))
-  (setcdr (assoc ?E (plist-get magit-dispatch-popup :actions))
-          '("vdiff popup" 'vdiff-magit-popup))
-  ;; This flag will default to using ediff for merges. vdiff-magit does not yet
-  ;; support 3-way merges. Please see the docstring of this variable for more
-  ;; information
-  ;; (setq vdiff-magit-use-ediff-for-merges nil)
-
-  ;; Whether vdiff-magit-dwim runs show variants on hunks.  If non-nil,
-  ;; vdiff-magit-show-staged or vdiff-magit-show-unstaged are called based on 
what
-  ;; section the hunk is in.  Otherwise, vdiff-magit-dwim runs 
vdiff-magit-stage
-  ;; when point is on an uncommitted hunk.
-  ;; (setq vdiff-magit-dwim-show-on-hunks nil)
-
-  ;; Whether vdiff-magit-show-stash shows the state of the index.
-  ;; (setq vdiff-magit-show-stash-with-index t)
-
-  ;; Only use two buffers (working file and index) for vdiff-magit-stage
-  ;; (setq vdiff-magit-stage-is-2way nil)
-#+END_SRC
-
-Please note that this is a new feature and probably contains some bugs, so use
-it with caution and please report oddities.
 
 ** Further customization
    
diff --git a/packages/vdiff/vdiff-magit.el b/packages/vdiff/vdiff-magit.el
deleted file mode 100644
index 241df34..0000000
--- a/packages/vdiff/vdiff-magit.el
+++ /dev/null
@@ -1,376 +0,0 @@
-;;; vdiff-magit.el --- magit integration for vdiff -*- lexical-binding: t; -*-
-
-;; Copyright (C) 2017 Free Software Foundation, Inc.
-
-;; Author: Justin Burkett <address@hidden>
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; magit integration for vdiff
-
-;;; Code:
-
-(require 'vdiff)
-(require 'magit)
-(require 'magit-ediff)
-
-(defgroup vdiff-magit nil
-  "vdiff support for Magit."
-  :group 'magit-extensions)
-
-(defcustom vdiff-magit-dwim-show-on-hunks nil
-  "Whether `vdiff-magit-dwim' runs show variants on hunks.
-If non-nil, `vdiff-magit-show-staged' or
-`vdiff-magit-show-unstaged' are called based on what section the
-hunk is in.  Otherwise, `vdiff-magit-dwim' runs
-`vdiff-magit-stage' when point is on an uncommitted hunk."
-  ;; :package-version '(magit . "2.2.0")
-  :group 'vdiff-magit
-  :type 'boolean)
-
-(defcustom vdiff-magit-show-stash-with-index t
-  "Whether `vdiff-magit-show-stash' shows the state of the index.
-
-If non-nil, use a third vdiff buffer to distinguish which changes
-in the stash were staged.  In cases where the stash contains no
-staged changes, fall back to a two-buffer vdiff.
-
-More specificaly, a stash is a merge commit, address@hidden, with
-potentially three parents.
-
-* address@hidden represents the HEAD commit at the time the stash
-  was created.
-
-* address@hidden records any changes that were staged when the stash
-  was made.
-
-* address@hidden, if it exists, contains files that were untracked
-  when stashing.
-
-If this option is non-nil, `vdiff-magit-show-stash' will run
-vdiff on a file using three buffers: one for address@hidden, another
-for address@hidden, and a third for address@hidden
-
-Otherwise, vdiff uses two buffers, comparing
address@hidden@{N}.  Along with any unstaged changes, changes
-in the index commit, address@hidden, will be shown in this
-comparison unless they conflicted with changes in the working
-tree at the time of stashing."
-  ;; :package-version '(magit . "2.6.0")
-  :group 'vdiff-magit
-  :type 'boolean)
-
-(defcustom vdiff-magit-use-ediff-for-merges nil
-  "If non-nil prefer using `magit-ediff-resolve' over `vdiff-magit-resolve'.
-
-The vdiff-magit version only supports 2-way merges right now and
-not 3-way ones. If you use `vdiff-magit-resolve' in a situation
-requiring a 3-way merge it will abort and forward to
-`magit-ediff-resolve' instead. The purpose of this flag is to
-make the merge experience consistent across all types of
-merges."
-  :group 'vdiff-magit
-  :type 'boolean)
-
-(defcustom vdiff-magit-stage-is-2way nil
-  "If non-nil `vdiff-magit-stage' will only show two buffers, the
-file and the index with the HEAD omitted."
-  :group 'vdiff-magit
-  :type 'boolean)
-
-;; (defvar magit-ediff-previous-winconf nil)
-
-;;;###autoload (autoload 'vdiff-magit-popup "vdiff-magit" nil t)
-(magit-define-popup vdiff-magit-popup
-  "Popup console for vdiff commands."
-  :actions '((?d "Dwim"          vdiff-magit-dwim)
-             (?u "Show unstaged" vdiff-magit-show-unstaged)
-             (?s "Stage (vdiff)" vdiff-magit-stage)
-             (?i "Show staged"   vdiff-magit-show-staged)
-             (?m "Resolve"       vdiff-magit-resolve)
-             (?w "Show worktree" vdiff-magit-show-working-tree)
-             (?r "Diff range"    vdiff-magit-compare)
-             (?c "Show commit"   vdiff-magit-show-commit) nil
-             (?z "Show stash"    vdiff-magit-show-stash))
-  :max-action-columns 2)
-
-;;;###autoload
-(defun vdiff-magit-resolve (file)
-  "Resolve outstanding conflicts in FILE using vdiff.
-FILE has to be relative to the top directory of the repository.
-
-In the rare event that you want to manually resolve all
-conflicts, including those already resolved by Git, use
-`ediff-merge-revisions-with-ancestor'."
-  (interactive
-   (let ((current  (magit-current-file))
-         (unmerged (magit-unmerged-files)))
-     (unless unmerged
-       (user-error "There are no unresolved conflicts"))
-     (list (magit-completing-read "Resolve file" unmerged nil t nil nil
-                                  (car (member current unmerged))))))
-  (if vdiff-magit-use-ediff-for-merges
-      (magit-ediff-resolve file)
-    (vdiff-merge-conflict file)))
-
-;;;###autoload
-(defun vdiff-magit-stage (file)
-  "Stage and unstage changes to FILE using vdiff.
-FILE has to be relative to the top directory of the repository."
-  (interactive
-   (list (magit-completing-read "Selectively stage file" nil
-                                (magit-tracked-files) nil nil nil
-                                (magit-current-file))))
-  (magit-with-toplevel
-    (let* ((buf-a (or (magit-get-revision-buffer "HEAD" file)
-                      (magit-find-file-noselect "HEAD" file)))
-           (buf-b (with-current-buffer (magit-find-file-index-noselect file t)
-                    (setq buffer-read-only nil)
-                    (current-buffer)))
-           (buf-c (get-file-buffer file))
-           (file-buf-c (or buf-c (find-file-noselect file)))
-           (coding-system-for-read
-            (with-current-buffer file-buf-c buffer-file-coding-system)))
-      (if vdiff-magit-stage-is-2way
-          (vdiff-buffers
-           buf-b file-buf-c nil
-           `(lambda (buf-b buf-c)
-              (when (and (buffer-live-p buf-b)
-                         (buffer-modified-p buf-b))
-                (with-current-buffer buf-b
-                  (magit-update-index))
-                (kill-buffer buf-b))
-              (when (and (buffer-live-p buf-c)
-                         (buffer-modified-p buf-c))
-                (with-current-buffer buf-c
-                  (when (y-or-n-p
-                         (format "Save file %s? " buffer-file-name))
-                    (save-buffer))))
-              ;; kill buf-c if it wasn't open originally
-              (unless ,buf-c (kill-buffer buf-c)))
-           t nil)
-        (vdiff-buffers3
-         buf-a buf-b file-buf-c
-         `(lambda (buf-a buf-b buf-c)
-            (when (and (buffer-live-p buf-b)
-                       (buffer-modified-p buf-b))
-              (with-current-buffer buf-b
-                (magit-update-index))
-              (kill-buffer buf-b))
-            (when (and (buffer-live-p buf-c)
-                       (buffer-modified-p buf-c))
-              (with-current-buffer buf-c
-                (when (y-or-n-p
-                       (format "Save file %s? " buffer-file-name))
-                  (save-buffer))))
-            ;; kill buf-c if it wasn't open originally
-            (unless ,buf-c (kill-buffer buf-c))
-            (when (buffer-live-p buf-a)
-              (kill-buffer buf-a)))
-         t nil)))))
-
-;; ;;;###autoload
-(defun vdiff-magit-compare (rev-a rev-b file-a file-b)
-  "Compare REVA:FILEA with REVB:FILEB using vdiff.
-
-FILEA and FILEB have to be relative to the top directory of the
-repository.  If REVA or REVB is nil then this stands for the
-working tree state.
-
-If the region is active, use the revisions on the first and last
-line of the region.  With a prefix argument, instead of diffing
-the revisions, choose a revision to view changes along, starting
-at the common ancestor of both revisions (i.e., use a \"...\"
-range)."
-  (interactive (-let [(rev-a rev-b) (magit-ediff-compare--read-revisions
-                                   nil current-prefix-arg)]
-                 (nconc (list rev-a rev-b)
-                        (magit-ediff-read-files rev-a rev-b))))
-  (magit-with-toplevel
-    (vdiff-buffers
-     (if rev-a
-         (or (magit-get-revision-buffer rev-a file-a)
-             (magit-find-file-noselect rev-a file-a))
-       (or (get-file-buffer file-a)
-           (find-file-noselect file-a)))
-     (if rev-b
-         (or (magit-get-revision-buffer rev-b file-b)
-             (magit-find-file-noselect rev-b file-b))
-       (or (get-file-buffer file-b)
-           (find-file-noselect file-b)))
-     nil t t)))
-
-;;;###autoload
-(defun vdiff-magit-dwim ()
-  "Compare, stage, or resolve using vdiff.
-
-This command tries to guess what file, and what commit or range
-the user wants to compare, stage, or resolve using vdiff.  It
-might only be able to guess either the file, or range or commit,
-in which case the user is asked about the other.  It might not
-always guess right, in which case the appropriate `vdiff-magit-*'
-command has to be used explicitly.  If it cannot read the user's
-mind at all, then it asks the user for a command to run."
-  (interactive)
-  (magit-section-case
-    (hunk (save-excursion
-            (goto-char (magit-section-start (magit-section-parent it)))
-            (vdiff-magit-dwim)))
-    (t
-     (let ((range (magit-diff--dwim))
-           (file (magit-current-file))
-           command rev-a rev-b)
-       (pcase range
-         ((and (guard (not vdiff-magit-dwim-show-on-hunks))
-               (or `unstaged `staged))
-          (setq command (if (magit-anything-unmerged-p)
-                            #'vdiff-magit-resolve
-                          #'vdiff-magit-stage)))
-         (`unstaged (setq command #'vdiff-magit-show-unstaged))
-         (`staged (setq command #'vdiff-magit-show-staged))
-         (`(commit . ,value)
-          (setq command #'vdiff-magit-show-commit
-                rev-b value))
-         (`(stash . ,value)
-          (setq command #'vdiff-magit-show-stash
-                rev-b value))
-         ((pred stringp)
-          (-let [(a b) (magit-ediff-compare--read-revisions range)]
-            (setq command #'vdiff-magit-compare
-                  rev-a a
-                  rev-b b)))
-         (_
-          (when (derived-mode-p 'magit-diff-mode)
-            (pcase (magit-diff-type)
-              (`committed (-let [(a b) (magit-ediff-compare--read-revisions
-                                        (car magit-refresh-args))]
-                            (setq rev-a a rev-b b)))
-              ((guard (not vdiff-magit-dwim-show-on-hunks))
-               (setq command #'vdiff-magit-stage))
-              (`unstaged  (setq command #'vdiff-magit-show-unstaged))
-              (`staged    (setq command #'vdiff-magit-show-staged))
-              (`undefined (setq command nil))
-              (_          (setq command nil))))))
-       (cond ((not command)
-              (call-interactively
-               (magit-read-char-case
-                   "Failed to read your mind; do you want to " t
-                 (?c "[c]ommit"  'vdiff-magit-show-commit)
-                 (?r "[r]ange"   'vdiff-magit-compare)
-                 (?s "[s]tage"   'vdiff-magit-stage)
-                 (?v "resol[v]e" 'vdiff-magit-resolve))))
-             ((eq command 'vdiff-magit-compare)
-              (apply 'vdiff-magit-compare rev-a rev-b
-                     (magit-ediff-read-files rev-a rev-b file)))
-             ((eq command 'vdiff-magit-show-commit)
-              (vdiff-magit-show-commit rev-b))
-             ((eq command 'vdiff-magit-show-stash)
-              (vdiff-magit-show-stash rev-b))
-             (file
-              (funcall command file))
-             (t
-              (call-interactively command)))))))
-
-;; ;;;###autoload
-(defun vdiff-magit-show-staged (file)
-  "Show staged changes using vdiff.
-
-This only allows looking at the changes; to stage, unstage,
-and discard changes using vdiff, use `vdiff-magit-stage'.
-
-FILE must be relative to the top directory of the repository."
-  (interactive
-   (list (magit-read-file-choice "Show staged changes for file"
-                                 (magit-staged-files)
-                                 "No staged files")))
-  (vdiff-buffers
-   (or (magit-get-revision-buffer "HEAD" file)
-       (magit-find-file-noselect "HEAD" file))
-   (or (get-buffer (concat file ".~{index}~"))
-       (magit-find-file-index-noselect file t))
-   nil t t))
-
-;;;###autoload
-(defun vdiff-magit-show-unstaged (file)
-  "Show unstaged changes using vdiff.
-
-This only allows looking at the changes; to stage, unstage,
-and discard changes using vdiff, use `vdiff-magit-stage'.
-
-FILE must be relative to the top directory of the repository."
-  (interactive
-   (list (magit-read-file-choice "Show unstaged changes for file"
-                                 (magit-modified-files)
-                                 "No unstaged files")))
-  (magit-with-toplevel
-    (vdiff-buffers
-     (or (get-buffer (concat file ".~{index}~"))
-         (magit-find-file-index-noselect file t))
-     (or (get-file-buffer file)
-         (find-file-noselect file))
-     nil t t)))
-
-;; ;;;###autoload
-(defun vdiff-magit-show-working-tree (file)
-  "Show changes between HEAD and working tree using vdiff.
-FILE must be relative to the top directory of the repository."
-  (interactive
-   (list (magit-read-file-choice "Show changes in file"
-                                 (magit-changed-files "HEAD")
-                                 "No changed files")))
-  (magit-with-toplevel
-    (vdiff-buffers
-     (or (magit-get-revision-buffer "HEAD" file)
-         (magit-find-file-noselect "HEAD" file))
-     (or (get-file-buffer file) (find-file-noselect file))
-     nil t t)))
-
-;; ;;;###autoload
-(defun vdiff-magit-show-commit (commit)
-  "Show changes introduced by COMMIT using vdiff."
-  (interactive (list (magit-read-branch-or-commit "Revision")))
-  (let ((rev-a (concat commit "^"))
-        (rev-b commit))
-    (apply #'vdiff-magit-compare
-           (concat commit "^") commit
-           (magit-ediff-read-files rev-a rev-b (magit-current-file)))))
-
-;; ;;;###autoload
-(defun vdiff-magit-show-stash (stash)
-  "Show changes introduced by STASH using vdiff.
-`vdiff-magit-show-stash-with-index' controls whether a
-three-buffer vdiff is used in order to distinguish changes in the
-stash that were staged."
-  (interactive (list (magit-read-stash "Stash")))
-  (-let* ((rev-a (concat stash "^1"))
-          (rev-b (concat stash "^2"))
-          (rev-c stash)
-          ((file-a file-c) (magit-ediff-read-files rev-a rev-c))
-          (file-b file-c))
-    (if (and vdiff-magit-show-stash-with-index
-             (member file-a (magit-changed-files rev-b rev-a)))
-        (let ((buf-a (magit-get-revision-buffer rev-a file-a))
-              (buf-b (magit-get-revision-buffer rev-b file-b))
-              (buf-c (magit-get-revision-buffer rev-c file-c)))
-          (vdiff-buffers3
-           (or buf-a (magit-find-file-noselect rev-a file-a))
-           (or buf-b (magit-find-file-noselect rev-b file-b))
-           (or buf-c (magit-find-file-noselect rev-c file-c))
-           nil t t))
-      (vdiff-magit-compare rev-a rev-c file-a file-c))))
-
-(provide 'vdiff-magit)
-;;; vdiff-magit.el ends here
diff --git a/packages/vdiff/vdiff.el b/packages/vdiff/vdiff.el
index ba26feb..e96b18c 100644
--- a/packages/vdiff/vdiff.el
+++ b/packages/vdiff/vdiff.el
@@ -306,7 +306,7 @@ because those are handled differently.")
 
 (defun vdiff--all-windows ()
   (remq nil
-        (mapcar #'get-buffer-window
+        (mapcar (lambda (buf) (get-buffer-window buf 0))
                 (vdiff-session-buffers vdiff--session))))
 
 (defun vdiff--all-overlays (ovr)
@@ -590,8 +590,8 @@ an addition when compared to other vdiff buffers."
 parsing the diff output and triggering the overlay updates."
   (unless vdiff--inhibit-diff-update
     (let ((parse-func (if (process-get proc 'vdiff-3way)
-                          'vdiff--parse-diff3
-                        'vdiff--parse-diff))
+                          #'vdiff--parse-diff3
+                        #'vdiff--parse-diff))
           (ses (process-get proc 'vdiff-session))
           (post-function (process-get proc 'vdiff-post-refresh-function))
           finished)
@@ -1667,7 +1667,7 @@ function for ON-QUIT to do something useful with the 
result."
       (get-buffer
        (read-buffer
         (format "[Buffer 1 %s] Buffer 2: " buffer-a)
-        (window-buffer (next-window (selected-window)))))
+        (window-buffer (next-window (selected-window) nil 0))))
       current-prefix-arg)))
   (let ((prior-window-config (when restore-windows-on-quit
                                (current-window-configuration)))



reply via email to

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