aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2010-06-29 14:17:31 -0400
committerChong Yidong2010-06-29 14:17:31 -0400
commita2f043d3d72cbbc0ad64fb271a9f0545791100ec (patch)
treebc1bef14bdebdda024fa3d0c4611f1eac53eaa67
parent5d1d3d04611aa010a6bc97bb39d499f28131454c (diff)
downloademacs-a2f043d3d72cbbc0ad64fb271a9f0545791100ec.tar.gz
emacs-a2f043d3d72cbbc0ad64fb271a9f0545791100ec.zip
Allow global VC ops like `C-x v D' in Diff and Log-View buffers.
* vc/diff-mode.el (diff-vc-backend): New var. * vc/vc.el (vc-deduce-backend): New fun. Handle diff buffers. (vc-root-diff, vc-print-root-log, vc-log-incoming) (vc-log-outgoing): Use it. (vc-diff-internal): Set diff-vc-backend.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/vc/diff-mode.el3
-rw-r--r--lisp/vc/vc.el32
3 files changed, 27 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2316e9eabab..ddef9202be3 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
12010-06-29 Chong Yidong <cyd@stupidchicken.com>
2
3 * vc/vc.el (vc-deduce-backend): New fun. Handle diff buffers.
4 (vc-root-diff, vc-print-root-log, vc-log-incoming)
5 (vc-log-outgoing): Use it.
6 (vc-diff-internal): Set diff-vc-backend.
7
8 * vc/diff-mode.el (diff-vc-backend): New var.
9
12010-06-28 Jan Djärv <jan.h.d@swipnet.se> 102010-06-28 Jan Djärv <jan.h.d@swipnet.se>
2 11
3 * dynamic-setting.el (font-setting-change-default-font): Remove 12 * dynamic-setting.el (font-setting-change-default-font): Remove
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index adc5a2a0455..0ef9d06c3b2 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -97,6 +97,9 @@ when editing big diffs)."
97 :options '(diff-delete-empty-files diff-make-unified) 97 :options '(diff-delete-empty-files diff-make-unified)
98 :group 'diff-mode) 98 :group 'diff-mode)
99 99
100(defvar diff-vc-backend nil
101 "The VC backend that created the current Diff buffer, if any.")
102
100(defvar diff-outline-regexp 103(defvar diff-outline-regexp
101 "\\([*+][*+][*+] [^0-9]\\|@@ ...\\|\\*\\*\\* [0-9].\\|--- [0-9]..\\)") 104 "\\([*+][*+][*+] [^0-9]\\|@@ ...\\|\\*\\*\\* [0-9].\\|--- [0-9]..\\)")
102 105
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index ae3f6a0ed38..23dd6f0f7ae 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -913,6 +913,16 @@ Within directories, only files already under version control are noticed."
913 (nreverse flattened))) 913 (nreverse flattened)))
914 914
915(defvar vc-dir-backend) 915(defvar vc-dir-backend)
916(defvar log-view-vc-backend)
917(defvar diff-vc-backend)
918
919(defun vc-deduce-backend ()
920 (cond ((derived-mode-p 'vc-dir-mode) vc-dir-backend)
921 ((derived-mode-p 'log-view-mode) log-view-vc-backend)
922 ((derived-mode-p 'diff-mode) diff-vc-backend)
923 ((derived-mode-p 'dired-mode)
924 (vc-responsible-backend default-directory))
925 (vc-mode (vc-backend buffer-file-name))))
916 926
917(declare-function vc-dir-current-file "vc-dir" ()) 927(declare-function vc-dir-current-file "vc-dir" ())
918(declare-function vc-dir-deduce-fileset "vc-dir" (&optional state-model-only-files)) 928(declare-function vc-dir-deduce-fileset "vc-dir" (&optional state-model-only-files))
@@ -1547,6 +1557,7 @@ returns t if the buffer had changes, nil otherwise."
1547 (message "%s" (cdr messages)) 1557 (message "%s" (cdr messages))
1548 nil) 1558 nil)
1549 (diff-mode) 1559 (diff-mode)
1560 (set (make-local-variable 'diff-vc-backend) (car vc-fileset))
1550 (set (make-local-variable 'revert-buffer-function) 1561 (set (make-local-variable 'revert-buffer-function)
1551 `(lambda (ignore-auto noconfirm) 1562 `(lambda (ignore-auto noconfirm)
1552 (vc-diff-internal ,async ',vc-fileset ,rev1 ,rev2 ,verbose))) 1563 (vc-diff-internal ,async ',vc-fileset ,rev1 ,rev2 ,verbose)))
@@ -1656,10 +1667,7 @@ saving the buffer."
1656 ;; that's not what we want here, we want the diff for the VC root dir. 1667 ;; that's not what we want here, we want the diff for the VC root dir.
1657 (call-interactively 'vc-version-diff) 1668 (call-interactively 'vc-version-diff)
1658 (when buffer-file-name (vc-buffer-sync not-urgent)) 1669 (when buffer-file-name (vc-buffer-sync not-urgent))
1659 (let ((backend 1670 (let ((backend (vc-deduce-backend))
1660 (cond ((derived-mode-p 'vc-dir-mode) vc-dir-backend)
1661 ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
1662 (vc-mode (vc-backend buffer-file-name))))
1663 rootdir working-revision) 1671 rootdir working-revision)
1664 (unless backend 1672 (unless backend
1665 (error "Buffer is not version controlled")) 1673 (error "Buffer is not version controlled"))
@@ -1956,7 +1964,6 @@ If it contains `directory' then if the fileset contains a directory show a short
1956If it contains `file' then show short logs for files. 1964If it contains `file' then show short logs for files.
1957Not all VC backends support short logs!") 1965Not all VC backends support short logs!")
1958 1966
1959(defvar log-view-vc-backend)
1960(defvar log-view-vc-fileset) 1967(defvar log-view-vc-fileset)
1961 1968
1962(defun vc-print-log-setup-buttons (working-revision is-start-revision limit pl-return) 1969(defun vc-print-log-setup-buttons (working-revision is-start-revision limit pl-return)
@@ -2105,10 +2112,7 @@ When called interactively with a prefix argument, prompt for LIMIT."
2105 (list lim))) 2112 (list lim)))
2106 (t 2113 (t
2107 (list (when (> vc-log-show-limit 0) vc-log-show-limit))))) 2114 (list (when (> vc-log-show-limit 0) vc-log-show-limit)))))
2108 (let ((backend 2115 (let ((backend (vc-deduce-backend))
2109 (cond ((derived-mode-p 'vc-dir-mode) vc-dir-backend)
2110 ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
2111 (vc-mode (vc-backend buffer-file-name))))
2112 rootdir working-revision) 2116 rootdir working-revision)
2113 (unless backend 2117 (unless backend
2114 (error "Buffer is not version controlled")) 2118 (error "Buffer is not version controlled"))
@@ -2120,10 +2124,7 @@ When called interactively with a prefix argument, prompt for LIMIT."
2120(defun vc-log-incoming (&optional remote-location) 2124(defun vc-log-incoming (&optional remote-location)
2121 "Show a log of changes that will be received with a pull operation from REMOTE-LOCATION." 2125 "Show a log of changes that will be received with a pull operation from REMOTE-LOCATION."
2122 (interactive "sRemote location (empty for default): ") 2126 (interactive "sRemote location (empty for default): ")
2123 (let ((backend 2127 (let ((backend (vc-deduce-backend))
2124 (cond ((derived-mode-p 'vc-dir-mode) vc-dir-backend)
2125 ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
2126 (vc-mode (vc-backend buffer-file-name))))
2127 rootdir working-revision) 2128 rootdir working-revision)
2128 (unless backend 2129 (unless backend
2129 (error "Buffer is not version controlled")) 2130 (error "Buffer is not version controlled"))
@@ -2133,10 +2134,7 @@ When called interactively with a prefix argument, prompt for LIMIT."
2133(defun vc-log-outgoing (&optional remote-location) 2134(defun vc-log-outgoing (&optional remote-location)
2134 "Show a log of changes that will be sent with a push operation to REMOTE-LOCATION." 2135 "Show a log of changes that will be sent with a push operation to REMOTE-LOCATION."
2135 (interactive "sRemote location (empty for default): ") 2136 (interactive "sRemote location (empty for default): ")
2136 (let ((backend 2137 (let ((backend (vc-deduce-backend))
2137 (cond ((derived-mode-p 'vc-dir-mode) vc-dir-backend)
2138 ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
2139 (vc-mode (vc-backend buffer-file-name))))
2140 rootdir working-revision) 2138 rootdir working-revision)
2141 (unless backend 2139 (unless backend
2142 (error "Buffer is not version controlled")) 2140 (error "Buffer is not version controlled"))