home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / modula-3 / m3-3.5 / m3-3 / usr / local / modula3-3.5.4-B / lib / elisp / m3menu.el < prev    next >
Encoding:
Text File  |  1995-11-24  |  20.4 KB  |  711 lines

  1. ; This file is part of m3ide, a simple development environment for M3    
  2. ; Copyright (C) 1995 Michel Dagenais                                     
  3. ;                                                                        
  4. ; This library is free software; you can redistribute it and/or          
  5. ; modify it under the terms of the GNU Library General Public            
  6. ; License as published by the Free Software Foundation; either           
  7. ; version 2 of the License, or (at your option) any later version.       
  8. ;                                                                        
  9. ; This library is distributed in the hope that it will be useful,        
  10. ; but WITHOUT ANY WARRANTY; without even the implied warranty of         
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      
  12. ; Library General Public License for more details.                       
  13. ;                                                                        
  14. ; You should have received a copy of the GNU Library General Public      
  15. ; License along with this library; if not, write to the Free             
  16. ; Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.     
  17. ;                                                                        
  18. ; For more information on this program, contact Michel Dagenais at       
  19. ; dagenais@vlsi.polymtl.ca or Electrical Eng. Dept., Ecole Polytechnique 
  20. ; P.O. Box 6079, Station A, Montreal, Quebec, Canada, H3C 3A7.           
  21.  
  22. ;
  23. ; CHECK disable auto-save and undo on scratch buffers
  24. ;
  25.  
  26. (defvar w3-mode-hooks 'check-m3-w3-menu)
  27. (defvar w3-reuse-buffers 'yes)
  28.  
  29. (require 'm3process)
  30. (require 'w3)
  31. (provide 'm3menu)
  32.  
  33. (defvar m3-w3-menu
  34.   '("W3Edit"
  35.     ["Edit corresponding file" m3-w3-edit t]
  36.   )
  37. )
  38.  
  39. (defvar m3-menu
  40.   '("Modula-3"
  41.     ("Help"
  42. ;      ["Modula-3 menu" m3-help-m3menu t]
  43.       ["Language definition" m3-help-language t]
  44.       ["Libraries" m3-help-libraries t]
  45.       ["Compiler and tools" m3-help-srcm3 t]
  46.       ["Building distributed Apps with M3" m3-help-bdam3 t]
  47.     )
  48.     ("Browse"
  49.       ["List programs" m3-list-programs t]
  50.       ["List libraries" m3-list-libraries t]
  51.       ["List interfaces" m3-list-interfaces t]
  52.       ["List implementations" m3-list-implementations t]
  53.       ["List types" m3-list-types t]
  54.       ( "List by prefix"
  55.         ["List programs" m3-list-programs-prefix t]
  56.         ["List libraries" m3-list-libraries-prefix t]
  57.         ["List interfaces" m3-list-interfaces-prefix t]
  58.         ["List .h interfaces" m3-list-h-interfaces-prefix t]
  59.         ["List generic interfaces" m3-list-gen-interfaces-prefix t]
  60.         ["List implementations" m3-list-implementations-prefix t]
  61.         ["List .c implementations" m3-list-c-implementations-prefix t]
  62.         ["List generic implementations" m3-list-gen-implementations-prefix t]
  63.         ["List types" m3-list-types-prefix t]
  64.       )
  65.     )
  66.     ("Build"
  67.       ["Build" m3-build t]
  68.       ["Ship" m3-ship t]
  69.       ["Coverage analysis" m3-toggle-cov :style toggle :selected (m3-covp)]
  70.       ["Profiling" m3-toggle-prof :style toggle :selected (m3-profp)]
  71.     )
  72.     ["Next error" next-error t]
  73.     ("Run/debug"
  74.       ["Run" m3-run-program t]
  75.       ["Debug" m3-debug t]
  76.       ["Show new" m3-toggle-shownew :style toggle :selected (m3-shownewp)]
  77.       ["Show heap" m3-toggle-showheap :style toggle :selected (m3-showheapp)]
  78.       ["Show thread" m3-toggle-showthread :style toggle 
  79.           :selected (m3-showthreadp)]
  80.       ["Run arguments" m3-read-run-arguments t]
  81.     )
  82.     ("Analyze"
  83.       ["Coverage" m3-analyze-coverage t]
  84.       ["Profiling" m3-analyze-profile t]
  85.     )
  86.     ("Forms VBT"
  87.       ["Show Form" m3-show-form m3-is-form]
  88.       ["Hide Form" m3-hide-form t]
  89.     )
  90.     ["Pretty print" m3-pprint m3-is-program]
  91.     ("Ide parameters"
  92. ;      ["Packages path" m3-edit-packages-paths t]
  93.       ["Restart ide" clean-m3-ide-process t]
  94.       ["Restart m3browser" clean-m3-browser-process t]
  95.     )
  96.   )
  97. )
  98.  
  99. (defvar m3-slash "/"
  100.   "On unix the path separator is /, may be \ on some weird machines"
  101. )
  102.  
  103. (defvar m3-www "file:/usr/local/modula3-3.5.4-B"
  104.   "Path where modula-3 packages are located"
  105. )
  106.  
  107. (defvar m3-browser (concat "http://" (system-name) ":8000")
  108.   "M3 browser to connect to"
  109. )
  110.  
  111. (defvar m3-source-roots 
  112.   (list "/usr/local/modula3-3.5.4-B/lib/m3/pkg" 
  113.     (concat (getenv "HOME") "/src/m3")
  114.   )
  115.   "Roots for Modula-3 packages source code, served by m3browser"
  116. )
  117.  
  118. (defvar m3-cov ()
  119.   "Build to generate coverage information, run the corresponding executable"
  120. )
  121.  
  122. (defun m3-covp () (if m3-cov t ()))
  123.  
  124. (defun m3-toggle-cov () (interactive)
  125.   "Change the status of cov"
  126.   (if m3-cov (setq m3-cov ()) (setq m3-cov t))
  127. )
  128.  
  129. (defvar m3-prof ()
  130.   "Build to generate profiling information, run the corresponding executable"
  131. )
  132.  
  133. (defun m3-profp () (if m3-prof t ()))
  134.  
  135. (defun m3-toggle-prof () (interactive)
  136.   "Change the status of prof"
  137.   (if m3-prof (setq m3-prof ()) (setq m3-prof t))
  138. )
  139.  
  140. (defvar m3-shownew ()
  141.   "Show new allocations while running"
  142. )
  143.  
  144. (defun m3-shownewp () (if m3-shownew t ()))
  145.  
  146. (defun m3-toggle-shownew () (interactive)
  147.   "Change the status of shownew"
  148.   (if m3-shownew (setq m3-shownew ()) (setq m3-shownew t))
  149. )
  150.  
  151. (defvar m3-showheap ()
  152.   "Show heap while running"
  153. )
  154.  
  155. (defun m3-showheapp () (if m3-showheap t ()))
  156.  
  157. (defun m3-toggle-showheap () (interactive)
  158.   "Change the status of showheap"
  159.   (if m3-showheap (setq m3-showheap ()) (setq m3-showheap t))
  160. )
  161.  
  162. (defvar m3-showthread ()
  163.   "Show thread while running"
  164. )
  165.  
  166. (defun m3-showthreadp () (if m3-showthread t ()))
  167.  
  168. (defun m3-toggle-showthread () (interactive)
  169.   "Change the status of showthread"
  170.   (if m3-showthread (setq m3-showthread ()) (setq m3-showthread t))
  171. )
  172.  
  173. (defvar m3-run-arguments ""
  174.   "Arguments when running a command"
  175. )
  176.  
  177. (defun m3-read-run-arguments () (interactive)
  178.   "Read and store the command line arguments"
  179.   (setq m3-run-arguments 
  180.     (read-string "Command line arguments: " m3-run-arguments)
  181.   )
  182. )
  183.  
  184. (defvar m3-w3-frame ()
  185.   "Frame to show browsing"
  186. )
  187.  
  188. (defun check-m3-menu ()
  189.   "insure that the Modula-3 menu is on the current menu bar"
  190.   (if (boundp 'current-menubar)
  191.     (if (and current-menubar (not (assoc "Modula-3" current-menubar)))
  192.      (progn
  193.         (set-buffer-menubar (copy-sequence current-menubar))
  194.         (add-menu nil "Modula-3" (cdr m3-menu))
  195.       )
  196.     )
  197.   )
  198. )
  199.  
  200. (defvar m3-w3-menu-set ()
  201.   "Have we added to the W3 menu yet"
  202. )
  203.  
  204. (defun check-m3-w3-menu ()
  205.   "Add an edit menu to the w3 menubar"
  206.   (if (boundp 'current-menubar)
  207.     (if (not m3-w3-menu-set)
  208.       (progn
  209.         (setq w3-menu (cons m3-w3-menu w3-menu))
  210.         (setq m3-w3-menu-set t)
  211.       )
  212.     )
  213.   )
  214. )
  215.  
  216. (defun get-buffer-create-m3 (b)
  217.   "install the m3 menu as well"
  218.   (let ((buffer (get-buffer-create b))
  219.         (old-buffer (current-buffer))
  220.        )
  221.     (set-buffer buffer)
  222.     (make-local-variable 'm3-is-form)
  223.     (make-local-variable 'm3-is-program)
  224.     (setq m3-is-form ())
  225.     (setq m3-is-program ())
  226.     (check-m3-menu)
  227.     (set-buffer old-buffer)
  228.     buffer
  229.   )
  230. )
  231.  
  232. (defun get-tmpbuf-create-m3 (b)
  233.   "have no undo"
  234.   (let ((buffer (get-buffer-create-m3 b)))
  235.     (buffer-disable-undo buffer)
  236.     buffer
  237.   )
  238. )
  239.  
  240. (defun m3-w3-fetch (url)
  241.   "Follow the url in the m3-w3 frame."
  242.   (interactive (list (w3-read-url-with-default)))
  243.   (cond
  244.     ( 
  245.       (and (fboundp 'make-frame)
  246.           (fboundp 'select-frame)
  247.       )
  248.       (progn
  249.         (if (not (framep m3-w3-frame)) (setq m3-w3-frame (make-frame)))
  250.         (select-frame m3-w3-frame)
  251.         (w3-fetch url)
  252.       )
  253.     )
  254.     (t (w3-fetch url))
  255.   )
  256. )
  257.  
  258. (defun m3-w3-edit () (interactive)
  259.   "Do a find-file on the currently viewed html document if it is a file."
  260.   (interactive)
  261.   (cond
  262.     (
  263.       (and (or (null url-current-type) (eq url-current-type "file") t)
  264.          (eq major-mode 'w3-mode)
  265.       )
  266.       (if w3-mutable-windows
  267.         (find-file-other-window (m3-w3-current-file))
  268.         (find-file (m3-w3-current-file))
  269.       )
  270.     )
  271.     (t (message "Sorry, I can't get that file so you can alter it."))
  272.   )
  273. )
  274.  
  275. (defun m3-w3-current-file ()
  276.   "Check if there is a base"
  277.   (let ((html-source w3-current-source)
  278.         (html-file url-current-file)
  279.        )
  280.     (if (string-match "<BASE HREF=\"[^/]*//[^/]*\\([^\"]*\\)\"" html-source)
  281.       (setq html-file 
  282.         (substring html-source (match-beginning 1) (match-end 1))
  283.       )
  284.     )
  285.     html-file
  286.   )
  287. )
  288.     
  289. ;(defun m3-edit-packages-paths () (interactive)
  290. ;  "Find the .m3paths file and show it in a buffer"
  291. ;  (find-file-other-window (concat (getenv "HOME") "/.m3path"))
  292. ;)
  293.  
  294. (defun m3-help-m3menu () (interactive)
  295.   "Show the m3menu documentation"
  296.   (m3-w3-fetch (concat m3-www "/M3PKG/m3ide/src/html/manual.html"))
  297. )
  298.  
  299. (defun m3-help-language () (interactive)
  300.   "Show the language definition documentation"
  301.   (m3-w3-fetch (concat m3-www "/html/m3defn/html/m3.html"))
  302. )
  303.  
  304. (defun m3-help-libraries () (interactive)
  305.   "Show the libraries documentation"
  306.   (m3-w3-fetch (concat m3-www "/html/libraries/html/index.html"))
  307. )
  308.  
  309. (defun m3-help-srcm3 () (interactive)
  310.   "Show the SRC Modula-3 documentation"
  311.   (m3-w3-fetch (concat m3-www "/html/modula-3/html/srcm3.html"))
  312. )
  313.  
  314. (defun m3-help-bdam3 () (interactive)
  315.   "Show the Building distributed applications with Modula-3 book"
  316.   (m3-w3-fetch (concat m3-www "/html/bdam3/main.html"))
  317. )
  318.  
  319. (defun m3-build () (interactive)
  320.   "Execute m3build and await errors"
  321.   (m3-run (m3-add-builddir "m3build"))
  322. )
  323.  
  324. (defun m3-add-builddir (command)
  325.   "Add -b builddir as needed"
  326.   (let ((new-command command)
  327.         (builddir ())
  328.        )
  329.     (if (or m3-cov m3-prof)
  330.       (progn
  331.         (if m3-cov
  332.           (setq builddir (m3-ide-command-string "buildDir" (list "-COV")))
  333.           (setq builddir (m3-ide-command-string "buildDir" (list "-PROF")))
  334.         )
  335.         (setq command (concat command " -b " builddir))
  336.       )
  337.     )
  338.     command
  339.   )
  340. )
  341.  
  342. (defun m3-run-program () (interactive)  
  343.   "Run the program associated with this package"
  344.   (let ((old-buffer (current-buffer))
  345.         (old-window (selected-window))
  346.         (m3-program-name ())
  347.         (m3-program-dir ())
  348.         (build-suffix ())
  349.        )
  350.  
  351.     (if m3-cov
  352.       (setq build-suffix "-COV")
  353.       (if m3-prof
  354.         (setq build-suffix "-PROF")
  355.         (setq build-suffix "")
  356.       )
  357.     )
  358.  
  359.     (setq m3-program-name 
  360.       (m3-ide-command-string "pkgProgram" 
  361.         (list (buffer-file-name) build-suffix)
  362.       )
  363.     )
  364.  
  365.     (setq m3-program-dir (m3-build-path (buffer-file-name) build-suffix))
  366.  
  367.     (if (or (= (length m3-program-name) 0) (= (length m3-program-dir) 0))
  368.       (message (concat "File " (buffer-file-name)
  369.         " is not in a program package")
  370.       )
  371.       (progn
  372.         (shell)
  373.         (if m3-shownew 
  374.           (setq m3-program-name (concat m3-program-name " @M3shownew"))
  375.         )
  376.         (if m3-showheap
  377.           (setq m3-program-name (concat m3-program-name " @M3showheap"))
  378.         )
  379.         (if m3-showthread 
  380.           (setq m3-program-name (concat m3-program-name " @M3showthread"))
  381.         )
  382.         (if (> (length m3-run-arguments) 0)
  383.           (setq m3-program-name (concat m3-program-name " " m3-run-arguments))
  384.         )
  385.         (goto-char (point-max))
  386.         (insert (concat "cd " m3-program-dir))
  387.         (comint-send-input)
  388.         (insert m3-program-name)
  389.       )
  390.     )
  391.   )
  392. )
  393.  
  394. (defun m3-debug () (interactive)
  395.   "Send the current buffer file name to the m3-ide which will return the
  396.    input to send to gdb to initialize the paths, working directory and
  397.    file to debug."
  398.   (let ((old-gdb-name gdb-command-name)
  399.         (old-buffer (current-buffer))
  400.         (old-window (selected-window))
  401.         (old-file-name (buffer-file-name))
  402.         (m3-program-name ())
  403.         (m3-program-dir ())
  404.         (build-suffix ())
  405.        )
  406.     (setq gdb-command-name "m3gdb")
  407.  
  408.     (if m3-cov
  409.       (setq build-suffix "-COV")
  410.       (if m3-prof
  411.         (setq build-suffix "-PROF")
  412.         (setq build-suffix "")
  413.       )
  414.     )
  415.  
  416.     (setq m3-program-name 
  417.       (m3-ide-command-string "pkgProgram" 
  418.         (list (buffer-file-name) build-suffix)
  419.       )
  420.     )
  421.  
  422.     (setq m3-program-dir (m3-build-path (buffer-file-name) build-suffix))
  423.  
  424.     (if (or (= (length m3-program-name) 0) (= (length m3-program-dir) 0))
  425.       (message (concat "File " (buffer-file-name)
  426.         " is not in a program package")
  427.       )
  428.       (progn
  429.         (gdb (concat m3-program-dir m3-slash m3-program-name))
  430.         (set-buffer current-gdb-buffer)
  431.         (goto-char (process-mark (get-buffer-process current-gdb-buffer)))
  432.         (delete-region (point) (point-max))
  433.         (insert (m3-source-paths old-file-name build-suffix "dir " "\n"))
  434.         (comint-send-input)
  435.       )
  436.     )
  437.     (setq gdb-command-name old-gdb-name)
  438.   )
  439. )
  440.  
  441. (defun m3-list-programs () (interactive)
  442.   "List the programs through the m3browser"
  443.   (start-m3-browser)
  444.   (m3-w3-fetch (concat m3-browser "/G"))
  445. )
  446.  
  447. (defun m3-list-libraries () (interactive)
  448.   "List the libraries through the m3browser"
  449.   (start-m3-browser)
  450.   (m3-w3-fetch (concat m3-browser "/0"))
  451. )
  452.  
  453. (defun m3-list-interfaces () (interactive)
  454.   "List the interfaces through the m3browser"
  455.   (start-m3-browser)
  456.   (m3-w3-fetch (concat m3-browser "/1"))
  457. )
  458.  
  459. (defun m3-list-implementations () (interactive)
  460.   "List the implementations through the m3browser"
  461.   (start-m3-browser)
  462.   (m3-w3-fetch (concat m3-browser "/2"))
  463. )
  464.  
  465. (defun m3-list-types () (interactive)
  466.   "List the types through the m3browser"
  467.   (start-m3-browser)
  468.   (m3-w3-fetch (concat m3-browser "/K"))
  469. )
  470.  
  471. (defun m3-list-programs-prefix (prefix) 
  472.   (interactive "sPrograms starting in: ")
  473.   "List the programs through the m3browser"
  474.   (start-m3-browser)
  475.   (m3-w3-fetch (concat m3-browser "/J" prefix))
  476. )
  477.  
  478. (defun m3-list-libraries-prefix (prefix) 
  479.   (interactive "sLibraries starting in: ")
  480.   "List the libraries through the m3browser"
  481.   (start-m3-browser)
  482.   (m3-w3-fetch (concat m3-browser "/9" prefix))
  483. )
  484.  
  485. (defun m3-list-interfaces-prefix (prefix) 
  486.   (interactive "sInterfaces starting in: ")
  487.   "List the interfaces through the m3browser"
  488.   (start-m3-browser)
  489.   (m3-w3-fetch (concat m3-browser "/B" prefix))
  490. )
  491.  
  492. (defun m3-list-gen-interfaces-prefix (prefix) 
  493.   (interactive "sInterfaces starting in: ")
  494.   "List the interfaces through the m3browser"
  495.   (start-m3-browser)
  496.   (m3-w3-fetch (concat m3-browser "/A" prefix))
  497. )
  498.  
  499. (defun m3-list-h-interfaces-prefix (prefix) 
  500.   (interactive "sInterfaces starting in: ")
  501.   "List the interfaces through the m3browser"
  502.   (start-m3-browser)
  503.   (m3-w3-fetch (concat m3-browser "/F" prefix))
  504. )
  505.  
  506. (defun m3-list-implementations-prefix (prefix) 
  507.   (interactive "sImplementations starting in: ")
  508.   "List the implementations through the m3browser"
  509.   (start-m3-browser)
  510.   (m3-w3-fetch (concat m3-browser "/D" prefix))
  511. )
  512.  
  513. (defun m3-list-gen-implementations-prefix (prefix) 
  514.   (interactive "sImplementations starting in: ")
  515.   "List the implementations through the m3browser"
  516.   (start-m3-browser)
  517.   (m3-w3-fetch (concat m3-browser "/C" prefix))
  518. )
  519.  
  520. (defun m3-list-c-implementations-prefix (prefix) 
  521.   (interactive "sImplementations starting in: ")
  522.   "List the implementations through the m3browser"
  523.   (start-m3-browser)
  524.   (m3-w3-fetch (concat m3-browser "/E" prefix))
  525. )
  526.  
  527. (defun m3-list-types-prefix (prefix) (interactive "sTypes starting in: ")
  528.   "List the types through the m3browser"
  529.   (start-m3-browser)
  530.   (m3-w3-fetch (concat m3-browser "/M" prefix))
  531. )
  532.  
  533. (defun m3-show-form () (interactive)
  534.   "Send the current buffer (and associated file name) as a form to the 
  535.    m3-ide and get back the errors if any."
  536.   (let ((old-buffer (current-buffer))
  537.         (old-window (selected-window))
  538.        )
  539.     (get-tmpbuf-create-m3 "*m3-tmp*")
  540.     (m3-ide-command "showForm" "*m3-tmp*" 
  541.       (list (buffer-file-name) (buffer-string))
  542.     )
  543.     (set-buffer "*m3-tmp*")
  544.     (if (> (buffer-size) 1)
  545.       (switch-to-buffer-other-window "*m3-tmp*")
  546.     )
  547.     (set-buffer old-buffer)    
  548.     (select-window old-window)
  549.   )
  550. )
  551.  
  552. (defun m3-hide-form () (interactive)
  553.   "Send an empty string as form to show"
  554.   (get-tmpbuf-create-m3 "*m3-tmp*")
  555.   (m3-ide-command "showForm" "*m3-tmp*" 
  556.       (list "" "")
  557.   )
  558. )
  559.  
  560. (defun m3-pprint () (interactive)
  561.   "Send the current buffer to the pretty printer and get the result back"
  562.   (let ((old-buffer (current-buffer))
  563.         (old-window (selected-window))
  564.        )
  565.     (m3-ide-command "pprint" (buffer-name) (list (buffer-string)))
  566.     (set-buffer old-buffer)    
  567.     (select-window old-window)
  568.   )
  569. )
  570.  
  571. ;(defun m3-pprint () (interactive)
  572. ;  "Send the current buffer to the pretty printer and get back the
  573. ;   pretty printed version." 
  574. ;  (m3::pp-buffer)
  575. ;)
  576.  
  577. (defun m3-ship () (interactive)
  578.   "Execute m3ship and await the errors"
  579.   (m3-run (m3-add-builddir "m3ship"))
  580. )
  581.  
  582. (defun m3-run (command)  
  583.   "Run the specified command, usually m3build or m3ship, and await the
  584.    errors"
  585.   (let ((old-buffer (current-buffer))
  586.         (old-buffer-file-name (buffer-file-name))
  587.         (old-window (selected-window))
  588.        )
  589.     (get-tmpbuf-create-m3 "*m3-tmp*")
  590.     (m3-ide-command "pkgM3makefile" "*m3-tmp*" (list old-buffer-file-name))
  591.     (set-buffer "*m3-tmp*")
  592.     (if (= (buffer-size) 0)
  593.       (message (concat "File " old-buffer-file-name " is not in a package"))
  594.       (progn
  595.         (let ((m3makefile-name (buffer-string))
  596.               (m3makefile-buffer (find-file-noselect (buffer-string)))
  597.              )
  598.           (set-buffer m3makefile-buffer)
  599.           (if (= (buffer-size) 0)
  600.             (message (concat "File " m3makefile-name " is empty"))
  601.             (compile command)
  602.           )
  603.         )
  604.       )
  605.     )
  606.     (set-buffer old-buffer)    
  607.     (select-window old-window)
  608.   )
  609. )
  610.  
  611. (defun m3-analyze-coverage () (interactive)
  612.   "Get the coverage analysis for the current file."
  613.   (let ((old-buffer (current-buffer))
  614.         (old-window (selected-window))
  615.         (build-path (m3-build-path (buffer-file-name) "-COV"))
  616.         (source-name (file-name-nondirectory (buffer-file-name)))
  617.         (source-path (file-name-directory (buffer-file-name)))
  618.        )
  619.     (if (= (length build-path) 0)
  620.       (message (concat "File " (buffer-file-name)
  621.         " is not in a program package")
  622.       )
  623.       (progn
  624.         (get-tmpbuf-create-m3 "*m3-coverage*")
  625.         (set-buffer "*m3-coverage*")
  626.         (erase-buffer)
  627.         (setq default-directory (concat build-path m3-slash))
  628.         (start-process "m3-coverage" "*m3-coverage*" "analyze_coverage"
  629.           "-S" source-path "-l" source-name)
  630.         (switch-to-buffer-other-window "*m3-coverage*")
  631.         (set-buffer old-buffer)    
  632.         (select-window old-window)
  633.       )
  634.     )
  635.   )
  636. )
  637.  
  638. (defun m3-analyze-profile () (interactive)
  639.   "Get the profiling for the current package."
  640.   (let ((old-buffer (current-buffer))
  641.         (old-window (selected-window))
  642.         (build-path (m3-build-path (buffer-file-name) "-PROF"))
  643.         (program-path (m3-package-program (buffer-file-name) "-PROF"))
  644.        )
  645.     (if (= (length build-path) 0)
  646.       (message (concat "File " (buffer-file-name)
  647.         " is not in a program package")
  648.       )
  649.       (progn
  650.         (get-tmpbuf-create-m3 "*m3-profile*")
  651.         (set-buffer "*m3-profile*")
  652.         (erase-buffer)
  653.         (setq default-directory (concat build-path m3-slash))
  654.         (start-process "m3-profile" "*m3-profile*" "gprof" program-path)
  655.         (switch-to-buffer-other-window "*m3-profile*")
  656.         (set-buffer old-buffer)    
  657.         (select-window old-window)
  658.       )
  659.     )
  660.   )
  661. )
  662.  
  663. (defun m3-ide-command-string (command args)  
  664.   "send the specified ide command and return result in string"
  665.   (let ((old-buffer (current-buffer))
  666.         (result ())
  667.        )
  668.     (get-tmpbuf-create-m3 "*m3-tmp*")
  669.     (m3-ide-command command "*m3-tmp*" args)
  670.     (set-buffer "*m3-tmp*")
  671.     (setq result (buffer-string))
  672.     (set-buffer old-buffer)
  673.     result
  674.   )
  675. )
  676.  
  677. (defun m3-package-prefix (file-name)
  678.   "Return the directory for the package containing the file"
  679.   (m3-ide-command-string "pkgPrefix" (list file-name))
  680. )
  681.  
  682. (defun m3-package-m3makefile (file-name)
  683.   "Return the m3makefile name for the package containing the file"
  684.   (m3-ide-command-string "pkgM3makefile" (list file-name))
  685. )
  686.  
  687. (defun m3-package-program (file-name build-suffix)
  688.   "Return the program name for the package containing the file"
  689.   (m3-ide-command-string "pkgProgram" (list file-name build-suffix))
  690. )
  691.  
  692. (defun m3-build-dir (build-suffix)
  693.   "Return the build directory"
  694.   (m3-ide-command-string "buildDir" (list build-suffix))
  695. )
  696.  
  697. (defun m3-build-path (file-name build-suffix)
  698.   "Return the build directory path for the package containing the file"
  699.   (m3-ide-command-string "buildPath" (list file-name build-suffix))
  700. )
  701.  
  702. (defun m3-source-paths (file-name build-suffix path-prefix path-suffix)
  703.   "Returns a large string of paths where source code may be found 
  704.    for the program and its libraries. The path prefix and suffix are
  705.    used to delimit the individual paths."
  706.   (m3-ide-command-string "sourcePaths" 
  707.     (list file-name build-suffix path-prefix path-suffix)
  708.   )
  709. )
  710.  
  711.