From 8dac9c34d8a2575d44fc78824ec77a58b63701b6 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 1 Dec 2014 13:12:37 -0500 Subject: [PATCH] * lisp/vc/diff-mode.el (diff-kill-applied-hunks): New command. * lisp/vc/smerge-mode.el (smerge-swap): New command. --- lisp/ChangeLog | 14 ++++++++++---- lisp/vc/diff-mode.el | 10 ++++++++++ lisp/vc/smerge-mode.el | 13 +++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9f233cdaadf..ec95af9441f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,7 +1,13 @@ +2014-12-01 Stefan Monnier + + * vc/smerge-mode.el (smerge-swap): New command. + + * vc/diff-mode.el (diff-kill-applied-hunks): New command. + 2014-12-01 Ulf Jasper - * net/newst-treeview.el (newsticker--treeview-item-show): Check - window liveliness before measuring its width. + * net/newst-treeview.el (newsticker--treeview-item-show): + Check window liveliness before measuring its width. * net/newst-backend.el (newsticker--get-news-by-url-callback): Pass correct status to `newsticker--sentinel-work'. @@ -25,13 +31,13 @@ * vc/vc.el, vc/vc-cvs.el, vc/vc-rcs.el, vc/vc-svn.el: The 'merge' backend method of RCS/CVS/SVN is now 'merge-file', to contrast with - 'merge-branch'. Prompting for merge revisions is pushed down to + 'merge-branch'. Prompting for merge revisions is pushed down to the back ends; this fixes a layering violation that caused bad behavior with SVN. * vc/vc.el, vc-hooks.el, and all backends: API simplification; vc-stay-local-p and repository-hostname are no longer public - methods. Only the CVS and SVN backends used these, and the SVN + methods. Only the CVS and SVN backends used these, and the SVN support was conditioned out because svn status -v is too slow. The CVS back end retains this machibery and the vc-stay-local configuration variable now only affects it. diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 9afb9f47e91..f3455efb294 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -1817,6 +1817,16 @@ With a prefix argument, try to REVERSE the hunk." (diff-hunk-status-msg line-offset (diff-xor reverse switched) t))) +(defun diff-kill-applied-hunks () + "Kill all hunks that have already been applied starting at point." + (interactive) + (while (not (eobp)) + (pcase-let ((`(,buf ,line-offset ,pos ,src ,_dst ,switched) + (diff-find-source-location nil nil))) + (if (and line-offset switched) + (diff-hunk-kill) + (diff-hunk-next))))) + (defalias 'diff-mouse-goto-source 'diff-goto-source) (defun diff-goto-source (&optional other-file event) diff --git a/lisp/vc/smerge-mode.el b/lisp/vc/smerge-mode.el index 771281555ab..0b7b70219c0 100644 --- a/lisp/vc/smerge-mode.el +++ b/lisp/vc/smerge-mode.el @@ -1132,6 +1132,19 @@ repeating the command will highlight other two parts." (unless smerge-use-changed-face '((smerge . refine) (face . smerge-refined-added)))))) +(defun smerge-swap () + "Swap the \"Mine\" and the \"Other\" chunks. +Can be used before things like `smerge-keep-all' or `smerge-resolve' where the +ordering can have some subtle influence on the result, such as preferring the +spacing of the \"Other\" chunk." + (interactive) + (smerge-match-conflict) + (goto-char (match-beginning 3)) + (let ((txt3 (delete-and-extract-region (point) (match-end 3)))) + (insert (delete-and-extract-region (match-beginning 1) (match-end 1))) + (goto-char (match-beginning 1)) + (insert txt3))) + (defun smerge-diff (n1 n2) (smerge-match-conflict) (smerge-ensure-match n1) -- 2.39.5