Karim Belabas on Wed, 10 Mar 1999 17:21:12 +0100 (MET) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
pari.el-2.24 patch |
Here is a patch for pari.el which I received from Olivier Ramare. It should address the problems that he and Paul van Wamelen mentioned lately (pari-dev-460 && 462). It applies to the emacs files distributed in pari-2.0.14, and none of the previous ones. I did not test it (don't use Emacs...), but it looks ok. Karim. *** emacs/pari.el.in.orig Wed Mar 10 17:13:52 1999 --- emacs/pari.el.in Wed Mar 10 16:54:36 1999 *************** *** 6,12 **** ;; All functions of gp are preserved. ! ;; Version 2.24 (28-January-1999) ;; The original pari.el was written by Annette Hoffman. ;; Modified by David Carlisle (JANET: carlisle@uk.ac.man.cs). ;; Modified by Karim Belabas (belabas@math.u-bordeaux.fr) for gp 2.xxx. --- 6,12 ---- ;; All functions of gp are preserved. ! ;; Version 2.25 (10-March-1999) ;; The original pari.el was written by Annette Hoffman. ;; Modified by David Carlisle (JANET: carlisle@uk.ac.man.cs). ;; Modified by Karim Belabas (belabas@math.u-bordeaux.fr) for gp 2.xxx. *************** *** 48,57 **** ;; to work properly with macro, they *should* be defined before ;; they are called. - ;; Weirdies : Comparison and \idx{boolean operators - ;; +$/$- - - (provide 'pari) ;;-------------------------- --- 48,53 ---- *************** *** 289,294 **** --- 285,330 ---- (defvar gp-color-menu-list nil "List containing the color menu.") + (defvar gp-syntax-table nil + "Syntax table in use in gp-mode and gp-script-mode buffers.") + + (if gp-syntax-table + () + (setq gp-syntax-table (make-syntax-table)) + (modify-syntax-entry ?( "()" gp-syntax-table) + (modify-syntax-entry ?) ")(" gp-syntax-table) + (modify-syntax-entry ?[ "(]" gp-syntax-table) + (modify-syntax-entry ?] ")[" gp-syntax-table) + (modify-syntax-entry ?{ "(}" gp-syntax-table) + (modify-syntax-entry ?} "){" gp-syntax-table) + (modify-syntax-entry ?# "." gp-syntax-table) + (modify-syntax-entry ?~ "_" gp-syntax-table) ; symbols + (modify-syntax-entry ?! "_" gp-syntax-table) ; symbols + (modify-syntax-entry ?+ "." gp-syntax-table) + (modify-syntax-entry ?- "." gp-syntax-table) + ;(modify-syntax-entry ?/ ". 1456" gp-syntax-table) ; XEmacs? + (modify-syntax-entry ?/ ". 14" gp-syntax-table) + (modify-syntax-entry ?* ". 23" gp-syntax-table) + (modify-syntax-entry ?\\ ". 12b" gp-syntax-table) + + (if (string-match "XEmacs" emacs-version) + (progn + (modify-syntax-entry ?\n ">b" gp-syntax-table) + ;; Give CR the same syntax as newline, for selective-display + (modify-syntax-entry ?\^m ">b" gp-syntax-table) + ) + (modify-syntax-entry ?\n "> b" gp-syntax-table) + ;; Give CR the same syntax as newline, for selective-display + (modify-syntax-entry ?\^m "> b" gp-syntax-table) + ) + (modify-syntax-entry ?= "." gp-syntax-table) + (modify-syntax-entry ?% "." gp-syntax-table) + (modify-syntax-entry ?< "." gp-syntax-table) + (modify-syntax-entry ?> "." gp-syntax-table) + (modify-syntax-entry ?$ "." gp-syntax-table) + (modify-syntax-entry ?| "." gp-syntax-table) + (modify-syntax-entry ?_ "w" gp-syntax-table)) + (defvar gp-map nil "Local keymap used in buffer *PARI*.") *************** *** 366,372 **** (define-key completion-list-mode-map [mouse-2] (function gp-mouse-2)) ! (define-key minibuffer-local-completion-map " " 'self-insert-command) ;; It is usually 'minibuffer-complete-word, but C-i does that. ;; Maps used for the menu-bar. --- 402,408 ---- (define-key completion-list-mode-map [mouse-2] (function gp-mouse-2)) ! ;; (define-key minibuffer-local-completion-map " " 'self-insert-command) ;; It is usually 'minibuffer-complete-word, but C-i does that. ;; Maps used for the menu-bar. *************** *** 396,404 **** ("\\*\\*\\*.*" nil gp-error) ("\\<\\(buffersize\\|colors\\|compatible\\|debug\\|debugmem\\|echo\\|format\\|help\\|histsize\\|logfile\\|output\\|parisize\\|path\\|primelimit\\|prompt\\|psfile\\|realprecision\\|seriesprecision\\|simplify\\|strictmatch\\|timer\\)\\>" nil gp-default-keywords) ;; In the next one, we avoid `log(10)' and `"pari.log"': ! ("[\\<\\.]\\(log\\)[^a-zA-Z0-9_\\.(\"]" 1 gp-default-keywords) ("^ *\\\\[a-z].*$" nil gp-default-set) ! ("\\(\\`\\|[^a-zA-Z0-9_]\\)\\(default\\)(" 2 gp-default-set) ("^ *%[0-9]* = \\(.*$\\)" 1 gp-output)))))) --- 432,440 ---- ("\\*\\*\\*.*" nil gp-error) ("\\<\\(buffersize\\|colors\\|compatible\\|debug\\|debugmem\\|echo\\|format\\|help\\|histsize\\|logfile\\|output\\|parisize\\|path\\|primelimit\\|prompt\\|psfile\\|realprecision\\|seriesprecision\\|simplify\\|strictmatch\\|timer\\)\\>" nil gp-default-keywords) ;; In the next one, we avoid `log(10)' and `"pari.log"': ! ("[\\<\\.]\\(log\\)[^\\w\\.(\"]" 1 gp-default-keywords) ("^ *\\\\[a-z].*$" nil gp-default-set) ! ("\\<\\(default\\)(" 2 gp-default-set) ("^ *%[0-9]* = \\(.*$\\)" 1 gp-output)))))) *************** *** 419,431 **** 'gp-script-mode '( (gp-find-comment nil gp-comment) ! ("\\(\\`\\|[^a-zA-Z0-9_]\\)\\(return\\|next\\|if\\|until\\|while\\|\\|fordiv\\|forprime\\|forstep\\|forvec\\|for\\) *(" 2 gp-control-statement) ! ("\\(\\`\\|[^a-zA-Z0-9_]\\)\\(break\\)[^a-zA-Z0-9_]" 2 gp-control-statement) ! ("\\(\\`\\|[^a-zA-Z0-9_]\\)\\(default\\)(" 2 gp-default-set) ! ("\\(\\`\\|[^a-zA-Z0-9_]\\)\\(read\\)[^a-zA-Z0-9_]" 2 gp-input-cmd) ! ("\\(\\`\\|[^a-zA-Z0-9_]\\)\\(local\\)\\([ \t\n]*(\\)" 2 gp-input-cmd) (hilit-string-find ?\\ gp-string) --- 455,467 ---- 'gp-script-mode '( (gp-find-comment nil gp-comment) ! ("\\<\\(return\\|next\\|if\\|until\\|while\\|\\|fordiv\\|forprime\\|forstep\\|forvec\\|for\\) *(" 1 gp-control-statement) ! ("\\<\\(break\\)[^a-zA-Z0-9_]" 1 gp-control-statement) ! ("\\<\\(default\\)(" 1 gp-default-set) ! ("\\<read\\>[^a-zA-Z0-9_]" 0 gp-input-cmd) ! ("\\<\\(local\\)\\([ \t\n]*(\\)" 1 gp-input-cmd) (hilit-string-find ?\\ gp-string) *************** *** 506,512 **** (if (file-really-exists-p gp-additional-completion-file) ;; Add this file to the usual completion array. (gp-completion-file gp-additional-completion-file)) ! (gp-learn-sexp)) ;;;###autoload (defun gp-script-mode () --- 542,549 ---- (if (file-really-exists-p gp-additional-completion-file) ;; Add this file to the usual completion array. (gp-completion-file gp-additional-completion-file)) ! (gp-learn-sexp) ! (set-syntax-table gp-syntax-table)) ;;;###autoload (defun gp-script-mode () *************** *** 600,606 **** (progn (message "done") (setq notdone nil)) ;; Else flush the buffer and wait a bit longer. (progn (message "Waiting for gp output ...") ! (goto-char p) (sit-for 0))) (goto-char p)))) (sit-for 0)) --- 637,643 ---- (progn (message "done") (setq notdone nil)) ;; Else flush the buffer and wait a bit longer. (progn (message "Waiting for gp output ...") ! (sit-for 0))) (goto-char p)))) (sit-for 0)) *************** *** 829,836 **** (looking-at "\\\\")))) (not (looking-at "\\\\"))))) - (defun aa nil (interactive) (print (gp-end-of-inputp))) - (defun gp-find-end-of-input (end) "Give the position of next end-of-input and nil if none." (save-excursion --- 866,871 ---- *************** *** 874,888 **** (setq gp-complete-expression (gp-end-of-inputp)))) ;; We refine 'gp-complete-expression: ! (let ((ans (parse-partial-sexp gp-input-start gp-input-end))) (setq gp-complete-expression (and gp-complete-expression (equal (nth 0 ans) 0) ;; Depth in parens is 0. ! (equal (save-excursion ! (goto-char (nth 2 ans)) ! (forward-sexp) ! (point)) ! gp-input-end) (not (nth 3 ans)) ;; Not inside a string. ;; This one does not work... Why ?? (not (nth 4 ans)) ;; Not inside a comment. --- 909,926 ---- (setq gp-complete-expression (gp-end-of-inputp)))) ;; We refine 'gp-complete-expression: ! (let ((ans (parse-partial-sexp gp-input-start gp-input-end)) a-pt) (setq gp-complete-expression (and gp-complete-expression (equal (nth 0 ans) 0) ;; Depth in parens is 0. ! (or (not (nth 2 ans)) ! (equal (save-excursion ! (goto-char (nth 2 ans)) ! (forward-sexp) ! (setq a-pt (point))) ! gp-input-end) ! (and (char-equal (preceding-char) ?;) ! (equal a-pt (1- gp-input-end)))) (not (nth 3 ans)) ;; Not inside a string. ;; This one does not work... Why ?? (not (nth 4 ans)) ;; Not inside a comment. *************** *** 995,1001 **** (if (gp-treat-special-inputp) nil ;; already treated. (gp-copy-input)) ;; does all the work! ! (if gp-complete-expression ;; If it is a complete expression do this: (progn (insert "\n") --- 1033,1039 ---- (if (gp-treat-special-inputp) nil ;; already treated. (gp-copy-input)) ;; does all the work! ! (if gp-complete-expression ;; If it is a complete expression do this: (progn (insert "\n") *************** *** 1152,1169 **** (if (or (string= my-buffer-name "*gp-help*") (not (get-buffer "*gp-help*"))) ;; Exit from help or the gp-menu is alone: ! (and (buffer-visiblep "*gp-help*") ! (gp-restore-wind-conf)) (if (string= my-buffer-name "*gp-menu*") ;; The previous condition should always be verified! ;; We should remove the window displaying gp-menu: (progn ! (gp-depile-wind-conf) ! (if (= (count-windows) 2) (progn ! (and (get-buffer "*gp-help*") ! (switch-to-buffer "*gp-help*")) ! (other-window 1)))))) ;; We have to kill the buffer (in any case) and select ;; a proper buffer for this window in case this killing ;; made something weird appear: --- 1190,1207 ---- (if (or (string= my-buffer-name "*gp-help*") (not (get-buffer "*gp-help*"))) ;; Exit from help or the gp-menu is alone: ! (gp-restore-wind-conf) (if (string= my-buffer-name "*gp-menu*") ;; The previous condition should always be verified! ;; We should remove the window displaying gp-menu: (progn ! (if (and (= (count-windows) 2) ! (get-buffer "*gp-help*")) (progn ! (gp-depile-wind-conf) ! (switch-to-buffer "*gp-help*") ! (other-window 1)) ! (gp-restore-wind-conf))))) ;; We have to kill the buffer (in any case) and select ;; a proper buffer for this window in case this killing ;; made something weird appear: *************** *** 1634,1640 **** (defun backward-gpword nil "Seeks the beginning of a gpword. A gpword is a continuous chain ! of [a-zA-Z_0-9]. Returns point." (if (bobp) (point) (forward-char -1) --- 1672,1678 ---- (defun backward-gpword nil "Seeks the beginning of a gpword. A gpword is a continuous chain ! of [a-zA-Z_0-9] not starting with a digit. Returns point." (if (bobp) (point) (forward-char -1) *************** *** 1658,1667 **** (defun forward-gpword nil "Seeks the end of a gpword. A gpword is a continuous chain of [a-zA-Z_0-9]. Returns point." ! (re-search-forward "\\([a-zA-Z0-9_]+\\)\\([^a-zA-Z0-9_]\\|\\'\\)" ! (point-max) t) ! (goto-char (match-end 1)) ! (point)) (defun gp-find-word-to-complete nil (backward-gpword) --- 1696,1702 ---- (defun forward-gpword nil "Seeks the end of a gpword. A gpword is a continuous chain of [a-zA-Z_0-9]. Returns point." ! (forward-word 1) (point)) (defun gp-find-word-to-complete nil (backward-gpword) *************** *** 2260,2272 **** (word (gp-find-word-to-complete)) ;; get the argument from the minibuffer into arg (arg ! (completing-read ! (concat (, this-type) ! (if (intern-soft word gp-c-array) ;; If the word before point is a gp function, offer it as default. ! (concat " [Default " word "]" )) ": ") ;; use gp-c-array as the completion array ! gp-c-array))) (if (equal arg "") ;; If the argument supplied is "", and word is a gp symbol, use it as default. ;; (Do not use "" as fn in anycase, so otherwise use " ", which will not --- 2295,2311 ---- (word (gp-find-word-to-complete)) ;; get the argument from the minibuffer into arg (arg ! (progn ! (define-key minibuffer-local-completion-map " " 'self-insert-command) ! ;; It is usually 'minibuffer-complete-word, but C-i does that. ! (completing-read ! (concat (, this-type) ! (if (intern-soft word gp-c-array) ;; If the word before point is a gp function, offer it as default. ! (concat " [Default " word "]" )) ": ") ;; use gp-c-array as the completion array ! gp-c-array)))) ! (define-key minibuffer-local-completion-map " " 'minibuffer-complete-word) (if (equal arg "") ;; If the argument supplied is "", and word is a gp symbol, use it as default. ;; (Do not use "" as fn in anycase, so otherwise use " ", which will not *************** *** 2280,2287 **** (interactive (gp-ask-name-wisely "Function")) (shell-command ! (concat gp-gphelp-dir "gphelp " fn) ! nil) (if (buffer-live-p (get-buffer "*Shell Command Output*")) (save-excursion (set-buffer "*Shell Command Output*") --- 2319,2325 ---- (interactive (gp-ask-name-wisely "Function")) (shell-command ! (concat gp-gphelp-dir "gphelp \"" fn "\"")) (if (buffer-live-p (get-buffer "*Shell Command Output*")) (save-excursion (set-buffer "*Shell Command Output*") *************** *** 2356,2361 **** --- 2394,2400 ---- in whose description the expression EXP appears. Similar to \"??? exp\" in gp." (interactive (gp-ask-name-wisely "Subject")) + (gp-window-manager "*gp-menu*" 'gp-beginning) (insert (format *************** *** 2384,2389 **** --- 2423,2429 ---- (search-forward "\n###\n") (gp-menu-info))) + ;;------------------------ ;; PART V : HIGHLIGHTING ;;------------------------ *************** *** 2868,2871 **** (list ["Previous Setting" gp-restore-wind-conf gp-registers-list]))))) ! ;;; pari.el ends here ----------2873 lines --- 2908,2911 ---- (list ["Previous Setting" gp-restore-wind-conf gp-registers-list]))))) ! ;;; pari.el ends here ----------2911 lines -- Karim Belabas email: Karim.Belabas@math.u-psud.fr Dep. de Mathematiques, Bat. 425 Universite Paris-Sud Tel: (33 1) 01 69 15 57 48 F-91405 Orsay (France) Fax: (33 1) 01 69 15 60 19 -- PARI/GP Home Page: http://hasse.mathematik.tu-muenchen.de/ntsw/pari/