[BACK]Return to pariemacs.txt CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / pari / emacs

Annotation of OpenXM_contrib/pari/emacs/pariemacs.txt, Revision 1.1.1.1

1.1       maekawa     1: This file refers to pari.el version 2.32
                      2:
                      3: Users that are used to previous versions should read the part concerning hooks.
                      4: Also, one key-binging has been changed: M-RET (meta-return) is not linked
                      5: anymore to 'gp-copy-input which copies the input at the end of the buffer
                      6: but to 'gp-C-j which splits the line. The same effect can be obtained via
                      7: C-j. The command 'gp-copy-input is available via M-c (meta-c).
                      8: If your version of emacs is at least 20, then customization of most of the
                      9: varaibles is now possible through the menu-bar.
                     10: !! The variables 'gp-stack-size and 'gp-prime-limit are now *integers*.
                     11:
                     12:                Some Notes on pari-mode
                     13:                =======================
                     14:
                     15: pari-mode runs pari-gp as a sub process of (gnu-)emacs. Note that pari-mode
                     16: is *not* a mode in itself but the collection of two modes, namely
                     17: gp-mode and gp-script-mode described below.
                     18:
                     19: INSTALLATION.
                     20: =============
                     21:
                     22: pari-mode consists of four files: pariemacs.txt (this file, for information
                     23: only), pari.el and two files aimed at writing extensions of pari.el:
                     24: gp-translator.el and with-syntax.el which is an example of how to write
                     25: such an extension. When GP is installed, those four files are
                     26: placed in a convenient directory (/usr/local/lib/pari by default) and pari.el
                     27: is byte-compiled, producing a file pari.elc. (If this directory is not in
                     28: your EMACSLOADPATH, read a full path and not only "pari" in the line below.)
                     29:
                     30: To use pari-mode, users should add the following line to their .emacs:
                     31:
                     32: (autoload 'gp-mode "pari" nil t)
                     33: (autoload 'gp-script-mode "pari" nil t)
                     34: (autoload 'gp "pari" nil t)
                     35: (autoload 'gpman "pari" nil t)
                     36:
                     37: Some specific highlighting is then enabled when editing *.gp files
                     38: (gp-scripts) and three main new commands are made available:
                     39:
                     40: M-x gp      starts up the pari-gp process in a new buffer,  *PARI*.
                     41: C-u M-x gp  same as M-x gp, but prompts for the command line arguments.
                     42: M-x gpman   starts up a dvi previewer with the PARI-GP manual.
                     43:
                     44: To use gpman, you must copy (or link) the file doc/users.dvi (from the
                     45: standard distribution) to the directory pari.el was installed in.
                     46:
                     47: We recommend the use of emacs 20.3 or higher since the installation of
                     48: the menu-bar item may be quite slow with earlier versions.
                     49: ===========================================================================
                     50:
                     51: GP-MODE/GP-SCRIPT-MODE:
                     52: =======================
                     53:
                     54: The file pari.el introduces two modes. The first one, called gp-mode, is
                     55: patterned for executing commands under gp. You can then use gp as if you
                     56: had typed "gp" on your terminal, except that some more features are available,
                     57: in particular a full page editor (namely emacs !). The second mode is
                     58: gp-script-mode which helps the user to write gp-scripts (programs). Some
                     59: further commands are available and described below. Most of these commands
                     60: are available through the menu-bar item GP. Starting a gp process
                     61: under emacs will automatically trigger gp-mode. To use gp-script-mode, you
                     62: have two possibilities: either to add the following lines to your .emacs:
                     63:
                     64: (setq auto-mode-alist (cons '("\\.gp$" . gp-script-mode)
                     65:                               auto-mode-alist))
                     66:
                     67: so that any file with the suffix ".gp" will be understood as a gp-script
                     68: and its edition will trigger gp-script-mode, either to simply make the first
                     69: line of your program be
                     70:
                     71: \\  -*-gp-script-*-
                     72:
                     73: (In fact you can put anything on this first line, provided you include
                     74: the string "-*-gp-script-*-").
                     75:
                     76: Common commands:
                     77:
                     78: KEY      LISP-NAME             DESCRIPTION
                     79: ===      =========             ===========
                     80: TAB      gp-complete           Complete the partly typed gp input line.
                     81:                                If your .gprc has been built with readline,
                     82:                                then the lisp-name is gp-complete2.
                     83: M-?      gp-get-man-entry      Display the manual entry for a gp command.
                     84: M-H      gp-get-apropos        Find all entries in the manual which contain
                     85:                                the string you give.
                     86: M-\ c    gp-help-menu          Some general help.
                     87: M-\ v    gp-meta-v             Display the version number of the gp file.
                     88: M-o      gp-restore-wind-conf  Strives to restore the previous window
                     89:                                configuration and to remove help windows.
                     90:          run-gp                Make gp read a file. Start a gp process
                     91:                                if required.
                     92:          gp-get-TeX-man-entry  Display a description of a given function
                     93:                                in TeX. This function will start
                     94:                                a gp process if none is running.
                     95:          gp-completion-file    Add a file to the completion list.
                     96:                                (See gp-make-completion-file below)
                     97:          gp-edit-completion-file
                     98:                                Edit a completion file.
                     99:                                (See gp-make-completion-file below)
                    100:          gp-completion-file-info
                    101:                                Some informations on completion files.
                    102: C-l                            Update hilighting locally.
                    103: C-u C-l                        Rehilight the whole buffer, however long.
                    104:          gp-set-simple-prompt  Set the prompt to "? "
                    105:          gp-set-time-prompt    Set a prompt giving the time.
                    106:          gp-set-date-prompt    Set a prompt that gives the date.
                    107:          gp-set-separator-prompt
                    108:                                Set a prompt with a separator
                    109: M-s      gp-skip-to-error      Strives to locate the latest error detected
                    110:                                while executing a program.
                    111:
                    112:
                    113: Functions that are not linked with a key can be accessed through the menu-bar
                    114: or through M-x lisp-name.
                    115:
                    116: Commands common to gp-mode and to gp-script-mode may behave differently
                    117: whether a gp process is being run or not. More information is available
                    118: if a gp process is being run.
                    119:
                    120: The buffer *PARI* is set in gp-mode and the following extra commands are
                    121: available:
                    122:
                    123: KEY      LISP-NAME             DESCRIPTION
                    124: ===      =========             ===========
                    125: RET      gp-send-input         Copy current expression to the end,
                    126:                                   and send to gp.
                    127: M-c      gp-copy-input         Copy current expression to the end.
                    128: M-RET    gp-C-j                Split the line.
                    129: C-j      gp-C-j                Split the line.
                    130: M-\ p    gp-set-prompt         Set the gp prompt.
                    131: M-\ t    gp-meta-t       \
                    132: M-\ d    gp-meta-d        |
                    133: M-\ r    gp-meta-r        |
                    134: M-\ w    gp-meta-w        |
                    135: M-\ x    gp-meta-x         \  Versions of the gp meta-commands, which
                    136: M-\ s    gp-meta-s         /  prompt for arguments in the mini-buffer
                    137: M-\ a    gp-meta-a        |   and display output in the help buffer.
                    138: M-\ b    gp-meta-b        |
                    139: M-\ m    gp-meta-m        |
                    140: M-\ k    gp-meta-k        |
                    141: M-\ q    gp-meta-q       /
                    142: M-\ \    gp-break-long-line    Break a long line at col. 100, inserting \.
                    143: M-p      gp-next-command       Step to the next command.
                    144: M-n      gp-previous-command   Step to the previous command.
                    145: C-n      next-line             Step to the next line.
                    146: C-p      previous-line         Step to the previous line.
                    147:          gp-toggle             Exchange behaviour of C-p/M-p and C-n/M-n.
                    148: C-kp-subtract
                    149:          gp-remove-last-output Erases last output.
                    150: M-kp-subtract
                    151:          gp-remove-last-action Erases last input and its output.
                    152:
                    153:
                    154: Within a gp-script set in gp-script-mode, the following extra commands
                    155: are available:
                    156:
                    157: KEY      LISP-NAME             DESCRIPTION
                    158: ===      =========             ===========
                    159: M-\ z    gp-run-in-region      Send the marked region to the gp process,
                    160:                                starting such a process if required.
                    161:          gp-make-completion-file
                    162:                                Allow use of the names of the functions
                    163:                                and of the global variables of this
                    164:                                program for completion.
                    165: M-x gp   gp-start-usual        Start a gp session with default parameters.
                    166: C-u M-x gp gp-start-with-parameters
                    167:                                Ask for parameters before starting a gp
                    168:                                session.
                    169: C-u M-o                        Quit editing a completion file.
                    170:
                    171: Note that most of these commands use the emacs meta key.
                    172: This may be marked `left' `right' `extended character'  `<>'
                    173: or various other markings. If your keyboard has not got a meta key. You
                    174: can use the escape key as a prefix.
                    175:
                    176: Thus M-\ corresponds to pressing meta and \ together, or pressing
                    177: ESC followed by \ .
                    178: ===========================================================================
                    179:
                    180: RET
                    181: ===
                    182: If point is after the last gp prompt,  pressing RET sends current gp
                    183: expression to the gp process. If point is at some previous expression, this
                    184: expression (which may be several lines long) is copied to the end of the
                    185: buffer and then executed. If the expression is incomplete, it is *not* sent
                    186: to gp, and a `virtual' newline is inserted like via C-j. Since emacs does
                    187: not produce a syntactical analysis of your input, the definition of a
                    188: complete expression is fairly simple-minded : parenthesis `(' `{' and `['
                    189: should be properly closed, the last character should not be "\" and not be
                    190: within a string. If none of these criteria applies, the input is declared
                    191: complete, whether you were in the middle of a comment or not...
                    192:
                    193: M-RET / C-j
                    194: ===========
                    195: Introduce a `virtual' newline, so that you can have a input of gp taking
                    196: several lines. The same behaviour is obtained if you type \ followed by RET.
                    197:
                    198: M-c
                    199: ===
                    200: M-c, acts like RET, except that the expression is not sent to the gp
                    201: process. It is just copied to the end, so that it may be edited, and then
                    202: RET pressed, to send the new expression to gp.
                    203:
                    204: TAB
                    205: ===
                    206: TAB Tries to complete the partly typed gp command in the *PARI* buffer.
                    207: Note that you can use C-i instead of TAB. If GP was compiled with the
                    208: readline library, it knows about all symbols meaningful tp GP, plus some
                    209: extra keywords (bnf, nf, ell, etc.)
                    210:
                    211: Otherwise, it originally `knows' about all the standart commands of GP.
                    212: User-defined commands will be known to the completion system if they are
                    213: given as arguments to M-?. Commands to teach the system large numbers of new
                    214: command names will be described in the part COMPLETION FILES below and later
                    215: on.
                    216:
                    217: M-?
                    218: ===
                    219: M-? prompts for the name of a gp command (which may include symbolic names
                    220: like +). It then finds the appropriate paragraphs of section 3 of the
                    221: manual, strips off some of the TeX commands, and displays the result in a
                    222: new window. If the command is not found in the manual, sends ?command to
                    223: gp, and displays the output in the help window. Thus M-? also works with
                    224: user-defined commands. You may use space and tab to complete the
                    225: command name, in the mini-buffer. M-? tries to guess which command you
                    226: may want help for. If this is incorrect, simply delete that command,
                    227: and type in the command required.
                    228:
                    229: M-\ p
                    230: =====
                    231: M-\ p prompts for a new string in the mini-buffer. The command
                    232:
                    233: default(prompt,"<new string>")
                    234:
                    235: is then sent to gp, so that gp will now prompt for input with <new string>.
                    236: The variable gp-prompt-pattern is also reset so that RET and M-RET know
                    237: that gp expressions now start with <new string>. Expressions typed to the
                    238: old prompt are still recognised.
                    239:
                    240:   Note that with this version, you can use a dynamic prompt (using %
                    241: constructs, which then go through strftime).
                    242:
                    243: M-\ c
                    244: =====
                    245: This shows a menu of subject headings taken from the manual, plus some
                    246: keywords that may lead to some interesting information. Pressing RET displays
                    247: the beginning of the chapter, or the list of the functions whose description
                    248: contains the keyword, as if the M-H command had been typed.
                    249:
                    250: M-\ \
                    251: =====
                    252: If the line is longer than 100, a \<newline> is inserted every 100
                    253: characters. This is necessary if the line is longer than 256 characters as gp
                    254: does not accept line longer than this. M-\ \ moves point to the end of the
                    255: current line.
                    256:
                    257: M-\
                    258: ===
                    259: The other commands on the M-\ prefix send the appropriate meta command to
                    260: gp. However they use the mini-buffer to read arguments (eg so that you can
                    261: use filename completion) and display any output in the *gp-help* buffer.
                    262:
                    263: C-kp-subtract/M-kp-subtract
                    264: ===========================
                    265: These commands are available only if you have a separate numerical keypad.
                    266: You should then press the Control key (respectively the Alt key) and the -
                    267: from this keypad.
                    268:
                    269: ===========================================================================
                    270:
                    271: HILIGHTING:
                    272: ===========
                    273:
                    274: If you're using X Windows on a color monitor, Emacs will use different
                    275: colors to display various parts when in gp-mode (when GP is running)
                    276: or in gp-script-mode (while editing a file with suffix .gp or after typing
                    277: M-x gp-script-mode). The colors chosen for hilighting can be modified and
                    278: customised through the menu-bar; They are then stored in a "pari-colors"
                    279: file. By default, this file is stored as "pari-colors.el" in the directory
                    280: where the help files are located (gp-gphelp-dir, chosen at Configure time).
                    281: If this directory is not writable (in most cases, it shouldn't be), the
                    282: filename defaults to ~/pari-colors.el. In the other direction, when pari.el
                    283: is loaded, emacs will look for "gp-gphelp-dir/pari-colors.el" if this
                    284: directory is writable and otherwise for "~/pari-colors.el".
                    285:
                    286: It is possible to override these default by setting the variable
                    287: 'pari-colors which can be set in 'pari-mode-hook (see below). Colors
                    288: will then be read from and written to this file.
                    289:
                    290: Troubles may occur with "}". A "}" followed by a newline indicates the
                    291: end of a function definition (starting with a "}"). Spaces ot tab-characters
                    292: are *not* allowed there. So if you use "}" in a string, simply don't
                    293: have it followed by a newline --- and pari.el won't get confused.
                    294:
                    295: NOTE: in order to set the colours, emacs has to be in charge from the
                    296: moment you send a command until GP outputs an answer. Thus it will appear
                    297: to hang if you input a command which takes a long time for GP to process.
                    298: You can hit C-g at any time, which will not affect GP (like C-c would),
                    299: but will let you back in control of emacs. The output of this specific
                    300: command will then not be highlighted, but you can rehilight the buffer
                    301: by C-l.
                    302:
                    303:   You can customize the setting through the menu-bar (easiest way) or by
                    304: modifying your .emacs, AFTER "pari"  has been loaded (if you use autoload
                    305: then set these variables in a pari-mode-hook):
                    306:
                    307:    to disable all highlighting.
                    308:      (setq gp-no-hilit t)
                    309:
                    310:    if you run emacs with a dark background (e.g. in reverse video mode)
                    311:      (setq hilit-background-mode 'dark)
                    312:
                    313:    The default colors can be quite painful to look at. In any case they
                    314:    are easily configurable using the function hilit-translate. Emacs knows
                    315:    about the following symbolic hilight groups:
                    316:
                    317:     in gp-mode (corresponding to what default(colors,...) would do):
                    318:       gp-error   gp-history   gp-prompt   gp-output
                    319:       gp-input   gp-timer     gp-help
                    320:
                    321:     in gp-script-mode:
                    322:       gp-control-statement   gp-default-keywords   gp-default-set
                    323:       gp-input-cmd           gp-string             gp-function-proto
                    324:       gp-function-args       gp-comment            gp-global-var
                    325:
                    326:     An actual face (font shape + color) is associated to all patterns belonging
                    327:     to a group using hilit-translate. For instance
                    328:
                    329:       (hilit-translate
                    330:          gp-string   'magenta3    ; all strings will be set in magenta3
                    331:          gp-comment  'italic-red  ; all comments in italic + red
                    332:          gp-timer    'hex-ffff60  ; timer output set in RGB color (ff ff 60)
                    333:          gp-prompt   'default     ; don't highlight the prompt
                    334:       )
                    335:     See the documentation of hilit-lookup-face-create for valid face names.
                    336:
                    337:     In practice, you could include the following code in your .emacs:
                    338:
                    339:       (setq pari-mode-hook
                    340:         (function (lambda ()
                    341:            ... ; as above for instance
                    342:           (if gp-can-hilit
                    343:             (progn
                    344:               (hilit-translate gp-prompt 'tomato4)
                    345:               (hilit-translate gp-timer  'default)
                    346:               (hilit-translate gp-string  'tomato4)
                    347:               (hilit-translate gp-comment 'default))))))
                    348:
                    349:   There is no need to separate gp-mode from gp-script-mode.
                    350:
                    351:
                    352: ===========================================================================
                    353:
                    354: COMPLETION / COMPLETION FILES:
                    355: ==============================
                    356:
                    357: See also the description of the TAB key above.
                    358:
                    359: Initially, emacs "knows" all the symbols can are listed by the command
                    360: gphelp -k "", i.e. essentially all the standard function/variable names.
                    361: If gp has been built with readline, it knows also some extra symbols.
                    362: In this case and while editing gp-scripts, emacs will try to start
                    363: a gp-session in the background and ask readline. Note that it is
                    364: compulsory for gphelp to be available and that the behaviour will
                    365: be better if a gp-process can be started.
                    366:
                    367: A "completion file", also denoted by "a file in gp-menu format", is a file
                    368: which contains the string "###" at the beginning of a line. Anything
                    369: before the first occurence of this string is ignored. Lines starting by
                    370: this string are considered as commented. Then each non commented line below
                    371: the first "###" contains a string which will be fed to the completion
                    372: system. For instance if a file containing:
                    373:
                    374: ### Function names:
                    375: my_function
                    376: facilitate
                    377:
                    378: is send to the completion system through the menu-bar item
                    379: [GP/Complete/Use Also File...], then the two strings "my_function" and
                    380: "facilitate" will be known for completion and the completions of "fa"
                    381: will be "factor" or "facilitate".
                    382:
                    383: Completion files relative to a gp-script "program-name" will be called
                    384: "program-name.cpl" and automatically loaded when editting "program-name".
                    385:
                    386: You can tell emacs to also use the function/global-variable names of your
                    387: script (program) through the menu-bar item [Gp Completion-File Make/Update].
                    388: To avoid the writing of too many files, it is *not* stored in a file
                    389: unless you ask to edit it.
                    390:
                    391: A file stored in the variable gp-additional-completion-file is loaded while
                    392: starting as an additional completion file. It can be set in a hook. Default
                    393: value is the empty string.
                    394: ===========================================================================
                    395:
                    396: CUSTOMIZATION:
                    397: ==============
                    398:
                    399: From version 2.31 onwards, some environment variables can be set via
                    400: the menu-bar provided you use a version of emacs which is at least 20.
                    401: Otherwise, you can use the classical way through a hook as explained
                    402: in the note number 3 below. Assuming you do have custom.el,
                    403: the item to be used is [Help Customize Specific-Group],
                    404: and the group to choose is gp. You can then modify the shown variables,
                    405: and save them for future sessions: they will be stored in your .emacs
                    406: file under the shape:
                    407:
                    408:   (custom-set-variables
                    409:     ; To select where the colors are stored:
                    410:     '(pari-colors "~/pari-colors.el")
                    411:     ; To select a file containing possible completions:
                    412:     '(gp-additional-completion-file "")
                    413:     ; To set parameters of gp:
                    414:     '(gp-stack-size 10000000)
                    415:     '(gp-prime-limit 500000)
                    416:     ; To ask gp to not/always ask for arguments:
                    417:     '(gp-prompt-for-args nil)
                    418:     ; To ask/remove tutorial help:
                    419:     '(gp-tutorial-requiredp t)
                    420:     ; To set/remove hilighting:
                    421:     '(gp-no-hilit nil)
                    422:     ; To set/remove the menu-bar item [GP/Colors]:
                    423:     '(gp-no-color-item nil)
                    424:     ; To set/remove both menu-bars:
                    425:     '(gp-no-menu-bar nil)
                    426:     ; To keep the PARI buffer when quitting:
                    427:     '(gp-keep-PARI-buffer-when-quitting t)
                    428:     ; To have mistakes displayed on a separate window:
                    429:     '(gp-no-separate-window-for-mistakes nil))
                    430:   (custom-set-faces)
                    431:
                    432: Within  the customization-window, you should save these values for them
                    433: to become valid. Note that the variables having something to do with the
                    434: menu-bar will affect only the next session since this menu-bar is
                    435: computed at the beginning of each session. The same applies to 'gp-no-hilit
                    436: since it is only used at the beginning of the session to set 'gp-can-hilit
                    437: which is in fact the relevant variable.
                    438:
                    439: ===========================================================================
                    440:
                    441: LISP EXPRESSIONS IN GP-SCRIPTS:
                    442: ===============================
                    443:
                    444: A new functionnality of version 2.21 is the possibility to introduce
                    445: elisp-commands inside a gp-script. Elisp commands can be inserted anywhere
                    446: and will be executed prior to sending the file to gp. The file should be
                    447: edited for emacs to take care of these commands. They are to be surrounded by
                    448: "/*@" and "*/", like in
                    449:
                    450: /*@
                    451: (setq gp-prompt-pattern (gp-make-gp-prompt-pattern "^NewOne: "))
                    452: */
                    453:
                    454: An additional cookie is the string "\\@" which, when located in a program at
                    455: the beginning of a line and followed by a newline is understood as
                    456: emacs-should-not-wait-for-output-of-the-program, which is convenient
                    457: while working with lengthy programs that give partial answers.
                    458: In fact, the effect of "\\@" can be obtained by writing
                    459:
                    460: /*@ (setq gp-should-wait-for-outpup nil) */
                    461:
                    462: This variable is automatically reset to t after the output.
                    463: Concerning this functionnality, a hook gp-input-filter-hook is run whenever
                    464: an input is sent to gp. It can be set in the .emacs and can be modified in
                    465: the file itself. For instance, if the file "with-syntax.el" contains the
                    466: function 'translate, we can use
                    467:
                    468: /*@
                    469: (load-file "with-syntax.el")
                    470: (setq gp-input-filter-hook (list 'translate))
                    471: */
                    472:
                    473: By "translation" we mean applying some transformations to a gp-script before
                    474: sending it to gp. There is a general file "pari-translator.el" which contains
                    475: functions handy for writing such a translator. An exemple is provided by the
                    476: file "with-syntax.el" which enables one to use the syntax "with(foo,to_do)"
                    477: in a gp-program. Details can be found in this file. It is possible to write
                    478: a file translating gp-syntax-old-version into gp-syntax-new-version. More
                    479: complicated and a project is to write a file translating simple MuPAD-syntax
                    480: into gp-syntax.
                    481:
                    482: ===========================================================================
                    483:
                    484: HANDLING OF MISTAKES:
                    485: =====================
                    486:
                    487: If you edit a program, execute it (or part of it) via the menu-bar,
                    488: and an error is found, then emacs will try to locate the typo in your
                    489: script. Note that this script should be in a visible window. Sometimes,
                    490: the place shown will not be the proper one and you can ask for the next
                    491: matching occurence by selecting the menu-item "Skip-to-error". Incidentally,
                    492: this function will also start the search even if the buffer is not visible,
                    493: in which case the search will start from the begining of the buffer and not
                    494: from point-location.
                    495:
                    496: In the *PARI* buffer, mistake will be displayed on a separate window,
                    497: so as not to crowd your session. However you can disable this behaviour
                    498: by setting the variable 'gp-no-separate-window-for-mistakes to t.
                    499: Exception to this is a \r command whose output will never go to a
                    500: separate window.
                    501:
                    502: Alternatively, you can delete last output through the key C-kp-subtract
                    503: (Control and the - from the numerical keypad), and all of last input and
                    504: out via M-kp-subtract.
                    505:
                    506: ===========================================================================
                    507: Notes
                    508: =====
                    509:
                    510: 1) You may edit previous expressions, and then type RET to send them to gp.
                    511:    However if you want the *PARI* buffer to contain a script of a valid gp
                    512:    session, you may prefer to use M-RET to copy the expression to the end
                    513:    of the buffer, before editing it.
                    514:
                    515: 2) M-\ c is supposed to be a version of the gp meta command \c, although
                    516:    it does not send \c to gp.
                    517:    M-\ p does not correspond to the gp meta command \p but rather to the
                    518:    command default(prompt,...). If this disturbs you it is easy enough to bind
                    519:    M-\ p to a command that inserts \p into the *PARI* buffer. The command
                    520:    gp-set-prompt can then be bound to any key sequence that you wish.
                    521:    All the other commands on the M-\ prefix do work by sending a gp meta
                    522:    command to the *PARI* buffer.
                    523:
                    524: 3) pari-mode-hook/gp-mode-hook/gp-script-mode-hook:
                    525:    Individual users can customise gp-mode without having to make copies of
                    526:    the file pari.el and most of this customization is automatically done
                    527:    (see the CUSTOMIZATION section above).
                    528:    For more specific purposes there are *three* hooks, namely gp-mode-hook,
                    529:    gp-script-mode-hook and an additional hook 'pari-mode-hook common to both
                    530:    modes. You should mostly use pari-mode-hook but can use also the two more
                    531:    specialised gp-mode-hook which will be run by the gp command and
                    532:    gp-script-mode-hook which will be run while starting a gp-script, both
                    533:    in addition to pari-mode-hook. Essentially the only example where
                    534:    gp-mode-hook *has to* be used rather than pari-mode-hook is when
                    535:    setting the prompt via gp-set-prompt (see end of this note and next one).
                    536:    The format is:
                    537:
                    538:        (setq pari-mode-hook
                    539:          (function (lambda ()
                    540:           ... commands to run when starting up gp ...
                    541:         )))
                    542:
                    543:    An example is:
                    544:
                    545:        (setq pari-mode-hook
                    546:          (function (lambda ()
                    547:            (define-key gp-map "\M-\\p" 'gp-meta-p)
                    548:            (define-key gp-map "\M-p" 'gp-set-prompt)
                    549:            (setq gp-stack-size 1000000)
                    550:            (setq gp-prime-limit 2000)
                    551:            (gp-completion-file my-file)
                    552:        )))
                    553:
                    554:   This:
                    555:         Binds a function which sends \p to gp (which would need to be defined
                    556:              somewhere else), to M-\ p.
                    557:         Binds gp-set-prompt to M-p.
                    558:         Defines the default stack size and prime limit as 10000 and 2000.
                    559:
                    560:         Let the completion system use all the commands listed in the
                    561:         file my-file.
                    562:
                    563:    In case, customization is not possible through the menu-bar, (see
                    564:    section CUSTOMIZATION), here is a generic way to set pari-mode-hook:
                    565:       (setq pari-mode-hook
                    566:        (function (lambda ()
                    567:               ; To select where the colors are stored:
                    568:               (setq pari-colors "~/")
                    569:               ; To select a file containing possible completions:
                    570:               (setq gp-additional-completion-file "")
                    571:               ; To ask/remove tutorial help:
                    572:               (setq gp-tutorial-requiredp t)
                    573:               ; To set/remove hilighting:
                    574:               (setq gp-no-hilit nil)
                    575:               ; To set/remove the menu-bar item [GP/Colors]:
                    576:               (setq gp-no-color-item nil)
                    577:               ; To set/remove both menu-bars:
                    578:               (setq gp-no-menu-bar nil)
                    579:               ; To set parameters of gp:
                    580:               (setq gp-stack-size 10000000)
                    581:               (setq gp-prime-limit 500000)
                    582:               ; To ask gp to not/always ask for arguments:
                    583:               (setq gp-prompt-for-args nil)
                    584:               ; To ensure a proper default for completion:
                    585:               (setq gp-complete-choice 'gp-complete)
                    586:               ; To keep the PARI buffer when quitting:
                    587:               (setq gp-keep-PARI-buffer-when-quitting t)
                    588:               ; To have mistakes displayed on a separate window:
                    589:               (setq gp-no-separate-window-for-mistakes nil)
                    590:               )))
                    591:
                    592:    A change in prompt, which has not gone to the .gprc (see below), *has to*
                    593:    use the gp-mode-hook. It reads
                    594:
                    595:    (setq gp-mode-hook
                    596:       (function (lambda ()
                    597:          ; Select a new prompt:
                    598:          ; (gp-set-prompt "...")
                    599:        )))
                    600:
                    601:    And for instance '...(get-set-prompt "(%R) gp > "))))' will set the
                    602:    prompt to "(%R) gp > " as soon as you enter gp.
                    603:
                    604: 4) Command line arguments.
                    605:    The gp executable file is specified in the variable gp-file-name. This
                    606:    is set in the file pari.el, but users can override this setting, either
                    607:    in their pari-mode-hook, or by using the C-u prefix to gp. In either case,
                    608:    the full path name need not be given if gp is in a directory specified
                    609:    in your PATH variable (or the equivalent in csh).
                    610:    The variables gp-stack-size, gp-buffer-size and gp-prime-limit should be
                    611:    set to strings specifying the arguments to gp. See the above example.
                    612:
                    613:
                    614:    If these variables are  set to "", then the appropriate flags
                    615:       "-s", "-b" or "-p" are *not* sent to gp.
                    616:    If RET is typed in response to any of the prompts produced by C-u M-x gp
                    617:       then the default value, ie., the value of gp-file-name, gp-stack-size,
                    618:       or gp-prime-limit, is assumed.
                    619:    If a space is sent to the prompt (ie SPC RET) then the appropriate argument
                    620:        is not  sent to gp, even if the default is non-empty.
                    621:
                    622:    People who often use different settings for these arguments, may like
                    623:    either to add the line
                    624:
                    625:    (setq gp-prompt-for-args t)
                    626:    to their gp-mode-hook, or to use the command (outside the gp-mode-hook)
                    627:    (custom-set-variables
                    628:       '(gp-prompt-for-args t))
                    629:    This makes M-x gp act like C-u M-x gp.
                    630:
                    631: 5) Prompt.
                    632:    Emacs needs to know at all time what your prompt looks like: it's stored
                    633:    at all times in gp-prompt-pattern. If you must change your prompt
                    634:    (e.g. with default(prompt,...)) without telling emacs,  emacs
                    635:    will try to understand what you mean, and else tell you it has not
                    636:    succeeded. What you *cannot* use is the command "default(prompt,fn())"
                    637:    where "fn" is a gp-function which evaluates to a string. Emacs
                    638:    will accept it though, but won't modify the prompt-pattern, so it
                    639:    may lead to errors.
                    640:
                    641:    If you intend to change your prompt in your .gprc and not in an
                    642:    emacs session, you have to modify the gp-prompt-pattern regular
                    643:    expression yourself (AFTER loading pari.el in your .emacs). For instance:
                    644:
                    645:    (setq gp-prompt-pattern
                    646:      (concat "^> [\C-j\t ]*\\|" gp-prompt-pattern))
                    647:
                    648:    caters for a 'prompt = "> "' in .gprc. If you use autoload, put this
                    649:    command in 'pari-mode-hook and *not* in 'gp-mode-hook (see the note 3
                    650:    for the way to proceed). Don't forget to anchor your prompt
                    651:    at the beginning of the line (the '^' at the beginning). And don't forget
                    652:    to concatenate the old pattern as well. A more complicated one is to deal
                    653:    with 'prompt = "(%R) gp > "':
                    654:
                    655:    (setq gp-prompt-pattern
                    656:     (concat "^([0-9][0-9]:[0-9][0-9]) gp > [\C-j\t ]*\\|" gp-prompt-pattern))
                    657:
                    658: 6) Emacs Version.
                    659:    pari.el till version 2.23 has been written for emacs 19.34. There is
                    660:    a small problem with emacs 20.3 and pari.el 2.24 onward takes care of
                    661:    that, while still being usable with emacs 19.34. However, if you use
                    662:    a version of emacs below 20.3, the installation of the menu-bar item
                    663:    may be quite slow (some 20s on fast machines), while it is instantaneous
                    664:    with emacs 20.3 or higher. There may be troubles with XEmacs as far as
                    665:    colors are concerned, nothing that I know of.
                    666: ===========================================================================
                    667:
                    668:   Modified: Olivier Ramare 4-September-1999 version 2.32.
                    669:   Modified: Olivier Ramare 23-June-1999 version 2.31.
                    670:   Modified: Olivier Ramare 15-Marsh-1999 version 2.28.
                    671:   Modified: Olivier Ramare 28-January-1999 version 2.24.
                    672:   Modified: Karim Belabas 13-January-1998 version 2.19.
                    673:   Modified from the original file pari.txt written by David Carlisle
                    674:
                    675:   4-September-1999 version 2.32 (This file refers to pari.el version 2.32)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>