diff options
| author | Dan Nicolaescu | 2008-01-06 10:20:26 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2008-01-06 10:20:26 +0000 |
| commit | 8fcaf22f902ab98150eedd3d5d411c59023183bb (patch) | |
| tree | 5c24864284bffb7e7c5937f59ae1833ef8f67b44 | |
| parent | 2614ccc373ed188a240bf2c2f7e131ee99f110c0 (diff) | |
| download | emacs-8fcaf22f902ab98150eedd3d5d411c59023183bb.tar.gz emacs-8fcaf22f902ab98150eedd3d5d411c59023183bb.zip | |
* vc.el (vc-status-fileinfo): New defstruct.
(vc-status): New defvar
(vc-status-insert-headers, vc-status-printer, vc-status)
(vc-status-mode-map, vc-status-mode, vc-status-mark-file)
(vc-status-unmark-file, vc-status-marked-files): New functions.
* vc-hg.el (vc-hg-dir-status): New function.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/vc-hg.el | 30 | ||||
| -rw-r--r-- | lisp/vc.el | 90 |
3 files changed, 130 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index caa9c0f71f1..4896c2c1f14 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2008-01-06 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * vc.el (vc-status-fileinfo): New defstruct. | ||
| 4 | (vc-status): New defvar | ||
| 5 | (vc-status-insert-headers, vc-status-printer, vc-status) | ||
| 6 | (vc-status-mode-map, vc-status-mode, vc-status-mark-file) | ||
| 7 | (vc-status-unmark-file, vc-status-marked-files): New functions. | ||
| 8 | |||
| 9 | * vc-hg.el (vc-hg-dir-status): New function. | ||
| 10 | |||
| 1 | 2008-01-06 Martin Rudalics <rudalics@gmx.at> | 11 | 2008-01-06 Martin Rudalics <rudalics@gmx.at> |
| 2 | 12 | ||
| 3 | * cus-edit.el (custom-tool-bar-map): Move initialization of this | 13 | * cus-edit.el (custom-tool-bar-map): Move initialization of this |
diff --git a/lisp/vc-hg.el b/lisp/vc-hg.el index d921de9bbd9..081e469d468 100644 --- a/lisp/vc-hg.el +++ b/lisp/vc-hg.el | |||
| @@ -477,6 +477,36 @@ REV is the revision to check out into WORKFILE." | |||
| 477 | 477 | ||
| 478 | (define-derived-mode vc-hg-incoming-mode vc-hg-log-view-mode "Hg-Incoming") | 478 | (define-derived-mode vc-hg-incoming-mode vc-hg-log-view-mode "Hg-Incoming") |
| 479 | 479 | ||
| 480 | |||
| 481 | ;; XXX Experimental function for the vc-dired replacement. | ||
| 482 | (defun vc-hg-dir-status (dir) | ||
| 483 | "Return a list of conses (file . state) for DIR." | ||
| 484 | (with-temp-buffer | ||
| 485 | (vc-hg-command (current-buffer) nil nil "status" "-A") | ||
| 486 | (goto-char (point-min)) | ||
| 487 | (let ((status-char nil) | ||
| 488 | (file nil) | ||
| 489 | (translation '((?= . up-to-date) | ||
| 490 | (?C . up-to-date) | ||
| 491 | (?A . added) | ||
| 492 | (?R . removed) | ||
| 493 | (?M . edited) | ||
| 494 | (?I . ignored) | ||
| 495 | (?! . deleted) | ||
| 496 | (?? . unregistered))) | ||
| 497 | (translated nil) | ||
| 498 | (result nil)) | ||
| 499 | (while (not (eobp)) | ||
| 500 | (setq status-char (char-after)) | ||
| 501 | (setq file | ||
| 502 | (buffer-substring-no-properties (+ (point) 2) | ||
| 503 | (line-end-position))) | ||
| 504 | (setq translated (assoc status-char translation)) | ||
| 505 | (when (and translated (not (eq (cdr translated) 'up-to-date))) | ||
| 506 | (push (cons file (cdr translated)) result)) | ||
| 507 | (forward-line)) | ||
| 508 | result))) | ||
| 509 | |||
| 480 | ;; XXX this adds another top level menu, instead figure out how to | 510 | ;; XXX this adds another top level menu, instead figure out how to |
| 481 | ;; replace the Log-View menu. | 511 | ;; replace the Log-View menu. |
| 482 | (easy-menu-define log-view-mode-menu vc-hg-outgoing-mode-map | 512 | (easy-menu-define log-view-mode-menu vc-hg-outgoing-mode-map |
diff --git a/lisp/vc.el b/lisp/vc.el index 74ab1afeb20..9e5df686546 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -1276,6 +1276,8 @@ Otherwise, throw an error." | |||
| 1276 | (unless (eq (vc-backend f) firstbackend) | 1276 | (unless (eq (vc-backend f) firstbackend) |
| 1277 | (error "All members of a fileset must be under the same version-control system.")))) | 1277 | (error "All members of a fileset must be under the same version-control system.")))) |
| 1278 | marked)) | 1278 | marked)) |
| 1279 | ((eq major-mode 'vc-status-mode) | ||
| 1280 | (vc-status-marked-files)) | ||
| 1279 | ((vc-backend buffer-file-name) | 1281 | ((vc-backend buffer-file-name) |
| 1280 | (list buffer-file-name)) | 1282 | (list buffer-file-name)) |
| 1281 | ((and vc-parent-buffer (or (buffer-file-name vc-parent-buffer) | 1283 | ((and vc-parent-buffer (or (buffer-file-name vc-parent-buffer) |
| @@ -2496,6 +2498,94 @@ With prefix arg READ-SWITCHES, specify a value to override | |||
| 2496 | vc-dired-switches | 2498 | vc-dired-switches |
| 2497 | 'vc-dired-mode)))) | 2499 | 'vc-dired-mode)))) |
| 2498 | 2500 | ||
| 2501 | ;;; Experimental code for the vc-dired replacement | ||
| 2502 | (require 'ewoc) | ||
| 2503 | |||
| 2504 | (defstruct (vc-status-fileinfo | ||
| 2505 | (:copier nil) | ||
| 2506 | (:constructor vc-status-create-fileinfo (state name &optional marked)) | ||
| 2507 | (:conc-name vc-status-fileinfo->)) | ||
| 2508 | marked | ||
| 2509 | state | ||
| 2510 | name) | ||
| 2511 | |||
| 2512 | (defvar vc-status nil) | ||
| 2513 | |||
| 2514 | (defun vc-status-insert-headers (backend dir) | ||
| 2515 | (insert (format "VC backend :%s\n" backend)) | ||
| 2516 | (insert "Repository : The repository goes here\n") | ||
| 2517 | (insert (format "Working dir: %s\n\n\n" dir))) | ||
| 2518 | |||
| 2519 | (defun vc-status-printer (fileentry) | ||
| 2520 | "Pretty print FILEENTRY." | ||
| 2521 | (insert | ||
| 2522 | (format "%c %-20s %s" | ||
| 2523 | (if (vc-status-fileinfo->marked fileentry) ?* ? ) | ||
| 2524 | (vc-status-fileinfo->state fileentry) | ||
| 2525 | (vc-status-fileinfo->name fileentry)))) | ||
| 2526 | |||
| 2527 | (defun vc-status (dir) | ||
| 2528 | "Show the VC status for DIR." | ||
| 2529 | (interactive "DVC status for directory: ") | ||
| 2530 | (vc-setup-buffer "*vc-status*") | ||
| 2531 | (switch-to-buffer "*vc-status*") | ||
| 2532 | (cd dir) | ||
| 2533 | (vc-status-mode)) | ||
| 2534 | |||
| 2535 | (defvar vc-status-mode-map | ||
| 2536 | (let ((map (make-sparse-keymap))) | ||
| 2537 | (define-key map "m" 'vc-status-mark-file) | ||
| 2538 | (define-key map "u" 'vc-status-unmark-file) | ||
| 2539 | map) | ||
| 2540 | "Keymap for VC status") | ||
| 2541 | |||
| 2542 | (defun vc-status-mode () | ||
| 2543 | "Major mode for VC status. | ||
| 2544 | \\{vc-status-mode-map}" | ||
| 2545 | (setq mode-name "*VC Status*") | ||
| 2546 | (setq major-mode 'vc-status-mode) | ||
| 2547 | (setq buffer-read-only t) | ||
| 2548 | (use-local-map vc-status-mode-map) | ||
| 2549 | (let ((buffer-read-only nil) | ||
| 2550 | (backend (vc-responsible-backend default-directory)) | ||
| 2551 | entries) | ||
| 2552 | (erase-buffer) | ||
| 2553 | (set (make-local-variable 'vc-status) | ||
| 2554 | (ewoc-create #'vc-status-printer)) | ||
| 2555 | (vc-status-insert-headers backend default-directory) | ||
| 2556 | (setq entries (vc-call-backend backend 'dir-status default-directory)) | ||
| 2557 | (dolist (entry entries) | ||
| 2558 | (ewoc-enter-last | ||
| 2559 | vc-status (vc-status-create-fileinfo (cdr entry) (car entry)))))) | ||
| 2560 | |||
| 2561 | (defun vc-status-mark-file () | ||
| 2562 | "Mark the current file." | ||
| 2563 | (interactive) | ||
| 2564 | (let* ((crt (ewoc-locate vc-status)) | ||
| 2565 | (file (ewoc-data crt))) | ||
| 2566 | (setf (vc-status-fileinfo->marked file) t) | ||
| 2567 | (ewoc-invalidate vc-status crt) | ||
| 2568 | (ewoc-goto-next vc-status 1))) | ||
| 2569 | |||
| 2570 | (defun vc-status-unmark-file () | ||
| 2571 | "Mark the current file." | ||
| 2572 | (interactive) | ||
| 2573 | (let* ((crt (ewoc-locate vc-status)) | ||
| 2574 | (file (ewoc-data crt))) | ||
| 2575 | (setf (vc-status-fileinfo->marked file) nil) | ||
| 2576 | (ewoc-invalidate vc-status crt) | ||
| 2577 | (ewoc-goto-next vc-status 1))) | ||
| 2578 | |||
| 2579 | (defun vc-status-marked-files () | ||
| 2580 | "Return the list of marked files" | ||
| 2581 | (mapcar | ||
| 2582 | (lambda (elem) | ||
| 2583 | (expand-file-name (vc-status-fileinfo->name elem))) | ||
| 2584 | (ewoc-collect | ||
| 2585 | vc-status | ||
| 2586 | (lambda (crt) (vc-status-fileinfo->marked crt))))) | ||
| 2587 | |||
| 2588 | ;;; End experimental code. | ||
| 2499 | 2589 | ||
| 2500 | ;; Named-configuration entry points | 2590 | ;; Named-configuration entry points |
| 2501 | 2591 | ||