Mercurial > emacs
comparison lisp/vc.el @ 83428:d0eee3282e6b
Merged from miles@gnu.org--gnu-2005 (patch 678-680)
Patches applied:
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-678
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-679
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-680
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-468
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Thu, 29 Dec 2005 04:41:02 +0000 |
parents | 14a4eb789b45 f4a3c7808545 |
children | ec395f552d45 |
comparison
equal
deleted
inserted
replaced
83427:2afc49c9f0c0 | 83428:d0eee3282e6b |
---|---|
467 (defgroup vc nil | 467 (defgroup vc nil |
468 "Version-control system in Emacs." | 468 "Version-control system in Emacs." |
469 :group 'tools) | 469 :group 'tools) |
470 | 470 |
471 (defcustom vc-suppress-confirm nil | 471 (defcustom vc-suppress-confirm nil |
472 "*If non-nil, treat user as expert; suppress yes-no prompts on some things." | 472 "If non-nil, treat user as expert; suppress yes-no prompts on some things." |
473 :type 'boolean | 473 :type 'boolean |
474 :group 'vc) | 474 :group 'vc) |
475 | 475 |
476 (defcustom vc-delete-logbuf-window t | 476 (defcustom vc-delete-logbuf-window t |
477 "*If non-nil, delete the *VC-log* buffer and window after each logical action. | 477 "If non-nil, delete the *VC-log* buffer and window after each logical action. |
478 If nil, bury that buffer instead. | 478 If nil, bury that buffer instead. |
479 This is most useful if you have multiple windows on a frame and would like to | 479 This is most useful if you have multiple windows on a frame and would like to |
480 preserve the setting." | 480 preserve the setting." |
481 :type 'boolean | 481 :type 'boolean |
482 :group 'vc) | 482 :group 'vc) |
483 | 483 |
484 (defcustom vc-initial-comment nil | 484 (defcustom vc-initial-comment nil |
485 "*If non-nil, prompt for initial comment when a file is registered." | 485 "If non-nil, prompt for initial comment when a file is registered." |
486 :type 'boolean | 486 :type 'boolean |
487 :group 'vc) | 487 :group 'vc) |
488 | 488 |
489 (defcustom vc-default-init-version "1.1" | 489 (defcustom vc-default-init-version "1.1" |
490 "*A string used as the default version number when a new file is registered. | 490 "A string used as the default version number when a new file is registered. |
491 This can be overridden by giving a prefix argument to \\[vc-register]. This | 491 This can be overridden by giving a prefix argument to \\[vc-register]. This |
492 can also be overridden by a particular VC backend." | 492 can also be overridden by a particular VC backend." |
493 :type 'string | 493 :type 'string |
494 :group 'vc | 494 :group 'vc |
495 :version "20.3") | 495 :version "20.3") |
496 | 496 |
497 (defcustom vc-command-messages nil | 497 (defcustom vc-command-messages nil |
498 "*If non-nil, display run messages from back-end commands." | 498 "If non-nil, display run messages from back-end commands." |
499 :type 'boolean | 499 :type 'boolean |
500 :group 'vc) | 500 :group 'vc) |
501 | 501 |
502 (defcustom vc-checkin-switches nil | 502 (defcustom vc-checkin-switches nil |
503 "*A string or list of strings specifying extra switches for checkin. | 503 "A string or list of strings specifying extra switches for checkin. |
504 These are passed to the checkin program by \\[vc-checkin]." | 504 These are passed to the checkin program by \\[vc-checkin]." |
505 :type '(choice (const :tag "None" nil) | 505 :type '(choice (const :tag "None" nil) |
506 (string :tag "Argument String") | 506 (string :tag "Argument String") |
507 (repeat :tag "Argument List" | 507 (repeat :tag "Argument List" |
508 :value ("") | 508 :value ("") |
509 string)) | 509 string)) |
510 :group 'vc) | 510 :group 'vc) |
511 | 511 |
512 (defcustom vc-checkout-switches nil | 512 (defcustom vc-checkout-switches nil |
513 "*A string or list of strings specifying extra switches for checkout. | 513 "A string or list of strings specifying extra switches for checkout. |
514 These are passed to the checkout program by \\[vc-checkout]." | 514 These are passed to the checkout program by \\[vc-checkout]." |
515 :type '(choice (const :tag "None" nil) | 515 :type '(choice (const :tag "None" nil) |
516 (string :tag "Argument String") | 516 (string :tag "Argument String") |
517 (repeat :tag "Argument List" | 517 (repeat :tag "Argument List" |
518 :value ("") | 518 :value ("") |
519 string)) | 519 string)) |
520 :group 'vc) | 520 :group 'vc) |
521 | 521 |
522 (defcustom vc-register-switches nil | 522 (defcustom vc-register-switches nil |
523 "*A string or list of strings; extra switches for registering a file. | 523 "A string or list of strings; extra switches for registering a file. |
524 These are passed to the checkin program by \\[vc-register]." | 524 These are passed to the checkin program by \\[vc-register]." |
525 :type '(choice (const :tag "None" nil) | 525 :type '(choice (const :tag "None" nil) |
526 (string :tag "Argument String") | 526 (string :tag "Argument String") |
527 (repeat :tag "Argument List" | 527 (repeat :tag "Argument List" |
528 :value ("") | 528 :value ("") |
529 string)) | 529 string)) |
530 :group 'vc) | 530 :group 'vc) |
531 | 531 |
532 (defcustom vc-dired-listing-switches "-al" | 532 (defcustom vc-dired-listing-switches "-al" |
533 "*Switches passed to `ls' for vc-dired. MUST contain the `l' option." | 533 "Switches passed to `ls' for vc-dired. MUST contain the `l' option." |
534 :type 'string | 534 :type 'string |
535 :group 'vc | 535 :group 'vc |
536 :version "21.1") | 536 :version "21.1") |
537 | 537 |
538 (defcustom vc-dired-recurse t | 538 (defcustom vc-dired-recurse t |
539 "*If non-nil, show directory trees recursively in VC Dired." | 539 "If non-nil, show directory trees recursively in VC Dired." |
540 :type 'boolean | 540 :type 'boolean |
541 :group 'vc | 541 :group 'vc |
542 :version "20.3") | 542 :version "20.3") |
543 | 543 |
544 (defcustom vc-dired-terse-display t | 544 (defcustom vc-dired-terse-display t |
545 "*If non-nil, show only locked files in VC Dired." | 545 "If non-nil, show only locked files in VC Dired." |
546 :type 'boolean | 546 :type 'boolean |
547 :group 'vc | 547 :group 'vc |
548 :version "20.3") | 548 :version "20.3") |
549 | 549 |
550 (defcustom vc-directory-exclusion-list '("SCCS" "RCS" "CVS" "MCVS" ".svn" "{arch}") | 550 (defcustom vc-directory-exclusion-list '("SCCS" "RCS" "CVS" "MCVS" ".svn" "{arch}") |
551 "*List of directory names to be ignored when walking directory trees." | 551 "List of directory names to be ignored when walking directory trees." |
552 :type '(repeat string) | 552 :type '(repeat string) |
553 :group 'vc) | 553 :group 'vc) |
554 | 554 |
555 (defcustom vc-diff-switches nil | 555 (defcustom vc-diff-switches nil |
556 "*A string or list of strings specifying switches for diff under VC. | 556 "A string or list of strings specifying switches for diff under VC. |
557 When running diff under a given BACKEND, VC concatenates the values of | 557 When running diff under a given BACKEND, VC concatenates the values of |
558 `diff-switches', `vc-diff-switches', and `vc-BACKEND-diff-switches' to | 558 `diff-switches', `vc-diff-switches', and `vc-BACKEND-diff-switches' to |
559 get the switches for that command. Thus, `vc-diff-switches' should | 559 get the switches for that command. Thus, `vc-diff-switches' should |
560 contain switches that are specific to version control, but not | 560 contain switches that are specific to version control, but not |
561 specific to any particular backend." | 561 specific to any particular backend." |
566 string)) | 566 string)) |
567 :group 'vc | 567 :group 'vc |
568 :version "21.1") | 568 :version "21.1") |
569 | 569 |
570 (defcustom vc-allow-async-revert nil | 570 (defcustom vc-allow-async-revert nil |
571 "*Specifies whether the diff during \\[vc-revert-buffer] may be asynchronous. | 571 "Specifies whether the diff during \\[vc-revert-buffer] may be asynchronous. |
572 Enabling this option means that you can confirm a revert operation even | 572 Enabling this option means that you can confirm a revert operation even |
573 if the local changes in the file have not been found and displayed yet." | 573 if the local changes in the file have not been found and displayed yet." |
574 :type '(choice (const :tag "No" nil) | 574 :type '(choice (const :tag "No" nil) |
575 (const :tag "Yes" t)) | 575 (const :tag "Yes" t)) |
576 :group 'vc | 576 :group 'vc |
577 :version "22.1") | 577 :version "22.1") |
578 | 578 |
579 ;;;###autoload | 579 ;;;###autoload |
580 (defcustom vc-checkout-hook nil | 580 (defcustom vc-checkout-hook nil |
581 "*Normal hook (list of functions) run after checking out a file. | 581 "Normal hook (list of functions) run after checking out a file. |
582 See `run-hooks'." | 582 See `run-hooks'." |
583 :type 'hook | 583 :type 'hook |
584 :group 'vc | 584 :group 'vc |
585 :version "21.1") | 585 :version "21.1") |
586 | 586 |
593 :value "20.5")) | 593 :value "20.5")) |
594 :group 'vc) | 594 :group 'vc) |
595 | 595 |
596 ;;;###autoload | 596 ;;;###autoload |
597 (defcustom vc-checkin-hook nil | 597 (defcustom vc-checkin-hook nil |
598 "*Normal hook (list of functions) run after a checkin is done. | 598 "Normal hook (list of functions) run after a checkin is done. |
599 See also `log-edit-done-hook'." | 599 See also `log-edit-done-hook'." |
600 :type 'hook | 600 :type 'hook |
601 :options '(log-edit-comment-to-change-log) | 601 :options '(log-edit-comment-to-change-log) |
602 :group 'vc) | 602 :group 'vc) |
603 | 603 |
604 ;;;###autoload | 604 ;;;###autoload |
605 (defcustom vc-before-checkin-hook nil | 605 (defcustom vc-before-checkin-hook nil |
606 "*Normal hook (list of functions) run before a file is checked in. | 606 "Normal hook (list of functions) run before a file is checked in. |
607 See `run-hooks'." | 607 See `run-hooks'." |
608 :type 'hook | 608 :type 'hook |
609 :group 'vc) | 609 :group 'vc) |
610 | 610 |
611 (defcustom vc-logentry-check-hook nil | 611 (defcustom vc-logentry-check-hook nil |
612 "*Normal hook run by `vc-backend-logentry-check'. | 612 "Normal hook run by `vc-backend-logentry-check'. |
613 Use this to impose your own rules on the entry in addition to any the | 613 Use this to impose your own rules on the entry in addition to any the |
614 version control backend imposes itself." | 614 version control backend imposes itself." |
615 :type 'hook | 615 :type 'hook |
616 :group 'vc) | 616 :group 'vc) |
617 | 617 |
632 (260. . "#66CC00") | 632 (260. . "#66CC00") |
633 (280. . "#33CC33") | 633 (280. . "#33CC33") |
634 (300. . "#00CCFF") | 634 (300. . "#00CCFF") |
635 (320. . "#00CC99") | 635 (320. . "#00CC99") |
636 (340. . "#0099FF")) | 636 (340. . "#0099FF")) |
637 "*Association list of age versus color, for \\[vc-annotate]. | 637 "Association list of age versus color, for \\[vc-annotate]. |
638 Ages are given in units of fractional days. Default is eighteen steps | 638 Ages are given in units of fractional days. Default is eighteen steps |
639 using a twenty day increment." | 639 using a twenty day increment." |
640 :type 'alist | 640 :type 'alist |
641 :group 'vc) | 641 :group 'vc) |
642 | 642 |
643 (defcustom vc-annotate-very-old-color "#0046FF" | 643 (defcustom vc-annotate-very-old-color "#0046FF" |
644 "*Color for lines older than the current color range in \\[vc-annotate]]." | 644 "Color for lines older than the current color range in \\[vc-annotate]]." |
645 :type 'string | 645 :type 'string |
646 :group 'vc) | 646 :group 'vc) |
647 | 647 |
648 (defcustom vc-annotate-background "black" | 648 (defcustom vc-annotate-background "black" |
649 "*Background color for \\[vc-annotate]. | 649 "Background color for \\[vc-annotate]. |
650 Default color is used if nil." | 650 Default color is used if nil." |
651 :type 'string | 651 :type 'string |
652 :group 'vc) | 652 :group 'vc) |
653 | 653 |
654 (defcustom vc-annotate-menu-elements '(2 0.5 0.1 0.01) | 654 (defcustom vc-annotate-menu-elements '(2 0.5 0.1 0.01) |
655 "*Menu elements for the mode-specific menu of VC-Annotate mode. | 655 "Menu elements for the mode-specific menu of VC-Annotate mode. |
656 List of factors, used to expand/compress the time scale. See `vc-annotate'." | 656 List of factors, used to expand/compress the time scale. See `vc-annotate'." |
657 :type '(repeat number) | 657 :type '(repeat number) |
658 :group 'vc) | 658 :group 'vc) |
659 | 659 |
660 (defvar vc-annotate-mode-map | 660 (defvar vc-annotate-mode-map |
661 (let ((m (make-sparse-keymap))) | 661 (let ((m (make-sparse-keymap))) |
662 (define-key m [menu-bar] (make-sparse-keymap "VC-Annotate")) | 662 (define-key m [menu-bar] (make-sparse-keymap "VC-Annotate")) |
663 (define-key m "A" 'vc-annotate-revision-previous-to-line) | |
664 (define-key m "D" 'vc-annotate-show-diff-revision-at-line) | |
665 (define-key m "J" 'vc-annotate-revision-at-line) | |
666 (define-key m "L" 'vc-annotate-show-log-revision-at-line) | |
667 (define-key m "N" 'vc-annotate-next-version) | |
668 (define-key m "P" 'vc-annotate-prev-version) | |
669 (define-key m "W" 'vc-annotate-workfile-version) | |
663 m) | 670 m) |
664 "Local keymap used for VC-Annotate mode.") | 671 "Local keymap used for VC-Annotate mode.") |
665 | 672 |
666 (define-key vc-annotate-mode-map "A" 'vc-annotate-revision-previous-to-line) | |
667 (define-key vc-annotate-mode-map "D" 'vc-annotate-show-diff-revision-at-line) | |
668 (define-key vc-annotate-mode-map "J" 'vc-annotate-revision-at-line) | |
669 (define-key vc-annotate-mode-map "L" 'vc-annotate-show-log-revision-at-line) | |
670 (define-key vc-annotate-mode-map "N" 'vc-annotate-next-version) | |
671 (define-key vc-annotate-mode-map "P" 'vc-annotate-prev-version) | |
672 (define-key vc-annotate-mode-map "W" 'vc-annotate-workfile-version) | |
673 | |
674 (defvar vc-annotate-mode-menu nil | 673 (defvar vc-annotate-mode-menu nil |
675 "Local keymap used for VC-Annotate mode's menu bar menu.") | 674 "Local keymap used for VC-Annotate mode's menu bar menu.") |
676 | 675 |
677 ;; Header-insertion hair | 676 ;; Header-insertion hair |
678 | 677 |
679 (defcustom vc-static-header-alist | 678 (defcustom vc-static-header-alist |
680 '(("\\.c$" . | 679 '(("\\.c\\'" . |
681 "\n#ifndef lint\nstatic char vcid[] = \"\%s\";\n#endif /* lint */\n")) | 680 "\n#ifndef lint\nstatic char vcid[] = \"\%s\";\n#endif /* lint */\n")) |
682 "*Associate static header string templates with file types. | 681 "*Associate static header string templates with file types. |
683 A \%s in the template is replaced with the first string associated with | 682 A \%s in the template is replaced with the first string associated with |
684 the file's version control type in `vc-header-alist'." | 683 the file's version control type in `vc-header-alist'." |
685 :type '(repeat (cons :format "%v" | 684 :type '(repeat (cons :format "%v" |
711 | 710 |
712 | 711 |
713 ;; Variables the user doesn't need to know about. | 712 ;; Variables the user doesn't need to know about. |
714 (defvar vc-log-operation nil) | 713 (defvar vc-log-operation nil) |
715 (defvar vc-log-after-operation-hook nil) | 714 (defvar vc-log-after-operation-hook nil) |
716 (defvar vc-annotate-buffers nil | 715 |
717 "Alist of current \"Annotate\" buffers and their corresponding backends. | |
718 The keys are \(BUFFER . BACKEND\). See also `vc-annotate-get-backend'.") | |
719 ;; In a log entry buffer, this is a local variable | 716 ;; In a log entry buffer, this is a local variable |
720 ;; that points to the buffer for which it was made | 717 ;; that points to the buffer for which it was made |
721 ;; (either a file, or a VC dired buffer). | 718 ;; (either a file, or a VC dired buffer). |
722 (defvar vc-parent-buffer nil) | 719 (defvar vc-parent-buffer nil) |
723 (put 'vc-parent-buffer 'permanent-local t) | 720 (put 'vc-parent-buffer 'permanent-local t) |
1365 (vc-next-action-on-file buffer-file-name verbose) | 1362 (vc-next-action-on-file buffer-file-name verbose) |
1366 (error "Buffer %s is not associated with a file" (buffer-name))))) | 1363 (error "Buffer %s is not associated with a file" (buffer-name))))) |
1367 | 1364 |
1368 ;; These functions help the vc-next-action entry point | 1365 ;; These functions help the vc-next-action entry point |
1369 | 1366 |
1367 (defun vc-default-init-version (backend) vc-default-init-version) | |
1368 | |
1370 ;;;###autoload | 1369 ;;;###autoload |
1371 (defun vc-register (&optional set-version comment) | 1370 (defun vc-register (&optional set-version comment) |
1372 "Register the current file into a version control system. | 1371 "Register the current file into a version control system. |
1373 With prefix argument SET-VERSION, allow user to specify initial version | 1372 With prefix argument SET-VERSION, allow user to specify initial version |
1374 level. If COMMENT is present, use that as an initial comment. | 1373 level. If COMMENT is present, use that as an initial comment. |
1396 | 1395 |
1397 (vc-start-entry buffer-file-name | 1396 (vc-start-entry buffer-file-name |
1398 (if set-version | 1397 (if set-version |
1399 (read-string (format "Initial version level for %s: " | 1398 (read-string (format "Initial version level for %s: " |
1400 (buffer-name))) | 1399 (buffer-name))) |
1401 (let ((backend (vc-responsible-backend buffer-file-name))) | 1400 (vc-call-backend (vc-responsible-backend buffer-file-name) |
1402 (if (vc-find-backend-function backend 'init-version) | 1401 'init-version)) |
1403 (vc-call-backend backend 'init-version) | |
1404 vc-default-init-version))) | |
1405 (or comment (not vc-initial-comment)) | 1402 (or comment (not vc-initial-comment)) |
1406 nil | 1403 nil |
1407 "Enter initial comment." | 1404 "Enter initial comment." |
1408 (lambda (file rev comment) | 1405 (lambda (file rev comment) |
1409 (message "Registering %s... " file) | 1406 (message "Registering %s... " file) |
1935 (save-excursion | 1932 (save-excursion |
1936 (save-restriction | 1933 (save-restriction |
1937 (widen) | 1934 (widen) |
1938 (if (or (not (vc-check-headers)) | 1935 (if (or (not (vc-check-headers)) |
1939 (y-or-n-p "Version headers already exist. Insert another set? ")) | 1936 (y-or-n-p "Version headers already exist. Insert another set? ")) |
1940 (progn | 1937 (let* ((delims (cdr (assq major-mode vc-comment-alist))) |
1941 (let* ((delims (cdr (assq major-mode vc-comment-alist))) | 1938 (comment-start-vc (or (car delims) comment-start "#")) |
1942 (comment-start-vc (or (car delims) comment-start "#")) | 1939 (comment-end-vc (or (car (cdr delims)) comment-end "")) |
1943 (comment-end-vc (or (car (cdr delims)) comment-end "")) | 1940 (hdsym (vc-make-backend-sym (vc-backend buffer-file-name) |
1944 (hdsym (vc-make-backend-sym (vc-backend buffer-file-name) | 1941 'header)) |
1945 'header)) | 1942 (hdstrings (and (boundp hdsym) (symbol-value hdsym)))) |
1946 (hdstrings (and (boundp hdsym) (symbol-value hdsym)))) | 1943 (dolist (s hdstrings) |
1947 (mapcar (lambda (s) | 1944 (insert comment-start-vc "\t" s "\t" |
1948 (insert comment-start-vc "\t" s "\t" | 1945 comment-end-vc "\n")) |
1949 comment-end-vc "\n")) | 1946 (if vc-static-header-alist |
1950 hdstrings) | 1947 (dolist (f vc-static-header-alist) |
1951 (if vc-static-header-alist | 1948 (if (string-match (car f) buffer-file-name) |
1952 (mapcar (lambda (f) | 1949 (insert (format (cdr f) (car hdstrings))))))))))) |
1953 (if (string-match (car f) buffer-file-name) | |
1954 (insert (format (cdr f) (car hdstrings))))) | |
1955 vc-static-header-alist)) | |
1956 ) | |
1957 ))))) | |
1958 | 1950 |
1959 (defun vc-clear-headers (&optional file) | 1951 (defun vc-clear-headers (&optional file) |
1960 "Clear all version headers in the current buffer (or FILE). | 1952 "Clear all version headers in the current buffer (or FILE). |
1961 The headers are reset to their non-expanded form." | 1953 The headers are reset to their non-expanded form." |
1962 (let* ((filename (or file buffer-file-name)) | 1954 (let* ((filename (or file buffer-file-name)) |
2895 (if (file-name-absolute-p f) | 2887 (if (file-name-absolute-p f) |
2896 f | 2888 f |
2897 (concat odefault f)))) | 2889 (concat odefault f)))) |
2898 files))) | 2890 files))) |
2899 "done" | 2891 "done" |
2900 (pop-to-buffer | 2892 (pop-to-buffer (get-buffer-create "*vc*")) |
2901 (set-buffer (get-buffer-create "*vc*"))) | |
2902 (erase-buffer) | 2893 (erase-buffer) |
2903 (insert-file-contents tempfile) | 2894 (insert-file-contents tempfile) |
2904 "failed")) | 2895 "failed")) |
2905 (setq default-directory (file-name-directory changelog)) | 2896 (setq default-directory (file-name-directory changelog)) |
2906 (delete-file tempfile))))) | 2897 (delete-file tempfile))))) |
2911 ;; temp-buffer-show-function (not possible to pass more than one | 2902 ;; temp-buffer-show-function (not possible to pass more than one |
2912 ;; parameter). The use of annotate-ratio is deprecated in favor of | 2903 ;; parameter). The use of annotate-ratio is deprecated in favor of |
2913 ;; annotate-mode, which replaces it with the more sensible "span-to | 2904 ;; annotate-mode, which replaces it with the more sensible "span-to |
2914 ;; days", along with autoscaling support. | 2905 ;; days", along with autoscaling support. |
2915 (defvar vc-annotate-ratio nil "Global variable.") | 2906 (defvar vc-annotate-ratio nil "Global variable.") |
2916 (defvar vc-annotate-backend nil "Global variable.") | |
2917 | 2907 |
2918 ;; internal buffer-local variables | 2908 ;; internal buffer-local variables |
2909 (defvar vc-annotate-backend nil) | |
2919 (defvar vc-annotate-parent-file nil) | 2910 (defvar vc-annotate-parent-file nil) |
2920 (defvar vc-annotate-parent-rev nil) | 2911 (defvar vc-annotate-parent-rev nil) |
2921 (defvar vc-annotate-parent-display-mode nil) | 2912 (defvar vc-annotate-parent-display-mode nil) |
2922 | 2913 |
2923 (defconst vc-annotate-font-lock-keywords | 2914 (defconst vc-annotate-font-lock-keywords |
2924 ;; The fontification is done by vc-annotate-lines instead of font-lock. | 2915 ;; The fontification is done by vc-annotate-lines instead of font-lock. |
2925 '((vc-annotate-lines))) | 2916 '((vc-annotate-lines))) |
2926 | |
2927 (defun vc-annotate-get-backend (buffer) | |
2928 "Return the backend matching \"Annotate\" buffer BUFFER. | |
2929 Return nil if no match made. Associations are made based on | |
2930 `vc-annotate-buffers'." | |
2931 (cdr (assoc buffer vc-annotate-buffers))) | |
2932 | 2917 |
2933 (define-derived-mode vc-annotate-mode fundamental-mode "Annotate" | 2918 (define-derived-mode vc-annotate-mode fundamental-mode "Annotate" |
2934 "Major mode for output buffers of the `vc-annotate' command. | 2919 "Major mode for output buffers of the `vc-annotate' command. |
2935 | 2920 |
2936 You can use the mode-specific menu to alter the time-span of the used | 2921 You can use the mode-specific menu to alter the time-span of the used |
2937 colors. See variable `vc-annotate-menu-elements' for customizing the | 2922 colors. See variable `vc-annotate-menu-elements' for customizing the |
2938 menu items." | 2923 menu items." |
2939 (set (make-local-variable 'truncate-lines) t) | 2924 (set (make-local-variable 'truncate-lines) t) |
2940 (set (make-local-variable 'font-lock-defaults) | 2925 (set (make-local-variable 'font-lock-defaults) |
2941 '(vc-annotate-font-lock-keywords t)) | 2926 '(vc-annotate-font-lock-keywords t)) |
2942 (view-mode 1) | 2927 (view-mode 1)) |
2943 (vc-annotate-add-menu)) | |
2944 | 2928 |
2945 (defun vc-annotate-display-default (&optional ratio) | 2929 (defun vc-annotate-display-default (&optional ratio) |
2946 "Display the output of \\[vc-annotate] using the default color range. | 2930 "Display the output of \\[vc-annotate] using the default color range. |
2947 The color range is given by `vc-annotate-color-map', scaled by RATIO | 2931 The color range is given by `vc-annotate-color-map', scaled by RATIO |
2948 if present. The current time is used as the offset." | 2932 if present. The current time is used as the offset." |
2949 (interactive "e") | 2933 (interactive "e") |
2950 (message "Redisplaying annotation...") | 2934 (message "Redisplaying annotation...") |
2951 (vc-annotate-display | 2935 (vc-annotate-display |
2952 (if ratio (vc-annotate-time-span vc-annotate-color-map ratio))) | 2936 (if ratio (vc-annotate-time-span vc-annotate-color-map ratio))) |
2953 (message "Redisplaying annotation...done")) | 2937 (message "Redisplaying annotation...done")) |
2938 | |
2939 (defun vc-annotate-car-last-cons (a-list) | |
2940 "Return car of last cons in association list A-LIST." | |
2941 (caar (last a-list))) | |
2954 | 2942 |
2955 (defun vc-annotate-display-autoscale (&optional full) | 2943 (defun vc-annotate-display-autoscale (&optional full) |
2956 "Highlight the output of \\[vc-annotate] using an autoscaled color map. | 2944 "Highlight the output of \\[vc-annotate] using an autoscaled color map. |
2957 Autoscaling means that the map is scaled from the current time to the | 2945 Autoscaling means that the map is scaled from the current time to the |
2958 oldest annotation in the buffer, or, with prefix argument FULL, to | 2946 oldest annotation in the buffer, or, with prefix argument FULL, to |
2985 (- current oldest) | 2973 (- current oldest) |
2986 (- current newest)) | 2974 (- current newest)) |
2987 (format "Spanned to %.1f days old" (- current oldest)))))) | 2975 (format "Spanned to %.1f days old" (- current oldest)))))) |
2988 | 2976 |
2989 ;; Menu -- Using easymenu.el | 2977 ;; Menu -- Using easymenu.el |
2990 (defun vc-annotate-add-menu () | 2978 (easy-menu-define vc-annotate-mode-menu vc-annotate-mode-map |
2991 "Add the menu 'Annotate' to the menu bar in VC-Annotate mode." | 2979 "VC Annotate Display Menu" |
2992 (let ((menu-elements vc-annotate-menu-elements) | 2980 `("VC-Annotate" |
2993 (menu-def | 2981 ["Default" (unless (null vc-annotate-display-mode) |
2994 '("VC-Annotate" | 2982 (setq vc-annotate-display-mode nil) |
2995 ["Default" (unless (null vc-annotate-display-mode) | 2983 (vc-annotate-display-select)) |
2996 (setq vc-annotate-display-mode nil) | 2984 :style toggle :selected (null vc-annotate-display-mode)] |
2997 (vc-annotate-display-select)) | 2985 ,@(let ((oldest-in-map (vc-annotate-car-last-cons vc-annotate-color-map))) |
2998 :style toggle :selected (null vc-annotate-display-mode)])) | 2986 (mapcar (lambda (element) |
2999 (oldest-in-map (vc-annotate-car-last-cons vc-annotate-color-map))) | 2987 (let ((days (* element oldest-in-map))) |
3000 (while menu-elements | 2988 `([,(format "Span %.1f days" days) |
3001 (let* ((element (car menu-elements)) | 2989 (unless (and (numberp vc-annotate-display-mode) |
3002 (days (* element oldest-in-map))) | 2990 (= vc-annotate-display-mode ,days)) |
3003 (setq menu-elements (cdr menu-elements)) | 2991 (vc-annotate-display-select nil ,days)) |
3004 (setq menu-def | 2992 :style toggle :selected |
3005 (append menu-def | 2993 (and (numberp vc-annotate-display-mode) |
3006 `([,(format "Span %.1f days" days) | 2994 (= vc-annotate-display-mode ,days)) ]))) |
3007 (unless (and (numberp vc-annotate-display-mode) | 2995 vc-annotate-menu-elements)) |
3008 (= vc-annotate-display-mode ,days)) | 2996 ["Span ..." |
3009 (vc-annotate-display-select nil ,days)) | 2997 (let ((days |
3010 :style toggle :selected | 2998 (float (string-to-number |
3011 (and (numberp vc-annotate-display-mode) | 2999 (read-string "Span how many days? "))))) |
3012 (= vc-annotate-display-mode ,days)) ]))))) | 3000 (vc-annotate-display-select nil days)) t] |
3013 (setq menu-def | 3001 "--" |
3014 (append menu-def | 3002 ["Span to Oldest" |
3015 (list | 3003 (unless (eq vc-annotate-display-mode 'scale) |
3016 ["Span ..." | 3004 (vc-annotate-display-select nil 'scale)) |
3017 (let ((days | 3005 :style toggle :selected |
3018 (float (string-to-number | 3006 (eq vc-annotate-display-mode 'scale)] |
3019 (read-string "Span how many days? "))))) | 3007 ["Span Oldest->Newest" |
3020 (vc-annotate-display-select nil days)) t]) | 3008 (unless (eq vc-annotate-display-mode 'fullscale) |
3021 (list "--") | 3009 (vc-annotate-display-select nil 'fullscale)) |
3022 (list | 3010 :style toggle :selected |
3023 ["Span to Oldest" | 3011 (eq vc-annotate-display-mode 'fullscale)] |
3024 (unless (eq vc-annotate-display-mode 'scale) | 3012 "--" |
3025 (vc-annotate-display-select nil 'scale)) | 3013 ["Annotate previous revision" vc-annotate-prev-version] |
3026 :style toggle :selected | 3014 ["Annotate next revision" vc-annotate-next-version] |
3027 (eq vc-annotate-display-mode 'scale)]) | 3015 ["Annotate revision at line" vc-annotate-revision-at-line] |
3028 (list | 3016 ["Annotate revision previous to line" vc-annotate-revision-previous-to-line] |
3029 ["Span Oldest->Newest" | 3017 ["Annotate latest revision" vc-annotate-workfile-version] |
3030 (unless (eq vc-annotate-display-mode 'fullscale) | 3018 ["Show log of revision at line" vc-annotate-show-log-revision-at-line] |
3031 (vc-annotate-display-select nil 'fullscale)) | 3019 ["Show diff of revision at line" vc-annotate-show-diff-revision-at-line])) |
3032 :style toggle :selected | |
3033 (eq vc-annotate-display-mode 'fullscale)]) | |
3034 (list "--") | |
3035 (list ["Annotate previous revision" | |
3036 (call-interactively 'vc-annotate-prev-version)]) | |
3037 (list ["Annotate next revision" | |
3038 (call-interactively 'vc-annotate-next-version)]) | |
3039 (list ["Annotate revision at line" | |
3040 (vc-annotate-revision-at-line)]) | |
3041 (list ["Annotate revision previous to line" | |
3042 (vc-annotate-revision-previous-to-line)]) | |
3043 (list ["Annotate latest revision" | |
3044 (vc-annotate-workfile-version)]) | |
3045 (list ["Show log of revision at line" | |
3046 (vc-annotate-show-log-revision-at-line)]) | |
3047 (list ["Show diff of revision at line" | |
3048 (vc-annotate-show-diff-revision-at-line)]))) | |
3049 | |
3050 ;; Define the menu | |
3051 (if (or (featurep 'easymenu) (load "easymenu" t)) | |
3052 (easy-menu-define vc-annotate-mode-menu vc-annotate-mode-map | |
3053 "VC Annotate Display Menu" menu-def)))) | |
3054 | 3020 |
3055 (defun vc-annotate-display-select (&optional buffer mode) | 3021 (defun vc-annotate-display-select (&optional buffer mode) |
3056 "Highlight the output of \\[vc-annotate]. | 3022 "Highlight the output of \\[vc-annotate]. |
3057 By default, the current buffer is highlighted, unless overridden by | 3023 By default, the current buffer is highlighted, unless overridden by |
3058 BUFFER. `vc-annotate-display-mode' specifies the highlighting mode to | 3024 BUFFER. `vc-annotate-display-mode' specifies the highlighting mode to |
3081 ;;;; (defun vc-BACKEND-annotate-command (file buffer) ...) | 3047 ;;;; (defun vc-BACKEND-annotate-command (file buffer) ...) |
3082 ;;;; Execute "annotate" on FILE by using `call-process' and insert | 3048 ;;;; Execute "annotate" on FILE by using `call-process' and insert |
3083 ;;;; the contents in BUFFER. | 3049 ;;;; the contents in BUFFER. |
3084 | 3050 |
3085 ;;;###autoload | 3051 ;;;###autoload |
3086 (defun vc-annotate (prefix &optional revision display-mode) | 3052 (defun vc-annotate (file rev &optional display-mode buf) |
3087 "Display the edit history of the current file using colors. | 3053 "Display the edit history of the current file using colors. |
3088 | 3054 |
3089 This command creates a buffer that shows, for each line of the current | 3055 This command creates a buffer that shows, for each line of the current |
3090 file, when it was last edited and by whom. Additionally, colors are | 3056 file, when it was last edited and by whom. Additionally, colors are |
3091 used to show the age of each line--blue means oldest, red means | 3057 used to show the age of each line--blue means oldest, red means |
3106 | 3072 |
3107 `vc-annotate-menu-elements' customizes the menu elements of the | 3073 `vc-annotate-menu-elements' customizes the menu elements of the |
3108 mode-specific menu. `vc-annotate-color-map' and | 3074 mode-specific menu. `vc-annotate-color-map' and |
3109 `vc-annotate-very-old-color' defines the mapping of time to | 3075 `vc-annotate-very-old-color' defines the mapping of time to |
3110 colors. `vc-annotate-background' specifies the background color." | 3076 colors. `vc-annotate-background' specifies the background color." |
3111 (interactive "P") | 3077 (interactive |
3078 (save-current-buffer | |
3079 (vc-ensure-vc-buffer) | |
3080 (list buffer-file-name | |
3081 (let ((def (vc-workfile-version buffer-file-name))) | |
3082 (if (null current-prefix-arg) def | |
3083 (read-string | |
3084 (format "Annotate from version (default %s): " def) | |
3085 nil nil def))) | |
3086 (if (null current-prefix-arg) | |
3087 vc-annotate-display-mode | |
3088 (float (string-to-number | |
3089 (read-string "Annotate span days (default 20): " | |
3090 nil nil "20"))))))) | |
3112 (vc-ensure-vc-buffer) | 3091 (vc-ensure-vc-buffer) |
3113 (let* ((temp-buffer-name nil) | 3092 (setq vc-annotate-display-mode display-mode) ;Not sure why. --Stef |
3114 (temp-buffer-show-function 'vc-annotate-display-select) | 3093 (let* ((temp-buffer-name (format "*Annotate %s (rev %s)*" (buffer-name) rev)) |
3115 (rev (or revision (vc-workfile-version buffer-file-name))) | 3094 (temp-buffer-show-function 'vc-annotate-display-select)) |
3116 (bfn buffer-file-name) | |
3117 (vc-annotate-version | |
3118 (if prefix (read-string | |
3119 (format "Annotate from version (default %s): " rev) | |
3120 nil nil rev) | |
3121 rev))) | |
3122 (if display-mode | |
3123 (setq vc-annotate-display-mode display-mode) | |
3124 (if prefix | |
3125 (setq vc-annotate-display-mode | |
3126 (float (string-to-number | |
3127 (read-string "Annotate span days (default 20): " | |
3128 nil nil "20")))))) | |
3129 (setq temp-buffer-name (format "*Annotate %s (rev %s)*" | |
3130 (buffer-name) vc-annotate-version)) | |
3131 (setq vc-annotate-backend (vc-backend buffer-file-name)) | |
3132 (message "Annotating...") | 3095 (message "Annotating...") |
3096 ;; If BUF is specified it tells in which buffer we should put the | |
3097 ;; annotations. This is used when switching annotations to another | |
3098 ;; revision, so we should update the buffer's name. | |
3099 (if buf (with-current-buffer buf | |
3100 (rename-buffer temp-buffer-name t) | |
3101 ;; In case it had to be uniquified. | |
3102 (setq temp-buffer-name (buffer-name)))) | |
3133 (if (not (vc-find-backend-function vc-annotate-backend 'annotate-command)) | 3103 (if (not (vc-find-backend-function vc-annotate-backend 'annotate-command)) |
3134 (error "Sorry, annotating is not implemented for %s" | 3104 (error "Sorry, annotating is not implemented for %s" |
3135 vc-annotate-backend)) | 3105 vc-annotate-backend)) |
3136 (with-output-to-temp-buffer temp-buffer-name | 3106 (with-output-to-temp-buffer temp-buffer-name |
3137 (vc-call-backend vc-annotate-backend 'annotate-command | 3107 (vc-call annotate-command file (get-buffer temp-buffer-name) rev)) |
3138 buffer-file-name | 3108 (with-current-buffer temp-buffer-name |
3139 (get-buffer temp-buffer-name) | 3109 (set (make-local-variable 'vc-annotate-backend) (vc-backend file)) |
3140 vc-annotate-version)) | 3110 (set (make-local-variable 'vc-annotate-parent-file) file) |
3141 (save-excursion | 3111 (set (make-local-variable 'vc-annotate-parent-rev) rev) |
3142 (set-buffer temp-buffer-name) | |
3143 (set (make-local-variable 'vc-annotate-parent-file) bfn) | |
3144 (set (make-local-variable 'vc-annotate-parent-rev) vc-annotate-version) | |
3145 (set (make-local-variable 'vc-annotate-parent-display-mode) | 3112 (set (make-local-variable 'vc-annotate-parent-display-mode) |
3146 vc-annotate-display-mode)) | 3113 display-mode)) |
3147 | 3114 |
3148 ;; Don't use the temp-buffer-name until the buffer is created | |
3149 ;; (only after `with-output-to-temp-buffer'.) | |
3150 (setq vc-annotate-buffers | |
3151 (append vc-annotate-buffers | |
3152 (list (cons (get-buffer temp-buffer-name) vc-annotate-backend)))) | |
3153 (message "Annotating... done"))) | 3115 (message "Annotating... done"))) |
3154 | 3116 |
3155 (defun vc-annotate-prev-version (prefix) | 3117 (defun vc-annotate-prev-version (prefix) |
3156 "Visit the annotation of the version previous to this one. | 3118 "Visit the annotation of the version previous to this one. |
3157 | 3119 |
3272 (message "Cannot decrement %d versions from version %s" | 3234 (message "Cannot decrement %d versions from version %s" |
3273 (- 0 revspeccopy) vc-annotate-parent-rev))) | 3235 (- 0 revspeccopy) vc-annotate-parent-rev))) |
3274 ((stringp revspec) (setq newrev revspec)) | 3236 ((stringp revspec) (setq newrev revspec)) |
3275 (t (error "Invalid argument to vc-annotate-warp-version"))) | 3237 (t (error "Invalid argument to vc-annotate-warp-version"))) |
3276 (when newrev | 3238 (when newrev |
3277 (save-window-excursion | 3239 (vc-annotate vc-annotate-parent-file newrev |
3278 (find-file vc-annotate-parent-file) | 3240 vc-annotate-parent-display-mode |
3279 (vc-annotate nil newrev vc-annotate-parent-display-mode)) | 3241 (current-buffer)) |
3280 (kill-buffer (current-buffer)) ;; kill the buffer we started from | |
3281 (switch-to-buffer (car (car (last vc-annotate-buffers)))) | |
3282 (goto-line (min oldline (progn (goto-char (point-max)) | 3242 (goto-line (min oldline (progn (goto-char (point-max)) |
3283 (previous-line) | 3243 (previous-line) |
3284 (line-number-at-pos)))))))) | 3244 (line-number-at-pos)))))))) |
3285 | |
3286 (defun vc-annotate-car-last-cons (a-list) | |
3287 "Return car of last cons in association list A-LIST." | |
3288 (if (not (eq nil (cdr a-list))) | |
3289 (vc-annotate-car-last-cons (cdr a-list)) | |
3290 (car (car a-list)))) | |
3291 | 3245 |
3292 (defun vc-annotate-time-span (a-list span &optional quantize) | 3246 (defun vc-annotate-time-span (a-list span &optional quantize) |
3293 "Apply factor SPAN to the time-span of association list A-LIST. | 3247 "Apply factor SPAN to the time-span of association list A-LIST. |
3294 Return the new alist. | 3248 Return the new alist. |
3295 Optionally quantize to the factor of QUANTIZE." | 3249 Optionally quantize to the factor of QUANTIZE." |