home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / progs / pari / pari_137 / pari.elc < prev    next >
Text File  |  1992-05-20  |  14KB  |  268 lines

  1.  
  2. (provide (quote gp))
  3.  
  4. (defconst gp-chap3 "~pari/PARISOURCES/tex/usersch3.tex" "\
  5. The TeX source for chapter 3 of the PARI-GP manual")
  6.  
  7. (defconst gp-file-name "/usr/local/bin/gp" "\
  8. The file name of the gp executable file")
  9.  
  10. (defconst gp-man-dvi "~pari/SPARC/tex/users.dvi" "\
  11. dvi version of the manual")
  12.  
  13. (defconst gp-menu "~pari/PARISOURCES/pari.menu" "\
  14. menu file")
  15.  
  16. (defconst gp-dvi-preview "xdvi -s 3" "\
  17. dvi previewer (and options)")
  18.  
  19. (defvar gp-stack-size "4000000" "\
  20. Default stack size: passed to the progam gp.")
  21.  
  22. (defvar gp-buffer-size "30000" "\
  23. Default buffer size: passed to the progam gp.")
  24.  
  25. (defvar gp-prime-limit "500000" "\
  26. Default prime limit: passed to the progam gp.")
  27.  
  28. (defvar gp-prompt-for-args nil "\
  29. A non-nil value makes M-x gp act like C-u M-x gp, 
  30.    ie prompt for the command line arguments.")
  31.  
  32. (setq gp-temp-file (make-temp-name "/usr/tmp/gp_"))
  33.  
  34. (defvar gp-prompt-pattern "---- (type return to continue) ----\\|\\?[
  35.      ]*" "Regexp used to match gp prompts.
  36.    can be set with gp-set-prompt (bound to M-\\ p)")
  37.  
  38. (defvar gp-map (make-sparse-keymap) "\
  39. Local keymap used in buffer *PARI*.")
  40.  
  41. (define-key gp-map "" (quote gp-send-input))
  42.  
  43. (define-key gp-map "ì" (quote gp-copy-input))
  44.  
  45. (define-key gp-map "▄p" (quote gp-set-prompt))
  46.  
  47. (define-key gp-map "▄t" (quote gp-meta-t))
  48.  
  49. (define-key gp-map "▄d" (quote gp-meta-d))
  50.  
  51. (define-key gp-map "▄r" (quote gp-meta-r))
  52.  
  53. (define-key gp-map "▄w" (quote gp-meta-w))
  54.  
  55. (define-key gp-map "▄v" (quote gp-meta-v))
  56.  
  57. (define-key gp-map "▄x" (quote gp-meta-x))
  58.  
  59. (define-key gp-map "▄s" (quote gp-meta-s))
  60.  
  61. (define-key gp-map "▄a" (quote gp-meta-a))
  62.  
  63. (define-key gp-map "▄b" (quote gp-meta-b))
  64.  
  65. (define-key gp-map "▄m" (quote gp-meta-m))
  66.  
  67. (define-key gp-map "▄k" (quote gp-meta-k))
  68.  
  69. (define-key gp-map "▄q" (quote gp-meta-q))
  70.  
  71. (define-key gp-map "┐" (quote gp-get-man-entry))
  72.  
  73. (define-key gp-map "▄c" (quote gp-menu))
  74.  
  75. (define-key gp-map "▄\\" (quote gp-break-long-line))
  76.  
  77. (define-key gp-map "" (quote gp-interrupt))
  78.  
  79. (defvar gp-process nil "\
  80. ")
  81.  
  82. (defvar gp-man-process nil "\
  83. ")
  84.  
  85. (defun gp (flag) "\
  86.  
  87.    Open a buffer and a window for the execution of gp.
  88.  
  89.    The following bindings are available:
  90.    \\{gp-map}
  91.  
  92.   The variables
  93.   gp-file-name gp-stack-size gp-buffer-size gp-prime-limit
  94.   determine the command line that starts gp.
  95.   To override the default settings, give gp a prefix argument.
  96.   C-u M-x gp ." (interactive "P") (byte-code "┴ê╬╧!êdbêâ┴én╨ ê╤ëê╥ëê╙╘!ê╒ !ê╓ëêå/╫╪    ┘$╫┌
  97. █$╫▄ ▌$╫▐ ▀$RααQcêßΓ╧πΣP%ë*êσµ\"ç" [gp-process nil major-mode mode-name gp-map mode-line-process flag gp-prompt-for-args gp-command gp-file-name gp-stack-size gp-buffer-size gp-prime-limit shell-file-name switch-to-buffer "*PARI*" kill-all-local-variables gp "GP" run-hooks gp-mode-hook use-local-map (": %s") gp-read-input "Gp executable ?" "" "Stack size ?" " -s " "Buffer size ?" " -b " "Prime limit ?" " -p " "
  98. " start-process "pari" "-c" "stty nl; exec " set-process-sentinel gp-sentinel] 15))
  99.  
  100. (defun gp-read-input (prompt default sep flag) "\
  101.  If flag is non-nil, reads string then if string is \"\" uses default.
  102.   If flag is nil then string is the default.
  103.   If resulting string is not \"\" prepends sep.
  104.   As a special case, if string is a space, return \"\"." (byte-code "    â┼
  105. ╞ ╟R!é ╚╔\"â(╚ ╔\"â\"╔é% Pé6╚╩\"â3╔é6 P)ç" [string flag prompt default sep read-input " (Default " ") " equal "" " "] 6))
  106.  
  107. (defun gp-sentinel (proc msg) "\
  108. Sentinel for the gp-process in buffer *PARI*." (byte-code "╩╦!à    ╠╦!ê═    !à╠!)ê═
  109. !à\"╠!)ê╩╬!à6╬qêdbê cê╧╬!ê╨ !àI╤╥ P╙╔+ê╔ëç" [b gp-chap3 gp-menu msg gp-temp-file shell-file-name shell-command message gp-process nil get-buffer "*gp-help*" kill-buffer get-file-buffer "*PARI*" delete-windows-on file-exists-p "/bin/sh" "rm " "Removing %s"] 12))
  110.  
  111. (defun gpman nil "\
  112. Start up xdvi with the gp manual." (interactive) (byte-code "┴ê┼╞!ê╟╚!qêâ┴é-╔╩
  113. ╦ R!ê╠═╚ ╬╧
  114. ╦ R%ëê╨╤\"ç" [gp-man-process nil gp-dvi-preview gp-man-dvi shell-file-name run-hooks gp-mode-hook get-buffer-create "*GP-MAN*" message "Starting " " " start-process "gp-man" "-c" "exec " set-process-sentinel gp-man-sentinel] 12))
  115.  
  116. (defun gp-man-sentinel (proc msg) "\
  117. Sentinel for the gp-man-process in buffer *GP-MAN*." (byte-code "┼    !à ╞!)ê╟╚
  118. P!ê─ëç" [buf proc msg gp-man-process nil process-buffer kill-buffer message "gpman: "] 5))
  119.  
  120. (defun gp-copy-input nil "\
  121. Copy expression around point to the end of the buffer.
  122.    (Unless this is already the last expression.)" (interactive) (byte-code "╔ê╩!ê╦╠!═ ê╬!ê`ëê    b)ê╬╧╨Qd─# â,╤╠!é-d
  123. bê╥╙!â;╘é<╒╬╓#ëê`ëê àjdbê╫
  124. \"cêâd╔éj╪ ê┘┌!)))ç" [gp-prompt-pattern p gp-input-start nlast t limit end-expression gp-complete-expression gp-input-end nil re-search-backward match-end 0 beginning-of-line re-search-forward "[
  125.  ]*\\(" "\\|^%[0-9]+ = \\|^ *\\*\\*\\*\\|^ *unused characters\\|^ *time[ r]\\)" match-beginning looking-at " *{" "}$" "[^\\]$" 1 buffer-substring ding message "Incomplete expression."] 12))
  126.  
  127. (defun gp-send-input nil "\
  128. Send input to gp. Does not send incomplete expressions
  129.    ie those starting with {, without a matching }, or those
  130.    ending with \\ .
  131.    Use a temporary file (and \\r )for large expressions" (interactive) (byte-code "┼ê╞ ê╟cêâ8    
  132. Z╚Vâ$╔
  133.      #ê╩ ╦ ╟Q\"é.╠
  134.     #ê╩ ╟\"ê═╬ !`\"é;╧╨!ç" [gp-complete-expression gp-input-end gp-input-start gp-temp-file gp-process nil gp-copy-input "
  135. " 255 write-region process-send-string "\\r " process-send-region set-marker process-mark message "Incomplete expression: Not sent to gp."] 9))
  136.  
  137. (defun gp-interrupt nil "\
  138. Interrupt gp.
  139.    This is identical to interrupt-shell-subjob in shell-mode." (interactive) (byte-code "└ê┬└┴\"ç" [nil t interrupt-process] 3))
  140.  
  141. (defun gp-set-prompt (p) "\
  142. Set new gp prompt (and tell emacs that you have done so).
  143.    Do not put spaces in the argument, or emacs and gp will
  144.    have a different idea about what the prompt is." (interactive "sNew prompt: ") (byte-code "┬ê├    !─Qëê┼qêdbê╞    Pcê╟ ç" [gp-prompt-pattern p nil regexp-quote "[
  145.      ]*\\|" "*PARI*" "\\prompt=" gp-send-input] 4))
  146.  
  147. (defun gp-replace (a b) "\
  148. Replace the regexp a by the string b everywhere in the current buffer" (byte-code "ebê├d┴#à─
  149. ┴┴#êéç" [a t b re-search-forward replace-match] 6))
  150.  
  151. (defun gp-get-man-entry (fn) "\
  152. Obtains the description of fn from chapter 3 of the manual.
  153.   Strips off some (not all) of the TeX syntax, and displays the result
  154.   in a new window.
  155.   If there is no entry for fn in the manual, sends ?fn to gp." (interactive "sFunction: ") (byte-code "┴ê┴╚
  156. !q)ê╔ ╩\"â╦é╖╔ ╠\"â ═é╖╔ ╬\"â+╧é╖╔ ╨\"â6╤é╖╔ ╥\"âA╙é╖╔ ╘\"âL╒é╖╔ ╓\"âW╫é╖╔ ╪\"âb┘é╖╔ ┌\"âm█é╖╔ ▄\"âx▌é╖╔ ▐\"å¡╔ ▀\"å¡╔ α\"å¡╔ ß\"å¡╔ Γ\"å¡╔ π\"å¡╔ Σ\"å¡╔ σ\"â┤µé╖τ !ebêΦΘ ΩQd┼#âδ∞!bêφ`Φεd┼#ê∩≡!\"± ≥≤⌠!!ê⌡ êcê÷≈╘\"ê÷°∙\"ê÷╦╩\"ê÷·╠\"ê÷√ⁿ\"êebê²!*é■qê ü@ P!)ç" [auto-mode-alist nil gp-chap3 qfn fn t copy wind find-file-noselect equal "\\" "\\\\backslash" "^" "\\\\hat{}" "!" "fact" "~" "trans" "_" "conj" "-" "\\+" "%" "\\\\%" "min" "max" "log" "ln" "det2" "det" "<=" "<" ">=" ">" "==" "!=" "||" "&&" "comparison and \\\\ref{boolean operators}" regexp-quote re-search-forward "\\(subsec[\\\\{ref]*[\\${]\\)" "[}\\$]" match-end 1 buffer-substring "[tT]he library\\|\\\\[sub]*sec" match-beginning 0 selected-window switch-to-buffer-other-window get-buffer-create "*gp-help*" erase-buffer gp-replace "\\$-" "\\$" " " "\\\\hat" "\\\\smallskip\\|\\\\sref{[ a-z]*}\\|\\\\bf\\|\\\\ref\\|\\\\Bbb\\|\\\\text\\|\\\\tt\\|{\\|}" "" select-window "*PARI*" gp-meta-command "?"] 39))
  157.  
  158. (defun gp-meta-command (command) "\
  159. Send command to gp, and display output in help buffer" (byte-code "dbê`┼ ╞
  160. ╟P\"ê╚ ê╔d\"╩d\"ê╦╠═!!ê╬ ê cê╧ ê╩`d\"êebê╨    !)*ç" [temp wind gp-process command copy selected-window process-send-string "
  161. " gp-wait-for-output buffer-substring delete-region switch-to-buffer-other-window get-buffer-create "*gp-help*" erase-buffer beginning-of-line select-window] 12))
  162.  
  163. (defun gp-wait-for-output nil "\
  164. Hang around until the prompt appears." (byte-code "┴ëêà,┼╞!ê`╟ ê╚ !â!╔╩!ê─ëé$╔╦!ê
  165. b)êéç" [ndone t p gp-prompt-pattern nil accept-process-output "*PARI*" beginning-of-line looking-at message "done" "Waiting for gp output ..."] 7))
  166.  
  167. (defun gp-meta-d nil "\
  168. Sends \\d to gp, then displays output in the help buffer.
  169.   Prints the gp defaults." (interactive) (byte-code "└ê┴┬!ç" [nil gp-meta-command "\\d"] 2))
  170.  
  171. (defun gp-meta-t nil "\
  172. Sends \\t to gp, then displays output in the help buffer.
  173.   Prints the longword format of PARI types." (interactive) (byte-code "└ê┴┬!ç" [nil gp-meta-command "\\t"] 2))
  174.  
  175. (defun gp-meta-r (file) "\
  176. Sends a \\r <file name> comand to gp.
  177.    Reads in gp commands from a file.
  178.    See gp-meta-r" (interactive "fRead from file: ") (byte-code "┴êdbê┬├!Pcê─ ç" [file nil "\\r " expand-file-name gp-send-input] 3))
  179.  
  180. (defun gp-meta-w (file num) "\
  181. Sends a \\w<num> <file name> comand to gp.
  182.   Writes gp object %<num> to <file name>." (interactive "FWrite to file: 
  183. sObject number %%") (byte-code "┬êdbê├─┼    !Rcê╞ ç" [num file nil "\\w" " " expand-file-name gp-send-input] 5))
  184.  
  185. (defun gp-meta-x nil "\
  186. Sends \\x to gp, then displays output in the help buffer.
  187.   Prints tree of addresses and contents of last object." (interactive) (byte-code "└ê┴┬!ç" [nil gp-meta-command "\\x"] 2))
  188.  
  189. (defun gp-meta-v nil "\
  190. Sends \\v to gp, then displays output in the help buffer.
  191.   Prints the version number of this implementation of pari-gp." (interactive) (byte-code "└ê┴┬!ç" [nil gp-meta-command "\\v"] 2))
  192.  
  193. (defun gp-meta-s (num) "\
  194. Sends \\s or \\s(num) to gp, then displays output in the help buffer.
  195.   Prints the state of the pari stack." (interactive "sNumber of longwords (default 0) ") (byte-code "┴ê┬├\"â─┼!é─╞╟Q!ç" [num nil equal "" gp-meta-command "\\s" "\\s(" ")"] 6))
  196.  
  197. (defun gp-meta-a (num) "\
  198. Sends \\a or \\a<num> to gp, then displays output in the help buffer.
  199.   Prints object %<num> in raw format." (interactive "sPrint object (default last) %%") (byte-code "┴ê┬├\"â─┼!é─┼P!ç" [num nil equal "" gp-meta-command "\\a"] 5))
  200.  
  201. (defun gp-meta-b (num) "\
  202. Sends \\b or \\b<num> to gp, then displays output in the help buffer.
  203.   Prints object %<num> in pretty format." (interactive "sPrint object (default last) %%") (byte-code "┴ê┬├\"â─┼!é─┼P!ç" [num nil equal "" gp-meta-command "\\b"] 5))
  204.  
  205. (defun gp-meta-m (num) "\
  206. Sends \\m or \\m<num> to gp, then displays output in the help buffer.
  207.   Prints object %<num> in prettymatrix format." (interactive "sPrint object (default last) %%") (byte-code "┴ê┬├\"â─┼!é─┼P!ç" [num nil equal "" gp-meta-command "\\m"] 5))
  208.  
  209. (defun gp-meta-k nil "\
  210. Sends \\k to gp.
  211.   Prompts for confirmation before 
  212.   re-initialising gp and clearing the buffer." (interactive) (byte-code "┴ê┬├!à%─qêdbê┼cê╞╟!`\"ê┬╚!à ╔ ê╩┼\"ê╦╠!ç" [gp-process nil y-or-n-p "Re-initialise gp ? " "*PARI*" "\\k
  213. " set-marker process-mark "Clear *PARI* buffer ? " erase-buffer process-send-string message ""] 8))
  214.  
  215. (defun gp-meta-q nil "\
  216. Sends \\q to gp.
  217.   Prompts for confirmation before quiting." (interactive) (byte-code "┴ê┬├!à─qêdbê┼╞\"ê╟╚!ç" [gp-process nil y-or-n-p "Quit gp ? " "*PARI*" process-send-string "\\q
  218. " message ""] 4))
  219.  
  220. (defun gp-break-long-line nil "\
  221. gp will not accept lines longer than 256.
  222.    gp-break-long-line breaks current line 
  223.    inserting \\ every (screen-width)-5 chars." (interactive) (byte-code "┴ê┬ ├Z─^┼!ê╞╟!?à╚cê┼!êé)ç" [length nil screen-width 5 250 move-to-column looking-at "$" "\\
  224. "] 6))
  225.  
  226. (defun gp-menu nil "\
  227. Major-mode for the gp menu buffer.
  228. The available commands are
  229. \\{gp-menu-map}" (interactive) (byte-code "╞ê╟!ê┬ëê╚ ê└ëê╔ëê╩!ê╦ ç" [gp-menu buffer-read-only t major-mode mode-name gp-menu-map nil find-file-other-window kill-all-local-variables "GP MENU" use-local-map gp-menu-main] 5))
  230.  
  231. (defun gp-menu-info nil (byte-code "└┴!ç" [message "SPC=next DEL=previous RET=select m=main-menu q=quit s=scroll-help"] 2))
  232.  
  233. (defun gp-menu-next nil "\
  234. Move down one line of the gp help menu. (Go to top if at the end.)" (interactive) (byte-code "└ê┴ ê┬├!êmà─ êebç" [nil gp-menu-info forward-line 1 ding] 4))
  235.  
  236. (defun gp-menu-previous nil "\
  237. Move up one line of the gp help menu. (Go to bottom if at the top.)" (interactive) (byte-code "└ê┴ êoâ┬ êdbê├ é─┼!ç" [nil gp-menu-info ding beginning-of-line forward-line -1] 5))
  238.  
  239. (defun gp-menu-quit nil "\
  240. Switch the *PARI* buffer if it exists, or (other-buffer) if it does not." (interactive) (byte-code "├ê─┼!╞┼!â╟ ê╚!é%    â!╔    !é%╔╩ !*ç" [w b t nil get-buffer-window "*PARI*" get-buffer delete-window select-window switch-to-buffer other-buffer] 8))
  241.  
  242. (defun gp-menu-select nil "\
  243. Select a subject from the main menu, or a manual entry from a subject menu." (interactive) (byte-code "┴êâ3┴ëê├ ê─ ê┼`╞ ê`\"╟╚╔
  244. P!ê╩╦!ê`╚╠!ê═╬!\")êebé?─ ê╧┼`╞ ê`\"!ê╨ ç" [main-menu nil sect widen beginning-of-line buffer-substring end-of-line narrow-to-region re-search-forward "^###" forward-line 1 "
  245. ###" match-beginning 0 gp-get-man-entry gp-menu-info] 15))
  246.  
  247. (defun gp-menu-main nil "\
  248. Display the main menu." (interactive) (byte-code "┴ê─ ê┼ êebê╞`╟╚!ê╔╩!\"êebê┴ëê├ëç" [done nil main-menu t gp-menu-info widen narrow-to-region re-search-forward "
  249. ###" match-beginning 0] 7))
  250.  
  251. (defun gp-menu-scroll nil "\
  252. Scroll the gp help window if it is visible" (interactive) (byte-code "┴ê┬ ê├─!à$┼ ╞─!ê╟d!âebé╚ ê╔!)ç" [wind nil gp-menu-info get-buffer-window "*gp-help*" selected-window switch-to-buffer-other-window pos-visible-in-window-p scroll-up select-window] 8))
  253.  
  254. (defvar gp-menu-map (make-sparse-keymap) "\
  255. Local keymap used in gp menu buffer.")
  256.  
  257. (define-key gp-menu-map " " (quote gp-menu-next))
  258.  
  259. (define-key gp-menu-map "" (quote gp-menu-previous))
  260.  
  261. (define-key gp-menu-map "" (quote gp-menu-select))
  262.  
  263. (define-key gp-menu-map "q" (quote gp-menu-quit))
  264.  
  265. (define-key gp-menu-map "m" (quote gp-menu-main))
  266.  
  267. (define-key gp-menu-map "s" (quote gp-menu-scroll))
  268.