home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / rexxmd11.zip / vxrexx-mode.el < prev   
Lisp/Scheme  |  1994-07-11  |  3KB  |  91 lines

  1. ;;; vxrexx-mode.el --- Adds intelligence for handling VX-Rexx code.
  2. ;;;               Must be used in conjunction with rexx-mode.
  3.  
  4. ;; Copyright (C) 1994 Scott K. Maxwell
  5.  
  6. ;; Author: Scott Maxwell <scottmax@netcom.com>
  7. ;; Keywords: rexx vxrexx
  8.  
  9. ;; Add the following lines to your .emacs
  10. ;;   (load "vxrexx-mode")
  11. ;; This will only work with rexx-mode so make sure you
  12. ;; have already installed that.
  13.  
  14. ;; These extensions cause rexx-mode to automatically
  15. ;; rename your VX-Rexx section buffers to the name of
  16. ;; the section, instead of the name of the temp file.
  17.  
  18. ;; If you want to have the procedure names from every
  19. ;; section added to your local completion table, add:
  20. ;;
  21. ;;   (setq vxrexx-build-master-table t)
  22. ;;
  23. ;; Then when you load the first section, vxrexx-mode uses grep
  24. ;; to build the procedure table.  After that it will just add
  25. ;; new sections as they are created.  If you delete some sections,
  26. ;; you may want to force vxrexx-mode to rebuild the table.  This
  27. ;; may be accomplished by saving your project.
  28. ;;
  29. ;; NOTE: You must have grep.exe somewhere in your path to use this
  30. ;;     feature.
  31.  
  32. ;; If you use this, you will probably also want to enable the
  33. ;; VX-Rexx completion and documentation file.  Look in
  34. ;; vxrexx-doc.el for details.
  35.  
  36. ;; You might also want to check out my frame-server package.
  37. ;; It causes Emacs to open a new frame for each emacsclient.
  38. ;; These frames then may be closed as if they were all separate
  39. ;; editors, i.e. hitting [Alt-F4] or selecting Close from the
  40. ;; system menu.
  41.  
  42.  
  43. (defvar vxrexx-build-master-table nil
  44.   "*If non-nil, rexx-mode will use grep to get all of the
  45. procedure names associated with the current file of the
  46. current project.")
  47.  
  48. (defvar vxrexx-table-alist nil
  49.   "Contains list of VX-Rexx tables for different projects.")
  50.  
  51. (add-hook 'rexx-mode-hook 'vxrexx-check)
  52.  
  53. (defun vxrexx-check ()
  54.   (if (looking-at "/\\*:VRX \\*/")
  55.       (let ((here (rexx-forward-to-noncomment))
  56.         (there (rexx-forward-sexp 1)))
  57.     (rename-buffer (buffer-substring here there))
  58.     (setq mode-name "VX-Rexx")
  59.     (setq rexx-build-eval '(vxrexx-build-procedure-table)))))
  60.  
  61. (defun vxrexx-build-procedure-table ()
  62.   (if vxrexx-build-master-table
  63.       (let ((first-vrm (car (directory-files "./" t "\.+\.VRM"))))
  64.     (if first-vrm
  65.         (let* (move
  66.            (time (elt (file-attributes first-vrm) 5))
  67.            (dir (file-name-directory first-vrm))
  68.            (old (assoc dir vxrexx-table-alist)))
  69.           (setq rexx-user-procedure-table
  70.             (append
  71.              (if (and old
  72.                   (equal (elt old 1) time))
  73.              (elt old 2)
  74.                (if (not old)
  75.                (progn
  76.                  (setq old (list dir time nil))
  77.                  (setq vxrexx-table-alist (cons old vxrexx-table-alist)))
  78.              (setcar (cdr old) time))
  79.                (save-excursion
  80.              (set-buffer (get-buffer-create " *vxrexx-procedures*"))
  81.              (erase-buffer)
  82.              (call-process "grep" nil t t "-h" "^[a-zA-Z][a-zA-Z_0-9]*:" "*.cmd")
  83.              (goto-char (point-min))
  84.              (while (re-search-forward "^[a-z][a-z_0-9]*:" nil t)
  85.                (rexx-add-to-procedure-table
  86.                 (buffer-substring (match-beginning 0) (1- (match-end 0)))))
  87.              (setq move rexx-user-procedure-table)
  88.              (kill-buffer " *vxrexx-procedures*"))
  89.                move) rexx-user-procedure-table))
  90.           (setcar (cdr (cdr old)) rexx-user-procedure-table))))))
  91.