From 8a4e6db81ae0c04a73693718cb8aaa59e160663f Mon Sep 17 00:00:00 2001 From: Sam Steingold Date: Thu, 19 Jul 2012 10:38:01 -0400 Subject: * lisp/vc/vc-dispatcher.el (vc-compilation-mode): Add, based on vc-bzr-pull & vc-bzr-merge-branch. * lisp/vc/vc-bzr.el (vc-bzr-pull, vc-bzr-merge-branch): Use it. (vc-bzr-error-regexp-alist): Rename from vc-bzr-error-regex-alist for consistency with compilation-error-regexp-alist. * lisp/vc/vc-git.el (vc-git-error-regexp-alist): Add. (vc-git-pull, vc-git-merge-branch): Call vc-compilation-mode. * lisp/vc/vc-hg.el (vc-hg-error-regexp-alist): Add. (vc-hg-pull, vc-hg-merge-branch): Call vc-compilation-mode. --- lisp/vc/vc-bzr.el | 20 +++----------------- lisp/vc/vc-dispatcher.el | 11 +++++++++++ lisp/vc/vc-git.el | 6 ++++++ lisp/vc/vc-hg.el | 10 ++++++++++ 4 files changed, 30 insertions(+), 17 deletions(-) (limited to 'lisp/vc') diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el index ce4d76dc5f..c0dafda57b 100644 --- a/lisp/vc/vc-bzr.el +++ b/lisp/vc/vc-bzr.el @@ -311,7 +311,7 @@ in the repository root directory of FILE." (when rootdir (file-relative-name filename* rootdir)))) -(defvar vc-bzr-error-regex-alist +(defvar vc-bzr-error-regexp-alist '(("^\\( M[* ]\\|+N \\|-D \\|\\| \\*\\|R[M ] \\) \\(.+\\)" 2 nil nil 1) ("^C \\(.+\\)" 2) ("^Text conflict in \\(.+\\)" 1 nil nil 2) @@ -347,14 +347,7 @@ prompt for the Bzr command to run." command (cadr args) args (cddr args))) (let ((buf (apply 'vc-bzr-async-command command args))) - (with-current-buffer buf - (vc-exec-after - `(progn - (let ((compilation-error-regexp-alist - vc-bzr-error-regex-alist)) - (compilation-mode)) - (set (make-local-variable 'compilation-error-regexp-alist) - vc-bzr-error-regex-alist)))) + (with-current-buffer buf (vc-exec-after '(vc-compilation-mode 'bzr))) (vc-set-async-update buf)))) (defun vc-bzr-merge-branch () @@ -385,14 +378,7 @@ default if it is available." (command (cadr cmd)) (args (cddr cmd))) (let ((buf (apply 'vc-bzr-async-command command args))) - (with-current-buffer buf - (vc-exec-after - `(progn - (let ((compilation-error-regexp-alist - vc-bzr-error-regex-alist)) - (compilation-mode)) - (set (make-local-variable 'compilation-error-regexp-alist) - vc-bzr-error-regex-alist)))) + (with-current-buffer buf (vc-exec-after '(vc-compilation-mode 'bzr))) (vc-set-async-update buf)))) (defun vc-bzr-status (file) diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index b8ad4ff521..d8a7a296cf 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -386,6 +386,17 @@ Display the buffer in some window, but don't select it." (set-window-start window new-window-start)) buffer)) +(defun vc-compilation-mode (backend) + "Setup `compilation-mode' after with the appropriate `compilation-error-regexp-alist'." + (let* ((error-regexp-alist + (vc-make-backend-sym backend 'error-regexp-alist)) + (compilation-error-regexp-alist + (and (boundp error-regexp-alist) + (symbol-value error-regexp-alist)))) + (compilation-mode) + (set (make-local-variable 'compilation-error-regexp-alist) + compilation-error-regexp-alist))) + (defun vc-set-async-update (process-buffer) "Set a `vc-exec-after' action appropriate to the current buffer. This action will update the current buffer after the current diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 700adf12fc..ee77609244 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -646,6 +646,10 @@ The car of the list is the current branch." (vc-git-command nil 0 file "reset" "-q" "--") (vc-git-command nil nil file "checkout" "-q" "--"))) +(defvar vc-git-error-regexp-alist + '(("^ \\(.+\\) |" 1 nil nil 0)) + "Value of `compilation-error-regexp-alist' in *vc-git* buffers.") + (defun vc-git-pull (prompt) "Pull changes into the current Git branch. Normally, this runs \"git pull\". If PROMPT is non-nil, prompt @@ -666,6 +670,7 @@ for the Git command to run." command (cadr args) args (cddr args))) (apply 'vc-do-async-command buffer root git-program command args) + (with-current-buffer buffer (vc-exec-after '(vc-compilation-mode 'git))) (vc-set-async-update buffer))) (defun vc-git-merge-branch () @@ -685,6 +690,7 @@ This prompts for a branch to merge from." nil t))) (apply 'vc-do-async-command buffer root vc-git-program "merge" (list merge-source)) + (with-current-buffer buffer (vc-exec-after '(vc-compilation-mode 'git))) (vc-set-async-update buffer))) ;;; HISTORY FUNCTIONS diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 6dbf697837..727fb08e38 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -611,6 +611,14 @@ REV is the revision to check out into WORKFILE." (mapcar (lambda (arg) (list "-r" arg)) marked-list))) (error "No log entries selected for push")))) +(defvar vc-hg-error-regexp-alist nil + ;; 'hg pull' does not list modified files, so, for now, the only + ;; benefit of `vc-compilation-mode' is that one can get rid of + ;; *vc-hg* buffer with 'q' or 'z'. + ;; TODO: call 'hg incoming' before pull/merge to get the list of + ;; modified files + "Value of `compilation-error-regexp-alist' in *vc-hg* buffers.") + (defun vc-hg-pull (prompt) "Issue a Mercurial pull command. If called interactively with a set of marked Log View buffers, @@ -651,6 +659,7 @@ then attempts to update the working directory." args (cddr args))) (apply 'vc-do-async-command buffer root hg-program command args) + (with-current-buffer buffer (vc-exec-after '(vc-compilation-mode 'hg))) (vc-set-async-update buffer))))) (defun vc-hg-merge-branch () @@ -659,6 +668,7 @@ This runs the command \"hg merge\"." (let* ((root (vc-hg-root default-directory)) (buffer (format "*vc-hg : %s*" (expand-file-name root)))) (apply 'vc-do-async-command buffer root vc-hg-program '("merge")) + (with-current-buffer buffer (vc-exec-after '(vc-compilation-mode 'hg))) (vc-set-async-update buffer))) ;;; Internal functions -- cgit v1.2.3