diff options
| author | Chong Yidong | 2011-01-28 18:10:55 -0500 |
|---|---|---|
| committer | Chong Yidong | 2011-01-28 18:10:55 -0500 |
| commit | 9bfe578343f60afa1a3b19856f90190bf74dcebb (patch) | |
| tree | 8ada004d8bec57a71d6f4156d32a508f9ad3a077 | |
| parent | 54b6f6edb89ba6b9bd6ef53f5edc4a0e05ed8894 (diff) | |
| download | emacs-9bfe578343f60afa1a3b19856f90190bf74dcebb.tar.gz emacs-9bfe578343f60afa1a3b19856f90190bf74dcebb.zip | |
Convert vc-bzr-async-command into a general vc-do-async-command facility.
* vc/vc-dispatcher.el (vc-do-async-command): New function.
* vc/vc-bzr.el (vc-bzr-async-command): Convert into a wrapper for
vc-do-async-command.
* vc/vc-bzr.el (vc-bzr-pull, vc-bzr-merge-branch): Callers changed.
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/vc/vc-bzr.el | 47 | ||||
| -rw-r--r-- | lisp/vc/vc-dispatcher.el | 28 |
3 files changed, 57 insertions, 30 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 59a346bdd95..c1477a6b8a5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,7 +1,17 @@ | |||
| 1 | 2011-01-28 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * vc/vc-dispatcher.el (vc-do-async-command): New function. | ||
| 4 | |||
| 5 | * vc/vc-bzr.el (vc-bzr-async-command): Convert into a wrapper for | ||
| 6 | vc-do-async-command. | ||
| 7 | |||
| 8 | * vc/vc-bzr.el (vc-bzr-pull, vc-bzr-merge-branch): Callers | ||
| 9 | changed. | ||
| 10 | |||
| 1 | 2011-01-28 Leo <sdl.web@gmail.com> | 11 | 2011-01-28 Leo <sdl.web@gmail.com> |
| 2 | 12 | ||
| 3 | * emacs-lisp/advice.el (ad-make-advised-docstring): Don't apply | 13 | * emacs-lisp/advice.el (ad-make-advised-docstring): Don't apply |
| 4 | highlighting to the "this function is advisted" message. | 14 | highlighting to the "this function is advised" message. |
| 5 | 15 | ||
| 6 | * help-mode.el (help-mode-finish): Apply highlighting here, to | 16 | * help-mode.el (help-mode-finish): Apply highlighting here, to |
| 7 | avoid clobbering by substitute-command-keys (Bug#6304). | 17 | avoid clobbering by substitute-command-keys (Bug#6304). |
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el index 9693fa745ce..31893645a62 100644 --- a/lisp/vc/vc-bzr.el +++ b/lisp/vc/vc-bzr.el | |||
| @@ -94,6 +94,20 @@ Invoke the bzr command adding `BZR_PROGRESS_BAR=none' and | |||
| 94 | (apply 'vc-do-command (or buffer "*vc*") okstatus vc-bzr-program | 94 | (apply 'vc-do-command (or buffer "*vc*") okstatus vc-bzr-program |
| 95 | file-or-list bzr-command args))) | 95 | file-or-list bzr-command args))) |
| 96 | 96 | ||
| 97 | (defun vc-bzr-async-command (bzr-command &rest args) | ||
| 98 | "Wrapper round `vc-do-async-command' using `vc-bzr-program' as COMMAND. | ||
| 99 | Invoke the bzr command adding `BZR_PROGRESS_BAR=none' and | ||
| 100 | `LC_MESSAGES=C' to the environment. | ||
| 101 | Use the current Bzr root directory as the ROOT argument to | ||
| 102 | `vc-do-async-command', and specify an output buffer named | ||
| 103 | \"*vc-bzr : ROOT*\"." | ||
| 104 | (let* ((process-environment | ||
| 105 | (list* "BZR_PROGRESS_BAR=none" "LC_MESSAGES=C" | ||
| 106 | process-environment)) | ||
| 107 | (root (vc-bzr-root default-directory)) | ||
| 108 | (buffer (format "*vc-bzr : %s*" (expand-file-name root)))) | ||
| 109 | (apply 'vc-do-async-command buffer root | ||
| 110 | vc-bzr-program bzr-command args))) | ||
| 97 | 111 | ||
| 98 | ;;;###autoload | 112 | ;;;###autoload |
| 99 | (defconst vc-bzr-admin-dirname ".bzr" | 113 | (defconst vc-bzr-admin-dirname ".bzr" |
| @@ -261,31 +275,6 @@ Invoke the bzr command adding `BZR_PROGRESS_BAR=none' and | |||
| 261 | (when rootdir | 275 | (when rootdir |
| 262 | (file-relative-name filename* rootdir)))) | 276 | (file-relative-name filename* rootdir)))) |
| 263 | 277 | ||
| 264 | (defun vc-bzr-async-command (command args) | ||
| 265 | "Run Bzr COMMAND asynchronously with ARGS, displaying the result. | ||
| 266 | Send the output to a buffer named \"*vc-bzr : NAME*\", where NAME | ||
| 267 | is the root of the current Bzr branch. Display the buffer in | ||
| 268 | some window, but don't select it." | ||
| 269 | ;; TODO: set up hyperlinks. | ||
| 270 | (let* ((dir default-directory) | ||
| 271 | (root (vc-bzr-root default-directory)) | ||
| 272 | (buffer (get-buffer-create | ||
| 273 | (format "*vc-bzr : %s*" | ||
| 274 | (expand-file-name root))))) | ||
| 275 | (with-current-buffer buffer | ||
| 276 | (setq default-directory root) | ||
| 277 | (goto-char (point-max)) | ||
| 278 | (unless (eq (point) (point-min)) | ||
| 279 | (insert "\n")) | ||
| 280 | (insert "Running \"" vc-bzr-program " " command) | ||
| 281 | (dolist (arg args) | ||
| 282 | (insert " " arg)) | ||
| 283 | (insert "\"...\n") | ||
| 284 | ;; Run bzr in the original working directory. | ||
| 285 | (let ((default-directory dir)) | ||
| 286 | (apply 'vc-bzr-command command t 'async nil args))) | ||
| 287 | (display-buffer buffer))) | ||
| 288 | |||
| 289 | (defun vc-bzr-pull (prompt) | 278 | (defun vc-bzr-pull (prompt) |
| 290 | "Pull changes into the current Bzr branch. | 279 | "Pull changes into the current Bzr branch. |
| 291 | Normally, this runs \"bzr pull\". However, if the branch is a | 280 | Normally, this runs \"bzr pull\". However, if the branch is a |
| @@ -315,7 +304,7 @@ prompt for the Bzr command to run." | |||
| 315 | (setq vc-bzr-program (car args) | 304 | (setq vc-bzr-program (car args) |
| 316 | command (cadr args) | 305 | command (cadr args) |
| 317 | args (cddr args))) | 306 | args (cddr args))) |
| 318 | (vc-bzr-async-command command args))) | 307 | (apply 'vc-bzr-async-command command args))) |
| 319 | 308 | ||
| 320 | (defun vc-bzr-merge-branch () | 309 | (defun vc-bzr-merge-branch () |
| 321 | "Merge another Bzr branch into the current one. | 310 | "Merge another Bzr branch into the current one. |
| @@ -324,8 +313,8 @@ source (an upstream branch or a previous merge source) as a | |||
| 324 | default if it is available." | 313 | default if it is available." |
| 325 | (let* ((branch-conf (vc-bzr--branch-conf default-directory)) | 314 | (let* ((branch-conf (vc-bzr--branch-conf default-directory)) |
| 326 | ;; "bzr merge" without an argument defaults to submit_branch, | 315 | ;; "bzr merge" without an argument defaults to submit_branch, |
| 327 | ;; then parent_location. We extract the specific location | 316 | ;; then parent_location. Extract the specific location and |
| 328 | ;; and add it explicitly to the command line. | 317 | ;; add it explicitly to the command line. |
| 329 | (location | 318 | (location |
| 330 | (cond | 319 | (cond |
| 331 | ((string-match | 320 | ((string-match |
| @@ -347,7 +336,7 @@ default if it is available." | |||
| 347 | (vc-bzr-program (car cmd)) | 336 | (vc-bzr-program (car cmd)) |
| 348 | (command (cadr cmd)) | 337 | (command (cadr cmd)) |
| 349 | (args (cddr cmd))) | 338 | (args (cddr cmd))) |
| 350 | (vc-bzr-async-command command args))) | 339 | (apply 'vc-bzr-async-command command args))) |
| 351 | 340 | ||
| 352 | (defun vc-bzr-status (file) | 341 | (defun vc-bzr-status (file) |
| 353 | "Return FILE status according to Bzr. | 342 | "Return FILE status according to Bzr. |
diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index b12719642e9..19a276b635c 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el | |||
| @@ -356,6 +356,34 @@ case, and the process object in the asynchronous case." | |||
| 356 | ',command ',file-or-list ',flags)) | 356 | ',command ',file-or-list ',flags)) |
| 357 | status)))) | 357 | status)))) |
| 358 | 358 | ||
| 359 | (defun vc-do-async-command (buffer root command &rest args) | ||
| 360 | "Run COMMAND asynchronously with ARGS, displaying the result. | ||
| 361 | Send the output to BUFFER, which should be a buffer or the name | ||
| 362 | of a buffer, which is created. | ||
| 363 | ROOT should be the directory in which the command should be run. | ||
| 364 | Display the buffer in some window, but don't select it." | ||
| 365 | (let* ((dir default-directory) | ||
| 366 | window new-window-start) | ||
| 367 | (setq buffer (get-buffer-create buffer)) | ||
| 368 | (if (get-buffer-process buffer) | ||
| 369 | (error "Another VC action on %s is running" root)) | ||
| 370 | (with-current-buffer buffer | ||
| 371 | (setq default-directory root) | ||
| 372 | (goto-char (point-max)) | ||
| 373 | (unless (eq (point) (point-min)) | ||
| 374 | (insert "\n")) | ||
| 375 | (setq new-window-start (point)) | ||
| 376 | (insert "Running \"" command " ") | ||
| 377 | (dolist (arg args) | ||
| 378 | (insert " " arg)) | ||
| 379 | (insert "\"...\n") | ||
| 380 | ;; Run in the original working directory. | ||
| 381 | (let ((default-directory dir)) | ||
| 382 | (apply 'vc-do-command t 'async command nil args))) | ||
| 383 | (setq window (display-buffer buffer)) | ||
| 384 | (if window | ||
| 385 | (set-window-start window new-window-start)))) | ||
| 386 | |||
| 359 | ;; These functions are used to ensure that the view the user sees is up to date | 387 | ;; These functions are used to ensure that the view the user sees is up to date |
| 360 | ;; even if the dispatcher client mode has messed with file contents (as in, | 388 | ;; even if the dispatcher client mode has messed with file contents (as in, |
| 361 | ;; for example, VCS keyword expansion). | 389 | ;; for example, VCS keyword expansion). |