aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2008-01-09 05:19:04 +0000
committerDan Nicolaescu2008-01-09 05:19:04 +0000
commitca8dfeda7c6edcfeacb95a2e2d3b5dcb3841886c (patch)
tree666f8dfd5edf648440eec09532997a6e58fc9eea
parent15b18fea8169cce339f2f792ce1eee44d2de03e0 (diff)
downloademacs-ca8dfeda7c6edcfeacb95a2e2d3b5dcb3841886c.tar.gz
emacs-ca8dfeda7c6edcfeacb95a2e2d3b5dcb3841886c.zip
* vc.el (vc-status-headers): Rename from
vc-status-insert-headers. Just return header. (vc-status-move-to-goal-column): New function. (vc-status-mode-map): Define more keys. (vc-status-mode): Use vc-status-refresh. Now 'special. (vc-status-refresh): New function. (vc-status-next-line): Likewise. (vc-status-previous-line): Likewise. (vc-status-mark-file): Use vc-status-next-line. (vc-status-unmark-file): Use vc-status-previous-line. (vc-status-unmark-file-up): New function. (vc-status-register): Likewise. (vc-status-find-file): Likewise. (vc-status-find-file-other-window): Likewise. (vc-status-current-file): Likewise. (vc-ensure-vc-buffer): Understand vc-status mode.
-rw-r--r--lisp/ChangeLog17
-rw-r--r--lisp/vc.el128
2 files changed, 127 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index eac75b01c7f..686852c7dd0 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,22 @@
12008-01-09 Tom Tromey <tromey@redhat.com> 12008-01-09 Tom Tromey <tromey@redhat.com>
2 2
3 * vc.el (vc-status-headers): Rename from
4 vc-status-insert-headers. Just return header.
5 (vc-status-move-to-goal-column): New function.
6 (vc-status-mode-map): Define more keys.
7 (vc-status-mode): Use vc-status-refresh. Now 'special.
8 (vc-status-refresh): New function.
9 (vc-status-next-line): Likewise.
10 (vc-status-previous-line): Likewise.
11 (vc-status-mark-file): Use vc-status-next-line.
12 (vc-status-unmark-file): Use vc-status-previous-line.
13 (vc-status-unmark-file-up): New function.
14 (vc-status-register): Likewise.
15 (vc-status-find-file): Likewise.
16 (vc-status-find-file-other-window): Likewise.
17 (vc-status-current-file): Likewise.
18 (vc-ensure-vc-buffer): Understand vc-status mode.
19
3 * vc-hg.el (vc-hg-dir-status): Don't pass -A to "hg status". 20 * vc-hg.el (vc-hg-dir-status): Don't pass -A to "hg status".
4 21
52008-01-09 Glenn Morris <rgm@gnu.org> 222008-01-09 Glenn Morris <rgm@gnu.org>
diff --git a/lisp/vc.el b/lisp/vc.el
index 61a2c67d9d4..6e170ab1464 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -1307,8 +1307,12 @@ Otherwise, throw an error."
1307 1307
1308(defun vc-ensure-vc-buffer () 1308(defun vc-ensure-vc-buffer ()
1309 "Make sure that the current buffer visits a version-controlled file." 1309 "Make sure that the current buffer visits a version-controlled file."
1310 (if vc-dired-mode 1310 (cond
1311 (set-buffer (find-file-noselect (dired-get-filename))) 1311 (vc-dired-mode
1312 (set-buffer (find-file-noselect (dired-get-filename))))
1313 ((eq major-mode 'vc-status-mode)
1314 (set-buffer (find-file-noselect (vc-status-current-file))))
1315 (t
1312 (while (and vc-parent-buffer 1316 (while (and vc-parent-buffer
1313 (buffer-live-p vc-parent-buffer) 1317 (buffer-live-p vc-parent-buffer)
1314 ;; Avoid infinite looping when vc-parent-buffer and 1318 ;; Avoid infinite looping when vc-parent-buffer and
@@ -1318,7 +1322,7 @@ Otherwise, throw an error."
1318 (if (not buffer-file-name) 1322 (if (not buffer-file-name)
1319 (error "Buffer %s is not associated with a file" (buffer-name)) 1323 (error "Buffer %s is not associated with a file" (buffer-name))
1320 (if (not (vc-backend buffer-file-name)) 1324 (if (not (vc-backend buffer-file-name))
1321 (error "File %s is not under version control" buffer-file-name))))) 1325 (error "File %s is not under version control" buffer-file-name))))))
1322 1326
1323;;; Support for the C-x v v command. This is where all the single-file-oriented 1327;;; Support for the C-x v v command. This is where all the single-file-oriented
1324;;; code from before the fileset rewrite lives. 1328;;; code from before the fileset rewrite lives.
@@ -2512,19 +2516,26 @@ With prefix arg READ-SWITCHES, specify a value to override
2512 2516
2513(defvar vc-status nil) 2517(defvar vc-status nil)
2514 2518
2515(defun vc-status-insert-headers (backend dir) 2519(defun vc-status-headers (backend dir)
2516 (insert (format "VC backend :%s\n" backend)) 2520 (concat
2517 (insert "Repository : The repository goes here\n") 2521 (format "VC backend : %s\n" backend)
2518 (insert (format "Working dir: %s\n\n\n" dir))) 2522 "Repository : The repository goes here\n"
2523 (format "Working dir: %s\n" dir)))
2519 2524
2520(defun vc-status-printer (fileentry) 2525(defun vc-status-printer (fileentry)
2521 "Pretty print FILEENTRY." 2526 "Pretty print FILEENTRY."
2522 (insert 2527 (insert
2528 ;; If you change this, change vc-status-move-to-goal-column.
2523 (format "%c %-20s %s" 2529 (format "%c %-20s %s"
2524 (if (vc-status-fileinfo->marked fileentry) ?* ? ) 2530 (if (vc-status-fileinfo->marked fileentry) ?* ? )
2525 (vc-status-fileinfo->state fileentry) 2531 (vc-status-fileinfo->state fileentry)
2526 (vc-status-fileinfo->name fileentry)))) 2532 (vc-status-fileinfo->name fileentry))))
2527 2533
2534(defun vc-status-move-to-goal-column ()
2535 (beginning-of-line)
2536 ;; Must be in sync with vc-status-printer.
2537 (forward-char 25))
2538
2528(defun vc-status (dir) 2539(defun vc-status (dir)
2529 "Show the VC status for DIR." 2540 "Show the VC status for DIR."
2530 (interactive "DVC status for directory: ") 2541 (interactive "DVC status for directory: ")
@@ -2534,9 +2545,30 @@ With prefix arg READ-SWITCHES, specify a value to override
2534 (vc-status-mode)) 2545 (vc-status-mode))
2535 2546
2536(defvar vc-status-mode-map 2547(defvar vc-status-mode-map
2537 (let ((map (make-sparse-keymap))) 2548 (let ((map (make-keymap)))
2549 (suppress-keymap map)
2550 ;; Marking.
2538 (define-key map "m" 'vc-status-mark-file) 2551 (define-key map "m" 'vc-status-mark-file)
2539 (define-key map "u" 'vc-status-unmark-file) 2552 (define-key map "u" 'vc-status-unmark-file)
2553 (define-key map "\C-?" 'vc-status-unmark-file-up)
2554 ;; Movement.
2555 (define-key map "n" 'vc-status-next-line)
2556 (define-key map " " 'vc-status-next-line)
2557 (define-key map "\t" 'vc-status-next-line)
2558 (define-key map "p" 'vc-status-previous-line)
2559 (define-key map [backtab] 'vc-status-previous-line)
2560 ;; VC commands.
2561 (define-key map "=" 'vc-diff)
2562 (define-key map "a" 'vc-status-register)
2563 ;; Can't be "g" (as in vc map), so "A" for "Annotate".
2564 (define-key map "A" 'vc-annotate)
2565 ;; vc-print-log uses the current buffer, not a file.
2566 ;; (define-key map "l" 'vc-status-print-log)
2567 ;; The remainder.
2568 (define-key map "f" 'vc-status-find-file)
2569 (define-key map "o" 'vc-status-find-file-other-window)
2570 (define-key map "q" 'bury-buffer)
2571 (define-key map "g" 'vc-status-refresh)
2540 map) 2572 map)
2541 "Keymap for VC status") 2573 "Keymap for VC status")
2542 2574
@@ -2552,30 +2584,90 @@ With prefix arg READ-SWITCHES, specify a value to override
2552 entries) 2584 entries)
2553 (erase-buffer) 2585 (erase-buffer)
2554 (set (make-local-variable 'vc-status) 2586 (set (make-local-variable 'vc-status)
2555 (ewoc-create #'vc-status-printer)) 2587 (ewoc-create #'vc-status-printer
2556 (vc-status-insert-headers backend default-directory) 2588 (vc-status-headers backend default-directory)))
2557 (setq entries (vc-call-backend backend 'dir-status default-directory)) 2589 (vc-status-refresh)))
2558 (dolist (entry entries) 2590
2559 (ewoc-enter-last 2591(put 'vc-status-mode 'mode-class 'special)
2560 vc-status (vc-status-create-fileinfo (cdr entry) (car entry)))))) 2592
2593(defun vc-status-refresh ()
2594 "Refresh the contents of the VC status buffer."
2595 (interactive)
2596 ;; This is not very efficient; ewoc could use a new function here.
2597 (ewoc-filter vc-status (lambda (node) nil))
2598 (let ((backend (vc-responsible-backend default-directory)))
2599 (dolist (entry (vc-call-backend backend 'dir-status default-directory))
2600 (ewoc-enter-last vc-status
2601 (vc-status-create-fileinfo (cdr entry) (car entry)))))
2602 (ewoc-goto-node vc-status (ewoc-nth vc-status 0)))
2603
2604(defun vc-status-next-line (arg)
2605 "Go to the next line.
2606If a prefix argument is given, move by that many lines."
2607 (interactive "p")
2608 (ewoc-goto-next vc-status arg)
2609 (vc-status-move-to-goal-column))
2610
2611(defun vc-status-previous-line (arg)
2612 "Go to the previous line.
2613If a prefix argument is given, move by that many lines."
2614 (interactive "p")
2615 (ewoc-goto-prev vc-status arg)
2616 (vc-status-move-to-goal-column))
2561 2617
2562(defun vc-status-mark-file () 2618(defun vc-status-mark-file ()
2563 "Mark the current file." 2619 "Mark the current file and move to the next line."
2564 (interactive) 2620 (interactive)
2565 (let* ((crt (ewoc-locate vc-status)) 2621 (let* ((crt (ewoc-locate vc-status))
2566 (file (ewoc-data crt))) 2622 (file (ewoc-data crt)))
2567 (setf (vc-status-fileinfo->marked file) t) 2623 (setf (vc-status-fileinfo->marked file) t)
2568 (ewoc-invalidate vc-status crt) 2624 (ewoc-invalidate vc-status crt)
2569 (ewoc-goto-next vc-status 1))) 2625 (vc-status-next-line 1)))
2570 2626
2571(defun vc-status-unmark-file () 2627(defun vc-status-unmark-file ()
2572 "Mark the current file." 2628 "Unmark the current file and move to the next line."
2573 (interactive) 2629 (interactive)
2574 (let* ((crt (ewoc-locate vc-status)) 2630 (let* ((crt (ewoc-locate vc-status))
2575 (file (ewoc-data crt))) 2631 (file (ewoc-data crt)))
2576 (setf (vc-status-fileinfo->marked file) nil) 2632 (setf (vc-status-fileinfo->marked file) nil)
2577 (ewoc-invalidate vc-status crt) 2633 (ewoc-invalidate vc-status crt)
2578 (ewoc-goto-next vc-status 1))) 2634 (vc-status-next-line 1)))
2635
2636(defun vc-status-unmark-file-up ()
2637 "Move to the previous line and unmark the file."
2638 (interactive)
2639 ;; If we're on the first line, we won't move up, but we will still
2640 ;; remove the mark. This seems a bit odd but it is what buffer-menu
2641 ;; does.
2642 (let* ((prev (ewoc-goto-prev vc-status 1))
2643 (file (ewoc-data prev)))
2644 (setf (vc-status-fileinfo->marked file) nil)
2645 (ewoc-invalidate vc-status prev)
2646 (vc-status-move-to-goal-column)))
2647
2648(defun vc-status-register ()
2649 "Register the marked files, or the current file if no marks."
2650 (interactive)
2651 (let ((files (or (vc-status-marked-files)
2652 (list (vc-status-current-file)))))
2653 (dolist (file files)
2654 (vc-register file))))
2655
2656(defun vc-status-find-file ()
2657 "Find the file on the current line."
2658 (interactive)
2659 (find-file (vc-status-current-file)))
2660
2661(defun vc-status-find-file-other-window ()
2662 "Find the file on the current line, in another window."
2663 (interactive)
2664 (find-file-other-window (vc-status-current-file)))
2665
2666(defun vc-status-current-file ()
2667 (let ((node (ewoc-locate vc-status)))
2668 (unless node
2669 (error "No file available."))
2670 (expand-file-name (vc-status-fileinfo->name (ewoc-data node)))))
2579 2671
2580(defun vc-status-marked-files () 2672(defun vc-status-marked-files ()
2581 "Return the list of marked files" 2673 "Return the list of marked files"