home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / lemacs-19.6 / lisp / pcl-cvs / pcl-cvs-lucid.el < prev    next >
Encoding:
Text File  |  1993-02-17  |  4.4 KB  |  136 lines

  1. ;;; Mouse and font support for PCL-CVS 1.3 running in Lucid GNU Emacs
  2. ;; Copyright (C) 1992-1993 Free Software Foundation, Inc.
  3.  
  4. ;; This file is part of GNU Emacs.
  5.  
  6. ;; GNU Emacs is free software; you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation; either version 2, or (at your option)
  9. ;; any later version.
  10.  
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;; GNU General Public License for more details.
  15.  
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  18. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20.  
  21. ;; This simply adds a menu of the common CVS commands to the menubar and to
  22. ;; the right mouse button.  Clicking right moves point, and then pops up a
  23. ;; menu from which commands can be executed.
  24. ;; 
  25. ;; This could stand to be a lot more clever: for example, the "Commit Changes"
  26. ;; command should only be active on files for which there is something to
  27. ;; commit.  Also, some indication of which files the command applies to
  28. ;; (especially in the presence of multiple marked files) would be nice.
  29. ;;
  30. ;; Middle-click runs find-file.
  31.  
  32.  
  33. (require 'pcl-cvs)
  34.  
  35. (defvar cvs-menu
  36.   '("CVS"
  37.     ["Find File"            cvs-find-file            t]
  38.     ["Find File Other Window"        cvs-find-file-other-window    t]
  39.     ["Diff against Repository"        cvs-diff-cvs            t]
  40.     ["Diff against Backup Version"    cvs-diff-backup            t]
  41.     "----"
  42.     ["Commit Changes to Repository"    cvs-commit            t]
  43.     ["Revert File from Repository"    cvs-undo-local-changes        t]
  44.     ["Add File to Repository"        cvs-add                t]
  45.     ["Remove File from Repository"    cvs-remove-file            t]
  46.     ["Ignore File"            cvs-ignore            t]
  47.     ["Hide File"            cvs-acknowledge            t]
  48.     ["Hide Handled Files"        cvs-remove-handled        t]
  49.     "----"
  50.     ["Add ChangeLog Entry"    cvs-add-change-log-entry-other-window    t]
  51.     ["Show CVS Log"            cvs-log                t]
  52.     ["Show CVS Status"            cvs-status            t]
  53.     "----"
  54.     ["Mark File"            cvs-mark            t]
  55.     ["Unmark File"            cvs-unmark            t]
  56.     ["Mark All Files"            cvs-mark-all-files        t]
  57.     ["Unmark All Files"            cvs-unmark-all-files        t]
  58.     ))
  59.  
  60. (defun cvs-menu (e)
  61.   (interactive "e")
  62.   (mouse-set-point e)
  63.   (beginning-of-line)
  64.   (or (looking-at "^[* ] ") (error ""))
  65.   (popup-menu cvs-menu))
  66.  
  67. (defun cvs-mouse-find-file (e)
  68.   (interactive "e")
  69.   (mouse-set-point e)
  70.   (beginning-of-line)
  71.   (or (looking-at "^[* ] ") (error ""))
  72.   (cvs-find-file (point)))
  73.  
  74. (define-key cvs-mode-map 'button3 'cvs-menu)
  75. (define-key cvs-mode-map 'button2 'cvs-mouse-find-file)
  76.  
  77. (make-face 'cvs-header-face)
  78. (make-face 'cvs-filename-face)
  79. (make-face 'cvs-status-face)
  80.  
  81. (or (face-differs-from-default-p 'cvs-header-face)
  82.     (copy-face 'italic 'cvs-header-face))
  83.  
  84. (or (face-differs-from-default-p 'cvs-filename-face)
  85.     (copy-face 'bold 'cvs-filename-face))
  86.  
  87. (or (face-differs-from-default-p 'cvs-status-face)
  88.     (copy-face 'bold-italic 'cvs-status-face))
  89.  
  90.  
  91. (defun pcl-mode-motion-highlight-line (event)
  92.   (if (save-excursion
  93.     (let* ((window (event-window event))
  94.            (buffer (and window (window-buffer window)))
  95.            (point (and buffer (event-point event))))
  96.       (and point
  97.            (progn
  98.          (set-buffer buffer)
  99.          (goto-char point)
  100.          (beginning-of-line)
  101.          (looking-at "^[* ] ")))))
  102.       (mode-motion-highlight-line event)))
  103.  
  104. (defun pcl-cvs-fontify ()
  105.   ;;
  106.   ;; set up line highlighting
  107.   (require 'mode-motion)
  108.   (setq mode-motion-hook 'pcl-mode-motion-highlight-line)
  109.   ;;
  110.   ;; set up menubar
  111.   (if (and current-menubar (not (assoc "CVS" current-menubar)))
  112.       (progn
  113.     (set-buffer-menubar (copy-sequence current-menubar))
  114.     (add-menu nil "CVS" (cdr cvs-menu))))
  115.   ;;
  116.   ;; fontify mousable lines
  117.   (save-excursion
  118.     (goto-char (point-min))
  119.     (search-forward "\n\n" nil t)
  120.     (while (not (eobp))
  121.       (cond ((looking-at "In directory \\(.+\\)$")
  122.          (set-extent-face (make-extent (match-beginning 1) (match-end 1))
  123.                   'cvs-header-face))
  124.         ((looking-at "[* ] \\w+ +\\(ci +\\)?\\(.+\\)$")
  125.          (if (match-beginning 1)
  126.          (set-extent-face
  127.           (make-extent (match-beginning 1) (match-end 1))
  128.           'cvs-status-face))
  129.          (set-extent-face (make-extent (match-beginning 2) (match-end 2))
  130.                   'cvs-filename-face))
  131.         )
  132.       (forward-line 1)))
  133.   )
  134.  
  135. (add-hook 'cvs-mode-hook 'pcl-cvs-fontify)
  136.