diff options
| author | Dan Nicolaescu | 2008-03-17 16:25:13 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2008-03-17 16:25:13 +0000 |
| commit | 7ee8e7eb0fbe17073ce4ebd94113241eb49669e4 (patch) | |
| tree | f1f67e02b2c8f77b3356945abaadc8300db8c0f4 | |
| parent | 7afdc39150718842ae5cb1cc19e038126430aedf (diff) | |
| download | emacs-7ee8e7eb0fbe17073ce4ebd94113241eb49669e4.tar.gz emacs-7ee8e7eb0fbe17073ce4ebd94113241eb49669e4.zip | |
* vc-bzr.el (vc-bzr-dir-status, vc-bzr-after-dir-status):
New functions to implement vc-status support.
* vc.el (vc-default-extra-status-menu)
(vc-add-to-vc-status-buffer): New functions.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/vc-bzr.el | 80 | ||||
| -rw-r--r-- | lisp/vc.el | 26 |
3 files changed, 83 insertions, 29 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 754d2d62d23..6c7fb228944 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2008-03-17 Dan Nicolaescu <dann@ics.uci.edu> | 1 | 2008-03-17 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 2 | ||
| 3 | * vc-bzr.el (vc-bzr-dir-status, vc-bzr-after-dir-status): | ||
| 4 | New functions to implement vc-status support. | ||
| 5 | |||
| 6 | * vc.el (vc-default-extra-status-menu) | ||
| 7 | (vc-add-to-vc-status-buffer): New functions. | ||
| 8 | |||
| 3 | * emacs-lisp/lisp-mode.el (emacs-lisp-mode-map): Add menu entries | 9 | * emacs-lisp/lisp-mode.el (emacs-lisp-mode-map): Add menu entries |
| 4 | for eldoc and ielm. | 10 | for eldoc and ielm. |
| 5 | 11 | ||
diff --git a/lisp/vc-bzr.el b/lisp/vc-bzr.el index d3af75203b0..3022ebb7f10 100644 --- a/lisp/vc-bzr.el +++ b/lisp/vc-bzr.el | |||
| @@ -464,45 +464,26 @@ EDITABLE is ignored." | |||
| 464 | Each line is tagged with the revision number, which has a `help-echo' | 464 | Each line is tagged with the revision number, which has a `help-echo' |
| 465 | property containing author and date information." | 465 | property containing author and date information." |
| 466 | (apply #'vc-bzr-command "annotate" buffer 0 file "--long" "--all" | 466 | (apply #'vc-bzr-command "annotate" buffer 0 file "--long" "--all" |
| 467 | (if revision (list "-r" revision))) | 467 | (when revision (list "-r" revision)))) |
| 468 | (with-current-buffer buffer | ||
| 469 | ;; Store the tags for the annotated source lines in a hash table | ||
| 470 | ;; to allow saving space by sharing the text properties. | ||
| 471 | (setq vc-bzr-annotation-table (make-hash-table :test 'equal)) | ||
| 472 | (goto-char (point-min)) | ||
| 473 | (while (re-search-forward "^\\( *[0-9]+\\) +\\(.+\\) +\\([0-9]\\{8\\}\\) |" | ||
| 474 | nil t) | ||
| 475 | (let* ((rev (match-string 1)) | ||
| 476 | (author (match-string 2)) | ||
| 477 | (date (match-string 3)) | ||
| 478 | (key (match-string 0)) | ||
| 479 | (tag (gethash key vc-bzr-annotation-table))) | ||
| 480 | (unless tag | ||
| 481 | (setq tag (propertize rev 'help-echo (concat "Author: " author | ||
| 482 | ", date: " date) | ||
| 483 | 'mouse-face 'highlight)) | ||
| 484 | (puthash key tag vc-bzr-annotation-table)) | ||
| 485 | (replace-match "") | ||
| 486 | (insert tag " |"))))) | ||
| 487 | 468 | ||
| 488 | (defun vc-bzr-annotate-time () | 469 | (defun vc-bzr-annotate-time () |
| 489 | (when (re-search-forward "^ *[0-9]+ |" nil t) | 470 | (when (re-search-forward "^[0-9]+.* \\([0-9]+ | \\)" nil t) |
| 490 | (let ((prop (get-text-property (line-beginning-position) 'help-echo))) | 471 | (goto-char (match-end 1)) |
| 491 | (string-match "[0-9]+\\'" prop) | 472 | (let ((str (buffer-substring-no-properties |
| 473 | (match-beginning 1) (match-end 1)))) | ||
| 492 | (vc-annotate-convert-time | 474 | (vc-annotate-convert-time |
| 493 | (encode-time 0 0 0 | 475 | (encode-time 0 0 0 |
| 494 | (string-to-number (substring (match-string 0 prop) 6 8)) | 476 | (string-to-number (substring str 6 8)) |
| 495 | (string-to-number (substring (match-string 0 prop) 4 6)) | 477 | (string-to-number (substring str 4 6)) |
| 496 | (string-to-number (substring (match-string 0 prop) 0 4)) | 478 | (string-to-number (substring str 0 4))))))) |
| 497 | ))))) | ||
| 498 | 479 | ||
| 499 | (defun vc-bzr-annotate-extract-revision-at-line () | 480 | (defun vc-bzr-annotate-extract-revision-at-line () |
| 500 | "Return revision for current line of annoation buffer, or nil. | 481 | "Return revision for current line of annoation buffer, or nil. |
| 501 | Return nil if current line isn't annotated." | 482 | Return nil if current line isn't annotated." |
| 502 | (save-excursion | 483 | (save-excursion |
| 503 | (beginning-of-line) | 484 | (beginning-of-line) |
| 504 | (if (looking-at " *\\([0-9]+\\) | ") | 485 | (when (looking-at "\\([0-9.]+\\) ") |
| 505 | (match-string-no-properties 1)))) | 486 | (match-string-no-properties 1)))) |
| 506 | 487 | ||
| 507 | (defun vc-bzr-command-discarding-stderr (command &rest args) | 488 | (defun vc-bzr-command-discarding-stderr (command &rest args) |
| 508 | "Execute shell command COMMAND (with ARGS); return its output and exitcode. | 489 | "Execute shell command COMMAND (with ARGS); return its output and exitcode. |
| @@ -608,6 +589,47 @@ Optional argument LOCALP is always ignored." | |||
| 608 | ;; else fall back to default vc.el representation | 589 | ;; else fall back to default vc.el representation |
| 609 | (vc-default-dired-state-info 'Bzr file))) | 590 | (vc-default-dired-state-info 'Bzr file))) |
| 610 | 591 | ||
| 592 | ;; XXX Experimental function for the vc-dired replacement. | ||
| 593 | ;; XXX: this needs testing, it's probably incomplete. | ||
| 594 | (defun vc-bzr-after-dir-status (update-function status-buffer) | ||
| 595 | (let ((status-str nil) | ||
| 596 | (file nil) | ||
| 597 | (translation '(("+N" . added) | ||
| 598 | ("-D" . removed) | ||
| 599 | (" M" . edited) | ||
| 600 | ;; XXX: what about ignored files? | ||
| 601 | (" D" . deleted) | ||
| 602 | ("? " . unregistered))) | ||
| 603 | (translated nil) | ||
| 604 | (result nil)) | ||
| 605 | (goto-char (point-min)) | ||
| 606 | (while (not (eobp)) | ||
| 607 | (setq status-str | ||
| 608 | (buffer-substring-no-properties (point) (+ (point) 2))) | ||
| 609 | (setq file | ||
| 610 | (buffer-substring-no-properties (+ (point) 4) | ||
| 611 | (line-end-position))) | ||
| 612 | (setq translated (assoc status-str translation)) | ||
| 613 | (push (cons file (cdr translated)) result) | ||
| 614 | (forward-line)) | ||
| 615 | ;; Remove the temporary buffer. | ||
| 616 | (kill-buffer (current-buffer)) | ||
| 617 | (funcall update-function result status-buffer))) | ||
| 618 | |||
| 619 | ;; XXX Experimental function for the vc-dired replacement. | ||
| 620 | ;; XXX This probably needs some further refinement and testing. | ||
| 621 | (defun vc-bzr-dir-status (dir update-function status-buffer) | ||
| 622 | "Return a list of conses (file . state) for DIR." | ||
| 623 | (with-current-buffer | ||
| 624 | (get-buffer-create | ||
| 625 | (expand-file-name " *VC-bzr* tmp status" dir)) | ||
| 626 | (erase-buffer) | ||
| 627 | ;; XXX: Is this the right command to use? | ||
| 628 | (vc-bzr-command "status" (current-buffer) 'async dir "-v" "-S") | ||
| 629 | (vc-exec-after | ||
| 630 | `(vc-bzr-after-dir-status (quote ,update-function) ,status-buffer)) | ||
| 631 | (current-buffer))) | ||
| 632 | |||
| 611 | ;;; Revision completion | 633 | ;;; Revision completion |
| 612 | 634 | ||
| 613 | (defun vc-bzr-complete-with-prefix (prefix action table string pred) | 635 | (defun vc-bzr-complete-with-prefix (prefix action table string pred) |
diff --git a/lisp/vc.el b/lisp/vc.el index 6917afc7a49..742e960fbc7 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -2800,6 +2800,9 @@ With prefix arg READ-SWITCHES, specify a value to override | |||
| 2800 | map) | 2800 | map) |
| 2801 | "Keymap for VC status") | 2801 | "Keymap for VC status") |
| 2802 | 2802 | ||
| 2803 | (defun vc-default-extra-status-menu (backend) | ||
| 2804 | nil) | ||
| 2805 | |||
| 2803 | (defun vc-status-menu-map-filter (orig-binding) | 2806 | (defun vc-status-menu-map-filter (orig-binding) |
| 2804 | (if (boundp 'vc-ignore-menu-filter) | 2807 | (if (boundp 'vc-ignore-menu-filter) |
| 2805 | orig-binding | 2808 | orig-binding |
| @@ -2889,6 +2892,29 @@ With prefix arg READ-SWITCHES, specify a value to override | |||
| 2889 | ;; We are done, turn of the in progress message in the mode-line. | 2892 | ;; We are done, turn of the in progress message in the mode-line. |
| 2890 | (setq mode-line-process nil))) | 2893 | (setq mode-line-process nil))) |
| 2891 | 2894 | ||
| 2895 | (defun vc-add-to-vc-status-buffer (entry buffer) | ||
| 2896 | ;; Add one ENTRY to the vc-status buffer BUFFER. | ||
| 2897 | ;; This will be used to automatically add files with the "modified" | ||
| 2898 | ;; state when saving them. | ||
| 2899 | |||
| 2900 | ;; ENTRY is (FILENAME . STATE) | ||
| 2901 | (with-current-buffer buffer | ||
| 2902 | (let ((crt (ewoc-nth vc-status 0)) | ||
| 2903 | (fname (car entry))) | ||
| 2904 | ;; First try to see if there's already an entry with that name | ||
| 2905 | ;; in the ewoc. | ||
| 2906 | (while (and crt (not (string= (vc-status-fileinfo->name | ||
| 2907 | (ewoc-data crt)) fname))) | ||
| 2908 | (setq crt (ewoc-next vc-status crt))) | ||
| 2909 | (if crt | ||
| 2910 | (progn | ||
| 2911 | ;; Found the file, just update the status. | ||
| 2912 | (setf (vc-status-fileinfo->state (ewoc-data crt)) (cdr entry)) | ||
| 2913 | (ewoc-invalidate vc-status crt)) | ||
| 2914 | ;; Could not find the file, insert a new entry. | ||
| 2915 | (ewoc-enter-last | ||
| 2916 | vc-status (vc-status-create-fileinfo (cdr entry) (car entry))))))) | ||
| 2917 | |||
| 2892 | (defun vc-status-refresh () | 2918 | (defun vc-status-refresh () |
| 2893 | "Refresh the contents of the VC status buffer." | 2919 | "Refresh the contents of the VC status buffer." |
| 2894 | (interactive) | 2920 | (interactive) |