home *** CD-ROM | disk | FTP | other *** search
- ;;; Basic ptools package ;; -*-Mode: Lisp -*-
- ;;;
- ;;; Originally by Kipp Hickman with help from Terry Weissman
- ;;; Hacked up further by Michael Toy
- ;;;
- ;;; more mods by Scott Henry
- ;;;
- ;;; sets ROOT to $WORKAREA/root and TOOLROOT to $WORKAREA/toolroot
- ;;; so those should be symlinks (if necessary) to the real root & toolroot
-
- (defvar ptools-dir "/usr/local/bin/ptools/")
- ;; be able to specify options to the ptools commands
- (defvar p_modify-options nil)
- (defvar p_unmodify-options "-u") ; updates with highest RCS revision
- (defvar p_rdiff-options "-g") ; uses gdiff instead of diff
- (defvar p_finalize-options "-B") ; don't bugpost
- (defvar p_integrate-options nil)
-
-
-
- (defun strip-matching-strings (src &rest matches)
- "Return a version of SRC with all strings matching MATCHES removed"
- (let* ((match-one
- (lambda (astring match-list)
- (cond
- ((eq match-list nil) nil)
- ((string-match (car match-list) astring) t)
- (t (funcall match-one astring (cdr match-list)))
- )
- )
- )
- (sms1
- (lambda (lstr)
- (cond
- ((eq lstr nil) nil)
- ((funcall match-one (car lstr) matches)
- (funcall sms1 (cdr lstr)))
- (t (cons (car lstr) (funcall sms1 (cdr lstr))))
- )
- )
- )
- )
- (funcall sms1 src)
- )
- )
-
- (defun p_root (relative-root)
- "Set the ptools environment variables appropriately for a new workarea"
- (interactive "DWorkarea: ")
- (setq new-root (expand-file-name relative-root))
- (cond
- ((not (file-accessible-directory-p new-root))
- (error "Error: %s is not a directory" new-root))
- ((not (file-readable-p (concat new-root ".workarea")))
- (error "Error: Can't access %s.workarea" new-root))
- (t
- (setq
- process-environment
- (append
- (list
- (concat "WORKAREA=" new-root)
- (concat "ROOT=" new-root "root")
- (concat "TOOLROOT=" new-root "toolroot"))
- (strip-matching-strings process-environment
- "WORKAREA=" "ROOT=" "TOOLROOT="))))
- )
- )
-
-
- (defun p_modify ()
- "Run p_modify on the file in the current buffer"
- (interactive)
- (if (not buffer-read-only)
- (error "Buffer is not read-only"))
- (shell-command (concat ptools-dir "p_modify " p_modify-options " "
- (file-name-nondirectory buffer-file-name)))
- (revert-buffer t t))
-
- (defun p_unmodify ()
- "Run p_unmodify on the file in the current buffer"
- (interactive)
- (if buffer-read-only
- (error "Buffer is already read-only"))
- (shell-command (concat ptools-dir "p_unmodify " p_unmodify-options " "
- (file-name-nondirectory buffer-file-name)))
- (revert-buffer t t))
-
- (defun p_integrate ()
- "Run p_integrate on the file in the current buffer"
- (interactive)
- (if buffer-read-only
- (error "Buffer is read-only - modify first"))
- (shell-command (concat ptools-dir "p_integrate " p_integrate-options " "
- (file-name-nondirectory buffer-file-name))))
-
- (defun p_finalize (arg)
- "Run p_finalize on the file in the current buffer"
- (interactive "sFinalize message: ")
- (shell-command (concat ptools-dir "p_finalize " p_finalize-options " -m \"" arg "\" "
- (file-name-nondirectory buffer-file-name)))
- (revert-buffer t t))
-
- (defun p_rdiff ()
- "Run p_rdiff on the file in the current buffer"
- (interactive)
- (shell-command (concat ptools-dir "p_rdiff " p_rdiff-options " "
- (file-name-nondirectory buffer-file-name)))
- )
-
-
- (defun p_fetal ()
- "Run p_modify -f on the file in the current buffer"
- (interactive)
- (shell-command (concat ptools-dir "p_modify -f " p_modify-options " "
- (file-name-nondirectory buffer-file-name)))
- )
-
- ;;; I think this is a dumb idea for a default, but you can do it if you want to
- ;(modify-frame-parameters (selected-frame) '((menu-bar-lines . 2)))
-
- ;; Make a menu keymap (with a prompt string)
- ;; to be the menu bar item's definition.
- ;; I stole this from somewhere. I have no idea how this works,
- ;; and I'd really like to know what the third argument
- (define-key global-map [menu-bar ptools]
- (cons "PTools" (make-sparse-keymap "PTools")))
-
- ;; Make specific subcommands in the item's submenu.
-
- (define-key global-map [menu-bar ptools p_fetal]
- '("p_fetal" . p_fetal))
- (define-key global-map [menu-bar ptools p_unmodify]
- '("p_unmodify" . p_unmodify))
- (define-key global-map [menu-bar ptools p_rdiff]
- '("p_rdiff" . p_rdiff))
- (define-key global-map [menu-bar ptools p_finalize]
- '("p_finalize" . p_finalize))
- (define-key global-map [menu-bar ptools p_integrate]
- '("p_integrate" . p_integrate))
- (define-key global-map [menu-bar ptools p_modify]
- '("p_modify" . p_modify))
- (define-key global-map [menu-bar ptools p_root]
- '("New Workarea ..." . p_root))
-
- (provide 'ptools)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; The following local variable definition causes this emacs code
- ;; to be byte compiled every time I save it.
- ;; From: makke@wins.uia.ac.be (Marc Gemis)
- ;;
- ;; Local variables:
- ;; mode: lisp
- ;; indent-tabs-mode: nil
- ;; eval: (defun byte-compile-this-file () (write-region (point-min) (point-max) buffer-file-name nil 't) (byte-compile-file buffer-file-name) nil)
- ;; write-file-hooks: (byte-compile-this-file)
- ;; End:
-