-
Notifications
You must be signed in to change notification settings - Fork 1
/
pari-completion.el
631 lines (558 loc) · 24.2 KB
/
pari-completion.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
;; pari-completion.el -- completion functions.
;; Copyright (C) 1997-2009 The PARI group.
;; This file is part of the PARIEMACS package.
;; PARIEMACS is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation. It is distributed in the hope that it
;; will be useful, but WITHOUT ANY WARRANTY WHATSOEVER.
;; Check the License for details. You should have received a copy of
;; it, along with the package; see the file 'COPYING'. If not, write
;; to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;; To be used with pari.el version 3.00 or higher
;; pari-completion.el version 3.04
;; See README for more details.
(provide 'pari-completion)
;; pari.el will use the function 'gp-quit-cpl-edit.
;; Also extends pari-mode-hook to set some key-bindings.
;; pari-help.el will use 'gp-c-array.
;; Of pari.el, it uses:
;; variables:
;; gp-process, gp-prompt-pattern, gp-tutorial-requiredp
;; functions:
;; gp-restore-wind-conf, gp-background,
;; gp-store-wind-conf, gp-backward-wind-conf,
;; gp-window-manager
;; Of pari-fontification.el, it uses gp-find-global-var.
(require 'pari-messages)
;; Of pari-messages.el, it uses gp-messager.
(eval-when-compile
;(fset 'x-defined-colors nil)
;; for development:
;;(setq byte-compile-warnings (list 'free-args 'unresolved 'callargs 'redefine 'obsolete))
;; for users:
(setq byte-compile-warnings (list 'unresolved 'redefine 'obsolete))
)
(eval-and-compile
(unless (fboundp 'gp-messager)
(defun gp-messager (no) (print "Feature pari-messages is absent ..." "*Messages*")))
(unless (fboundp 'gp-window-manager)
(defun gp-window-manager (a b) (message "Main program pari.el is absent !!")))
(unless (fboundp 'gp-info-wind-conf)
(defun gp-info-wind-conf nil (message "Main program pari.el is absent !!")))
(unless (fboundp 'gp-store-wind-conf)
(defun gp-store-wind-conf nil (message "Main program pari.el is absent !!")))
(unless (fboundp 'gp-backward-wind-conf)
(defun gp-backward-wind-conf nil (message "Main program pari.el is absent !!")))
(unless (fboundp 'gp-restore-wind-conf)
(defun gp-restore-wind-conf nil (message "Main program pari.el is absent !!")))
(unless (fboundp 'gp-background)
(defun gp-background nil (message "Main program pari.el is absent !!")))
(unless (fboundp 'gp-find-global-var)
(defun gp-find-global-var (l) (print "Feature pari-fontification is absent ..." "*Messages*"))))
(defvar gp-process nil "Defined in pari.el")
(defcustom gp-readline-enabledp t
"t if readline is enabled. Emacs will try to set it properly
whenever a gp-session is started."
:type 'boolean :group 'gp-font-lock-and-completion)
;; (defcustom gp-additional-cpl-file ""
;; "Name (string) of a completion file used in supplement for completion.
;; This file should have the format of 'gp-menu files."
;; :type 'file :group 'gp-font-lock-and-completion)
(defconst gp-c-array (make-vector 800 0)
"obarray used for completing gp command names.")
;; pari-2.0.19-beta contains 514 function names.
;; We extend it by 286 for local ones.
(defvar gp-cpl-lists-list
'(gp-c-array)
"List of the lists/arrays to be used for completion on top of the
completion already delivered by readline if present and by the general
'gp-c-array which has to be the first element of this list.")
(defconst gp-function-proto-pstart "\\(^ *\\|{\\)\\([a-zA-Z][_a-zA-Z0-9]*\\)([^)]*) *=[^=]"
"Regexp matching the beginning of a function-definition")
(defvar gp-completion-input-start 0)
(defun gp-choose-complete nil
"Try to see whether readline is enabled or not
and select proper completion function. To be used
when the buffer *PARI* is selected."
(save-excursion
(goto-char (point-min))
(if (re-search-forward "readline .*\\(dis\\|en\\)abled" nil t)
(progn
(forward-char -6)
(setq gp-readline-enabledp (looking-at "n")))
;; Else use default:
(message (gp-messager 1)))))
(defun gp-proper-name (filename)
"We replace the dots in filename by -."
(mapconcat
(lambda (achar) (char-to-string (if (= achar ?.) ?- achar)))
(string-to-list filename) ""))
(defun name-extension (filename)
"Return the extension suffix of filename, if any"
(if (> (length filename) (length (file-name-sans-extension filename)))
(substring filename (1+ (length (file-name-sans-extension filename))))
""))
;;-------------------------
;; GP COMPLETION FUNCTIONS
;;-------------------------
(defun gp-mouse-2 (event)
"A kind of hook for 'mouse-choose-completion."
(interactive "e")
;; 'mouse-choose-completion --> 'choose-completion since emacs 23 (24 ?)
(funcall 'choose-completion event)
;; 'mouse-choose-completion comes from the standard file "mouse.el".
(gp-restore-wind-conf) (forward-word 1))
(defun gp-clear-list (lst)
"Remove the lists `(\"\")' from LST."
(let ((newlist nil))
(mapcar (lambda (liststring)
(or (string= (car liststring) "")
(setq newlist (cons liststring newlist))))
lst)
newlist))
(defun gp-clear-list2 (lst)
"Remove the empty words from LST."
(let ((newlist nil))
(mapcar (lambda (astring)
(or (string= astring "")
(setq newlist (cons astring newlist))))
lst)
newlist))
(defun gp-make-cpl-list (abuffer)
"Take a buffer in the format of pari.menu, and create the list
whose name is the concatenation of \"gp-cpl-\" and the buffer-name
and which contains all the non-commented lines of the buffer.
The file must have at least one comment line, starting with #, All
lines before the first comment line are IGNORED. Finally add this list
name to 'gp-cpl-lists-list."
(save-excursion
(let ((lst nil) lst-aux astring)
(set-buffer abuffer)
(save-restriction
(widen)
(goto-char (point-min))
(re-search-forward "#")
(while (not (eobp))
(forward-line 1)
(or (looking-at "#")
(add-to-list 'lst
(list
(buffer-substring-no-properties (point)
(line-end-position))))))
(setq astring
(concat "gp-cpl-"
(gp-proper-name (buffer-name))))
(set (intern astring) (gp-clear-list lst))
(setq lst-aux (list (intern astring)))
(setcdr lst-aux (cdr gp-cpl-lists-list))
(setcdr gp-cpl-lists-list lst-aux)
(kill-buffer abuffer)
))))
;; (defun gp-cpl-file (afile)
;; "Same as `gp-make-cpl-list' except that we start with a file."
;; (interactive "fFile of command names: ")
;; (gp-make-cpl-list (find-file-noselect afile)))
(defun gp-add-symbol (name)
"Add a name to the obarray, if it is not already there."
(intern name gp-c-array))
(defun gp-find-word-to-complete nil
(save-excursion
(let ((pt (point)))
(if (char-equal (preceding-char) ?() (forward-char -1))
(if (not (bolp))
(progn
(forward-char -1)
(if (looking-at "\\w")
(progn (forward-char 1) (forward-word -1))
(forward-char 1))))
;; In case it is a command-word:
(if (= (preceding-char) ?\\) (forward-char -1))
(if (= (point) pt) " "
(buffer-substring-no-properties (point) pt)))))
(defun gp-string-to-list (astring)
"ASTRING is a succession of gp-words separated by spaces or newlines.
The answer is the list of these words."
(let ((lst nil) (beg 0) (end 1))
(while (<= end (length astring))
(cond ((member (aref astring (1- end)) '(?\ ?\n))
(if (not (= beg (1- end)))
(setq lst (nconc lst
(list (substring astring beg (1- end))))))
(setq beg end end (1+ end)))
(t (setq end (1+ end)))))
;; taking care of the last one:
(if (not (= beg (1- end)))
(setq lst (nconc lst (list (substring astring beg (1- end))))))
lst))
(defun gp-sort-and-minimise (list1 list2)
"Take two lists of strings and build the list of all their
elements with no repetition and sorted out."
(let ((lst (sort (nconc list1
(mapcar
(lambda (elt) (if (member elt list1) "" elt))
list2))
'string-lessp)))
(if (string= (car lst) "") (cdr lst) lst)))
(defun gp-make-standard-word (word)
"If WORD has a final \"()\", remove it."
;; When asking for completion and there is a unique completion, readline
;; adds sometimes `()' at the end of the completion.
(if (and (> (length word) 1)
(string= (substring word (- (length word) 2)) "()"))
(substring word 0 (- (length word) 2))
word))
(defsubst standard-string= (word1 word2)
(string= (gp-make-standard-word word1)
(gp-make-standard-word word2)))
(defsubst gp-standard-lst (word comp)
(cond ((and (string= (car comp) "") (null (nth 1 comp)))
(list ""))
((null (nth 1 comp))
(list (concat word (car comp))))
(t (nth 1 comp))))
(defun gp-merge-cpls (word comp1 comp2)
(let* ((lst1 (gp-standard-lst word comp1))
(lst2 (gp-standard-lst word comp2))
(a-local-cpl-list (mapcar 'list (gp-sort-and-minimise lst1 lst2))))
(gp-ask-cpl-via-list word 'a-local-cpl-list)))
(defun gp-ask-cpl-via-list (word lst)
"Careful! LST is a symbol whose value is a list of completion type,
ie a list of lists whose cars are strings used for completion."
;; LST can be an array also.
(setq lst (symbol-value lst))
(let ((comp (try-completion word lst))
to-insert fun-list)
(cond ((equal comp nil) ; No completion.
(list "" nil))
((equal comp t) ; Already complete.
(list "" nil))
((> (length comp) (length word)) ; Some completion with a kernel.
(setq to-insert (substring comp (length word)))
(setq fun-list
(all-completions comp lst))
(if (< (length fun-list) 2)
(list to-insert nil) ; Unique completion.
(list to-insert fun-list)))
(t (setq fun-list
(all-completions comp lst))
(if (< (length fun-list) 2)
(list "" nil) ; Unique completion.
(list "" fun-list))))))
(defun gp-ask-cpl-via-readline (context)
(let ((to-insert nil) (fun-list ""))
(if (gp-background)
(save-excursion
(set-buffer "*PARI*")
(goto-char (point-max))
(set-marker (process-mark gp-process) (point))
(let ((temp (point)) (last nil))
;; ask for all completions (readline command)
(process-send-string gp-process (concat context "\t" ))
(let ((notdone t))
(while notdone
(accept-process-output gp-process)
(let ((p (point)))
(if (or
(not (and (processp gp-process)
(eq 'run (process-status gp-process))))
(search-backward "@E_N_D" (1+ temp) t))
;; If gp is not running, or @E_N_D has appeared, stop.
(progn
(message (gp-messager 6))
(setq notdone nil last (point)))
;; Else wait a bit longer.
(message (gp-messager 15)) (goto-char p)))))
;; Get end of completed-part:
(search-backward "@" nil t)
(setq to-insert (buffer-substring-no-properties temp (point)))
(forward-char 1) ;; In order to skip the "@".
;; Possible further completions:
(if (< (point) last)
(setq fun-list (buffer-substring-no-properties (point) (1- last))))
(delete-region temp (point-max))
;; clear line in the gp-process:
(process-send-string gp-process "\C-A\C-K"))))
(list to-insert (gp-string-to-list fun-list))))
(defun gp-general-complete (completion-function word)
"Answer a list whose car is an extension of WORD, and whose cdr
is a list of list of possible matching words."
(let ((ans (funcall completion-function word)))
;; 'gp-find-word-to-complete puts the point at
;; the end of the word to complete.
;; Insert the beginning of the completion
;; BEFORE any window change :
(if (not (string= (car ans) ""))
(progn
(insert (car ans))
;; In case of a direct completion via readline:
(if (char-equal (preceding-char) ?)) (forward-char -1))))
(if (equal (nth 1 ans) nil)
;; at most one match:
(if (and (get-buffer "*Completions*")
(get-buffer-window "*Completions*"))
;; Occurs whenever an earlier completion has
;; been asked for.
(progn
(gp-restore-wind-conf)
(forward-word 1)
;; In case of a completion via readline:
(if (and (char-after (point))
(char-equal (char-after (point)) ?()) (forward-char 1))
(if (char-equal (preceding-char) ?)) (forward-char -1))))
;; more than two matches:
(if (string= (car ans) "")
;; We do not display anything if a partial completion was possible:
(progn
(if (not (and (get-buffer "*Completions*")
(get-buffer-window "*Completions*")))
;; No use storing wind-conf if some completion is in
;; progress.
(gp-store-wind-conf))
(with-output-to-temp-buffer "*Completions*"
(display-completion-list (nth 1 ans))))))))
(defun gp-ask-cpl-via-readline-and-emacs (word)
(interactive)
(let ((lst
(if (or (and gp-readline-enabledp (string= word ""))
(and gp-readline-enabledp gp-process
(equal (process-buffer gp-process) (current-buffer))))
;; Do not use general completion (let readline work !):
'("" nil)
;; Ask for general completion:
(gp-ask-cpl-via-list
word (car gp-cpl-lists-list)))))
(mapcar
(lambda (a-cpl-list)
(setq lst
(gp-merge-cpls
word
(gp-ask-cpl-via-list word a-cpl-list)
lst)))
(cdr gp-cpl-lists-list))
(cond ((and gp-readline-enabledp gp-process
(equal (process-buffer gp-process) (current-buffer)))
(save-excursion
(if (re-search-backward gp-prompt-pattern nil t)
(setq gp-completion-input-start (match-end 0)) ;; end of prompt
(setq gp-completion-input-start (point-min))))
(gp-merge-cpls
word lst
(gp-ask-cpl-via-readline
(buffer-substring-no-properties gp-completion-input-start (point)))))
(gp-readline-enabledp
(gp-merge-cpls
word lst
(gp-ask-cpl-via-readline
(buffer-substring-no-properties (line-beginning-position) (point)))))
(t lst))))
(defun gp-complete nil
(interactive)
(gp-general-complete 'gp-ask-cpl-via-readline-and-emacs
(gp-find-word-to-complete)))
;;------------------
;; COMPLETION FILES !!!! OBSOLETE!!!!
;;------------------
;A "completion file", also denoted by "a file in gp-menu format", is a file
;which contains the string "###" at the beginning of a line. Anything
;before the first occurence of this string is ignored. Lines starting by
;this string are considered as commented. Then each non commented line below
;the first "###" contains a string which will be fed to the completion
;system. For instance if a file containing:
;### Function names:
;my_function
;facilitate
;; (defsubst gp-cpl-stamp (my-cpl-file)
;; "Put a completion-file-stamp on a buffer."
;; ;; Do not convert that in any other langage ! See gp-actualise-stamp.
;; (insert (format "\nCompletion File Name: %s\n\n" my-cpl-file))
;; (insert
;; "----------------------------------------------------------------\n"
;; " Created: " (current-time-string) "\n"
;; " By: " (user-full-name) "\n\n"
;; " Last Modification: " (current-time-string) "\n"
;; "----------------------------------------------------------------\n"
;; "\n### Function Names : (one per line)\n"))
;; (defsubst gp-actualise-stamp nil
;; "Actualise the completion-file-stamp of a buffer."
;; (goto-char (point-min))
;; (if (re-search-forward "Last Modification: " nil t)
;; ;; We have found this string and update what's behind:
;; (let ((kill-whole-line nil)) ;; local value of global parameter.
;; (backward-char 1) ;;so that we are sure something is on this line.
;; (kill-line)
;; (insert " " (current-time-string)))))
;; Edition of completion file. We follow a loose way of working
;; in case the user edits other buffers in between.
;; (defun gp-edit-cpl-file (my-cpl-file)
;; "Edit my-cpl-file."
;; (interactive
;; (list (gp-read-input (gp-messager 33)
;; (concat (gp-possible-file-name) ".cpl") "" t)))
;; (gp-store-wind-conf)
;; (or (file-exists-p (expand-file-name my-cpl-file))
;; ;; If the file does not exist, create it (the list may exists though):
;; (gp-prepare-cpl-file t))
;; (switch-to-buffer-other-window
;; (find-file-noselect my-cpl-file))
;; (goto-char (point-min))
;; (if (eobp) (gp-cpl-stamp my-cpl-file)
;; (re-search-forward "#.*$" nil t)
;; (goto-char (match-end 0))
;; (if (eobp) (insert "\n") (forward-char 1)))
;; (message (gp-messager 16)))
;; (defsubst gp-cpl-bufferp (abuffer)
;; (string= (name-extension abuffer) "cpl"))
(defun gp-quit-cpl-edit nil
(interactive)
(if (gp-cpl-bufferp (buffer-name))
(progn
;; After entering 'gp-edit-cpl-file,
;; the user may have edited another completion file...
;; We don't bother since nothing bad will happen. The
;; behaviour of emacs may simply daze the user.
(gp-actualise-stamp)
(save-buffer 0) ;; No backup file.
(gp-backward-wind-conf)
)))
;; (defsubst gp-make-cpl-help (file)
;; (if gp-tutorial-requiredp
;; (let ((wind (selected-window)))
;; (gp-window-manager "*gp-help*" 'gp-beginning-temp)
;; (insert (format (gp-messager 30) file file file file))
;; (fill-region (point-min) (point-max) 'left)
;; (select-window wind))))
;; (defun gp-show-help (astring)
;; (gp-window-manager "*gp-help*" 'gp-beginning-temp)
;; (insert astring)
;; (setq fill-column (1- (window-width (get-buffer-window "*gp-help*"))))
;; (fill-individual-paragraphs (point-min) (point-max) 'left)
;; ;; Remove help window :
;; (gp-window-manager "*gp-help*" 'gp-remove-help-old-config)
;; (gp-restore-wind-conf))
;; (defun gp-cpl-file-info nil
;; (interactive)
;; (gp-show-help (gp-messager 29)))
;; (defmacro gp-cpl-file-has (astring)
;; "t if the edited completion-file has the string ASTRING
;; at a beginning of line followed by \n or a space or a #.
;; Also t when ASTRING is the empty string."
;; (`
;; (if (string= (, astring) "") t
;; (save-excursion
;; (goto-char (point-min))
;; (re-search-forward "#") ; There exists such a line.
;; (end-of-line)
;; (if (eobp)
;; nil ;; Return value is nil.
;; (forward-line 1)
;; (re-search-forward
;; (concat "^" (regexp-quote (, astring)) "[\n| |#]") nil t))))))
;; (defun gp-prepare-cpl-file (option)
;; " Write in the file 'buffername.cpl' which has the format of a completion
;; file (i.e. a gp-menu file) the names of the functions and of the global
;; variables of the visited file. OPTION is t means save the buffer on file,
;; nil means don't do that if the file wasn't existing already."
;; (let* ((file (buffer-name)) (my-cpl-file (concat file ".cpl")))
;; (or option (gp-make-cpl-help file))
;; ;; Prepare buffer:
;; (save-excursion
;; (if (or option
;; (file-exists-p (expand-file-name my-cpl-file)))
;; (set-buffer (find-file-noselect my-cpl-file))
;; (set-buffer (get-buffer-create my-cpl-file)))
;; (if (file-exists-p (expand-file-name my-cpl-file))
;; (progn
;; ;; Assume it has the format of a completion-file:
;; (re-search-forward "#" nil t)
;; (end-of-line)
;; (if (eobp) (insert "\n")
;; (forward-line 1) (beginning-of-line)
;; (kill-region (point) (point-max))))
;; (if option (gp-cpl-stamp my-cpl-file)
;; (insert "\n### Function Names : (one per line)\n")))
;; ;; Add function names:
;; (set-buffer file)
;; (goto-char (point-min))
;; (let ((thelist nil))
;; (while (re-search-forward gp-function-proto-pstart nil t)
;; (add-to-list 'thelist (match-string 2)))
;; (setq thelist (sort thelist (function string-lessp))) ; We order things.
;; (set-buffer my-cpl-file)
;; (mapcar (lambda (fn) (insert fn "\n")) (gp-clear-list2 thelist)))
;; ;; Prepare buffer for names of global variables:
;; (insert (gp-messager 25) "\n")
;; ;; Add global-variable-names:
;; (when (fboundp 'gp-find-global-var)
;; (set-buffer file)
;; (goto-char (point-min))
;; (let (theplace (thelist nil))
;; (while (setq theplace (gp-find-global-var nil))
;; (add-to-list 'thelist
;; (buffer-substring-no-properties (car theplace) (cdr theplace))))
;; (setq thelist (sort thelist (function string-lessp))) ; We order things.
;; (set-buffer my-cpl-file)
;; (mapcar (lambda (fn) (insert fn "\n")) (gp-clear-list2 thelist))))
;; (if (or option (file-exists-p my-cpl-file))
;; (progn
;; ;; Prepare buffer for closing, no backup-file:
;; (gp-actualise-stamp)
;; (save-buffer 0)))
;; ;; Add it to the possible completions:
;; (gp-make-cpl-list (buffer-name)))
;; ;; Remove help window
;; (if (and (not option) gp-tutorial-requiredp)
;; (progn
;; (gp-window-manager "*gp-help*" 'gp-remove-help-old-config)
;; (gp-restore-wind-conf))
;; )))
;; (defun gp-make-cpl-file nil
;; (interactive)
;; (gp-prepare-cpl-file nil))
;; (defsubst gp-cpl-file-menu nil ""
;; (nconc
;; (list
;; (vector (gp-messager 65) 'gp-cpl-file ':active t ':key-sequence nil)
;; (vector (gp-messager 66) 'gp-edit-cpl-file
;; ':active t ':key-sequence nil))
;; (if (eq major-mode 'gp-script-mode)
;; (list (vector (gp-messager 67) 'gp-make-cpl-file
;; ':active t ':key-sequence nil)
;; ["Info" gp-cpl-file-info :active t :key-sequence nil
;; :included gp-tutorial-requiredp])
;; nil)))
(add-hook 'pari-mode-hook
'(lambda nil
(if (file-really-exists-p (concat (buffer-name) ".cpl"))
;; The local completion for this file. OBSOLETE!!!!
(gp-cpl-file (concat (buffer-name) ".cpl")))
;; (if (file-really-exists-p gp-additional-cpl-file)
;; ;; Add this file to the usual completion array.
;; (gp-cpl-file gp-additional-cpl-file))
(define-key gp-map "\t" (function gp-complete))
(define-key gp-map "\M-i" (function gp-complete))
(define-key gp-map [(control tab)] (function gp-complete)) ;; C-i in fact !!!
(define-key gp-script-map "\M-i" (function gp-complete))))
(add-hook 'gp-mode-hook
'(lambda nil (gp-choose-complete)))
(add-hook 'pari-menu-bar-update-hook
'(lambda nil
(when (and gp-menu-barp
(or (and (eq major-mode 'gp-mode)
(= gp-menu-map-level 1))
(and (eq major-mode 'gp-script-mode)
(= gp-script-menu-map-level 1))))
;(easy-menu-change '("GP-script") (gp-messager 64) (gp-cpl-file-menu) (gp-messager 71))
(when (eq major-mode 'gp-script-mode)
(easy-menu-add-item GP-script-menu-map nil
(vector (gp-messager 72) 'gp-complete t) (gp-messager 73))
(setq gp-script-menu-map-level 2)
(message "Menu bar item GP-script loaded till level 2."))
(when (eq major-mode 'gp-mode)
(easy-menu-add-item GP-menu-map nil
(vector (gp-messager 72) 'gp-complete t) (gp-messager 73))
(setq gp-menu-map-level 2)
(message "Menu bar item GP loaded till level 2.")))))
;;Remove messages 64 71 65 66 67
;;gp-cpl-file-menu gp-cpl-file gp-edit-cpl-file gp-cpl-file-info
;; pari-completion.el ends here ---------------