1 |
;;; idlw-shell.el --- run IDL or WAVE as an inferior process of Emacs |
;; idlw-shell.el --- run IDL as an inferior process of Emacs. |
2 |
;; Copyright (c) 1999, 2000 Free Software Foundation |
;; Copyright (c) 1999, 2000, 2001 Free Software Foundation |
3 |
|
|
4 |
;; Author: Chris Chase <chase@att.com> |
;; Author: Carsten Dominik <dominik@astro.uva.nl> |
5 |
;; Maintainer: John-David Smith <jdsmith@astro.cornell.edu> |
;; Chris Chase <chase@att.com> |
6 |
;; Version: 4.7 |
;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu> |
7 |
|
;; Version: 4.14 |
8 |
;; Date: $Date$ |
;; Date: $Date$ |
9 |
;; Keywords: processes |
;; Keywords: processes |
10 |
|
|
26 |
;; Boston, MA 02111-1307, USA. |
;; Boston, MA 02111-1307, USA. |
27 |
|
|
28 |
;;; Commentary: |
;;; Commentary: |
29 |
|
;; |
30 |
;; This mode is for IDL version 4 or later. It should work on Emacs |
;; This mode is for IDL version 5 or later. It should work on |
31 |
;; or XEmacs version 19 or later. |
;; Emacs>20.3 or XEmacs>20.4. |
32 |
|
;; |
33 |
;; Runs IDL as an inferior process of Emacs, much like the emacs |
;; Runs IDL as an inferior process of Emacs, much like the emacs |
34 |
;; `shell' or `telnet' commands. Provides command history and |
;; `shell' or `telnet' commands. Provides command history and |
35 |
;; searching. Provides debugging commands available in buffers |
;; searching. Provides debugging commands available in buffers |
38 |
;; visual line pointer for current execution line, etc. |
;; visual line pointer for current execution line, etc. |
39 |
;; |
;; |
40 |
;; Documentation should be available online with `M-x idlwave-info'. |
;; Documentation should be available online with `M-x idlwave-info'. |
41 |
|
;; |
42 |
|
;; New versions of IDLWAVE, documentation, and more information |
43 |
|
;; available from: |
44 |
|
;; http://idlwave.org |
45 |
|
;; |
46 |
;; INSTALLATION: |
;; INSTALLATION: |
47 |
;; ============= |
;; ============= |
48 |
;; |
;; |
59 |
;; The newest version of this file can be found on the maintainers |
;; The newest version of this file can be found on the maintainers |
60 |
;; web site. |
;; web site. |
61 |
;; |
;; |
62 |
;; http://www.strw.leidenuniv.el/~dominik/Tools/idlwave |
;; http://idlwave.org |
63 |
;; |
;; |
64 |
;; DOCUMENTATION |
;; DOCUMENTATION |
65 |
;; ============= |
;; ============= |
93 |
;; |
;; |
94 |
;;-------------------------------------------------------------------------- |
;;-------------------------------------------------------------------------- |
95 |
;; |
;; |
|
;; |
|
96 |
|
|
97 |
;;; Code: |
;;; Code: |
98 |
|
|
103 |
|
|
104 |
(defvar idlwave-shell-have-new-custom nil) |
(defvar idlwave-shell-have-new-custom nil) |
105 |
(eval-and-compile |
(eval-and-compile |
106 |
;; Kludge to allow `defcustom' for Emacs 19. |
;; Kludge to allow `defcustom' for Emacs 19. |
107 |
(condition-case () (require 'custom) (error nil)) |
(condition-case () (require 'custom) (error nil)) |
108 |
(if (and (featurep 'custom) |
(if (and (featurep 'custom) |
109 |
(fboundp 'custom-declare-variable) |
(fboundp 'custom-declare-variable) |
110 |
(fboundp 'defface)) |
(fboundp 'defface)) |
111 |
;; We've got what we needed |
;; We've got what we needed |
112 |
(setq idlwave-shell-have-new-custom t) |
(setq idlwave-shell-have-new-custom t) |
113 |
;; We have the old or no custom-library, hack around it! |
;; We have the old or no custom-library, hack around it! |
114 |
(defmacro defgroup (&rest args) nil) |
(defmacro defgroup (&rest args) nil) |
115 |
(defmacro defcustom (var value doc &rest args) |
(defmacro defcustom (var value doc &rest args) |
116 |
`(defvar ,var ,value ,doc)))) |
`(defvar ,var ,value ,doc)))) |
117 |
|
|
118 |
;;; Customizations: idlwave-shell group |
;;; Customizations: idlwave-shell group |
119 |
|
|
145 |
"Initial commands, separated by newlines, to send to IDL. |
"Initial commands, separated by newlines, to send to IDL. |
146 |
This string is sent to the IDL process by `idlwave-shell-mode' which is |
This string is sent to the IDL process by `idlwave-shell-mode' which is |
147 |
invoked by `idlwave-shell'." |
invoked by `idlwave-shell'." |
148 |
:group 'idlwave-shell-initial-commands |
:group 'idlwave-shell-general-setup |
149 |
:type 'string) |
:type 'string) |
150 |
|
|
151 |
|
(defcustom idlwave-shell-save-command-history t |
152 |
|
"Non-nil means preserve command history between sessions. |
153 |
|
The file `idlwave-shell-command-history-file' is used to save and restore |
154 |
|
the history." |
155 |
|
:group 'idlwave-shell-general-setup |
156 |
|
:type 'boolean) |
157 |
|
|
158 |
|
(defcustom idlwave-shell-command-history-file "~/.idlwhist" |
159 |
|
"The file in which the command history of the idlwave shell is saved. |
160 |
|
In order to change the size of the history, see the variable |
161 |
|
`comint-input-ring-size'. |
162 |
|
The history is only saved if the variable `idlwave-shell-save-command-history' |
163 |
|
is non-nil." |
164 |
|
:group 'idlwave-shell-general-setup |
165 |
|
:type 'file) |
166 |
|
|
167 |
(defcustom idlwave-shell-use-dedicated-frame nil |
(defcustom idlwave-shell-use-dedicated-frame nil |
168 |
"*Non-nil means, IDLWAVE should use a special frame to display shell buffer." |
"*Non-nil means, IDLWAVE should use a special frame to display shell buffer." |
169 |
:group 'idlwave-shell-general-setup |
:group 'idlwave-shell-general-setup |
178 |
:type '(repeat |
:type '(repeat |
179 |
(cons symbol sexp))) |
(cons symbol sexp))) |
180 |
|
|
181 |
|
(defcustom idlwave-shell-raise-frame t |
182 |
|
"*Non-nil means, `idlwave-shell' raises the frame showing the shell window." |
183 |
|
:group 'idlwave-shell-general-setup |
184 |
|
:type 'boolean) |
185 |
|
|
186 |
(defcustom idlwave-shell-arrows-do-history t |
(defcustom idlwave-shell-arrows-do-history t |
187 |
"*Non-nil means UP and DOWN arrows move through command history. |
"*Non-nil means UP and DOWN arrows move through command history. |
188 |
This variable can have 3 values: |
This variable can have 3 values: |
197 |
(const :tag "everywhere" t) |
(const :tag "everywhere" t) |
198 |
(const :tag "in command line only" cmdline))) |
(const :tag "in command line only" cmdline))) |
199 |
|
|
200 |
|
;; FIXME: add comint-input-ring-size? |
201 |
|
(defcustom idlwave-shell-comint-settings |
202 |
|
'((comint-scroll-to-bottom-on-input . t) |
203 |
|
(comint-scroll-to-bottom-on-output . nil) |
204 |
|
(comint-scroll-show-maximum-output . t) |
205 |
|
) |
206 |
|
"Alist of special settings for the comint variables in the IDLWAVE Shell. |
207 |
|
Each entry is a cons cell with the name of a variable and a value. |
208 |
|
The function `idlwave-shell-mode' will make local variables out of each entry. |
209 |
|
Changes to this variable will only be active when the shell buffer is |
210 |
|
newly created." |
211 |
|
:group 'idlwave-shell-general-setup |
212 |
|
:type '(repeat |
213 |
|
(cons variable sexp))) |
214 |
|
|
215 |
(defcustom idlwave-shell-use-toolbar t |
(defcustom idlwave-shell-use-toolbar t |
216 |
"*Non-nil means, use the debugging toolbar in all IDL related buffers. |
"*Non-nil means, use the debugging toolbar in all IDL related buffers. |
217 |
Starting the shell will then add the toolbar to all idlwave-mode buffers. |
Starting the shell will then add the toolbar to all idlwave-mode buffers. |
225 |
(defcustom idlwave-shell-temp-pro-prefix "/tmp/idltemp" |
(defcustom idlwave-shell-temp-pro-prefix "/tmp/idltemp" |
226 |
"*The prefix for temporary IDL files used when compiling regions. |
"*The prefix for temporary IDL files used when compiling regions. |
227 |
It should be an absolute pathname. |
It should be an absolute pathname. |
228 |
The full temporary file name is obtained by to using `make-temp-name' |
The full temporary file name is obtained by using `make-temp-file' |
229 |
so that the name will be unique among multiple Emacs processes." |
so that the name will be unique among multiple Emacs processes." |
230 |
:group 'idlwave-shell-general-setup |
:group 'idlwave-shell-general-setup |
231 |
:type 'string) |
:type 'string) |
280 |
:group 'idlwave-shell-general-setup |
:group 'idlwave-shell-general-setup |
281 |
:type 'hook) |
:type 'hook) |
282 |
|
|
283 |
(defcustom idlwave-shell-print-expression-function nil |
(defvar idlwave-shell-print-expression-function nil |
284 |
"When non-nil, a function to handle display of evaluated expressions. |
"*OBSOLETE VARIABLE, is no longer used.") |
|
This can be used to arrange for displaying the value of an expression |
|
|
in (e.g.) a special frame. The function must accept one argument: |
|
|
the expression which was evaluated. The output from IDL will be |
|
|
available in the variable `idlwave-shell-command-output'." |
|
|
:group 'idlwave-shell-highlighting-and-faces |
|
|
:type 'symbol) |
|
285 |
|
|
286 |
|
(defcustom idlwave-shell-examine-alist |
287 |
|
'(("Print" . "print,___") |
288 |
|
("Help" . "help,___") |
289 |
|
("Structure Help" . "help,___,/STRUCTURE") |
290 |
|
("Dimensions" . "print,size(___,/DIMENSIONS)") |
291 |
|
("Type" . "print,size(___,/TNAME)") |
292 |
|
("N_Elements" . "print,n_elements(___)") |
293 |
|
("All Size Info" . "help,(__IWsz__=size(___,/STRUCTURE)),/STRUCTURE & print,__IWsz__.DIMENSIONS") |
294 |
|
("Ptr Valid" . "print,ptr_valid(___)") |
295 |
|
("Widget Valid" . "print,widget_info(___,/VALID)") |
296 |
|
("Widget Geometry" . "help,widget_info(___,/GEOMETRY)")) |
297 |
|
"Alist of special examine commands for popup selection. |
298 |
|
The keys are used in the selection popup created by |
299 |
|
`idlwave-shell-examine-select', and the corresponding value is sent as |
300 |
|
a command to the shell, with special sequence `___' replaced by the |
301 |
|
expression being examined." |
302 |
|
:group 'idlwave-shell-general-setup |
303 |
|
:type '(repeat |
304 |
|
(cons |
305 |
|
(string :tag "Label ") |
306 |
|
(string :tag "Command")))) |
307 |
|
|
308 |
|
(defcustom idlwave-shell-separate-examine-output t |
309 |
|
"*Non-nil mean, put output of examine commands in their own buffer." |
310 |
|
:group 'idlwave-shell-general-setup |
311 |
|
:type 'boolean) |
312 |
|
|
313 |
(defcustom idlwave-shell-use-input-mode-magic nil |
(defcustom idlwave-shell-use-input-mode-magic nil |
314 |
"*Non-nil means, IDLWAVE should check for input mode spells in output. |
"*Non-nil means, IDLWAVE should check for input mode spells in output. |
315 |
The spells are strings printed by your IDL program and matched |
The spells are strings printed by your IDL program and matched |
407 |
The overlay-arrow has the disadvantage to hide the first chars of a line. |
The overlay-arrow has the disadvantage to hide the first chars of a line. |
408 |
Since many people do not have the main block of IDL programs indented, |
Since many people do not have the main block of IDL programs indented, |
409 |
a face highlighting may be better. |
a face highlighting may be better. |
410 |
On Emacs 21, the overlay arrow is displayed in a special area and never |
In Emacs 21, the overlay arrow is displayed in a special area and never |
411 |
hides any code, so setting this to 'arrow on Emacs 21 sounds like a good idea." |
hides any code, so setting this to 'arrow on Emacs 21 sounds like a good idea." |
412 |
:group 'idlwave-shell-highlighting-and-faces |
:group 'idlwave-shell-highlighting-and-faces |
413 |
:type '(choice |
:type '(choice |
474 |
:group 'idlwave-shell-highlighting-and-faces |
:group 'idlwave-shell-highlighting-and-faces |
475 |
:type 'symbol) |
:type 'symbol) |
476 |
|
|
477 |
|
(defcustom idlwave-shell-output-face 'secondary-selection |
478 |
|
"*The face for `idlwave-shell-output-overlay'. |
479 |
|
Allows you to choose the font, color and other properties for |
480 |
|
the expression output by IDL." |
481 |
|
:group 'idlwave-shell-highlighting-and-faces |
482 |
|
:type 'symbol) |
483 |
|
|
484 |
;;; End user customization variables |
;;; End user customization variables |
485 |
|
|
486 |
;;; External variables |
;;; External variables |
487 |
(defvar comint-last-input-start) |
(defvar comint-last-input-start) |
488 |
(defvar comint-last-input-end) |
(defvar comint-last-input-end) |
489 |
|
|
490 |
;; Other variables |
(defun idlwave-shell-temp-file (type) |
491 |
|
"Return a temp file, creating it if necessary. |
492 |
|
|
493 |
(defvar idlwave-shell-temp-file-base |
TYPE is either 'pro or 'rinfo, and idlwave-shell-temp-pro-file or |
494 |
(make-temp-name idlwave-shell-temp-pro-prefix) |
idlwave-shell-temp-rinfo-save-file is set (respectively)." |
495 |
"Base name of the temporary files.") |
(cond |
496 |
|
((eq type 'rinfo) |
497 |
|
(or idlwave-shell-temp-rinfo-save-file |
498 |
|
(setq idlwave-shell-temp-rinfo-save-file |
499 |
|
(idlwave-shell-make-temp-file idlwave-shell-temp-pro-prefix)))) |
500 |
|
((eq type 'pro) |
501 |
|
(or idlwave-shell-temp-pro-file |
502 |
|
(setq idlwave-shell-temp-pro-file |
503 |
|
(idlwave-shell-make-temp-file idlwave-shell-temp-pro-prefix)))) |
504 |
|
(t (error "Wrong argument (idlwave-shell-temp-file): %s" |
505 |
|
(symbol-name type))))) |
506 |
|
|
507 |
|
|
508 |
|
(defun idlwave-shell-make-temp-file (prefix) |
509 |
|
"Create a temporary file." |
510 |
|
; Hard coded make-temp-file for Emacs<21 |
511 |
|
(if (fboundp 'make-temp-file) |
512 |
|
(make-temp-file prefix) |
513 |
|
(let (file |
514 |
|
(temp-file-dir (if (boundp 'temporary-file-directory) |
515 |
|
temporary-file-directory |
516 |
|
"/tmp"))) |
517 |
|
(while (condition-case () |
518 |
|
(progn |
519 |
|
(setq file |
520 |
|
(make-temp-name |
521 |
|
(expand-file-name prefix temp-file-dir))) |
522 |
|
(if (featurep 'xemacs) |
523 |
|
(write-region "" nil file nil 'silent nil) |
524 |
|
(write-region "" nil file nil 'silent nil 'excl)) |
525 |
|
nil) |
526 |
|
(file-already-exists t)) |
527 |
|
;; the file was somehow created by someone else between |
528 |
|
;; `make-temp-name' and `write-region', let's try again. |
529 |
|
nil) |
530 |
|
file))) |
531 |
|
|
532 |
(defvar idlwave-shell-temp-pro-file |
;; Other variables |
533 |
(concat idlwave-shell-temp-file-base ".pro") |
(defvar idlwave-shell-temp-pro-file |
534 |
|
nil |
535 |
"Absolute pathname for temporary IDL file for compiling regions") |
"Absolute pathname for temporary IDL file for compiling regions") |
536 |
|
|
537 |
(defvar idlwave-shell-temp-rinfo-save-file |
(defvar idlwave-shell-temp-rinfo-save-file |
538 |
(concat idlwave-shell-temp-file-base ".sav") |
nil |
539 |
"Absolute pathname for temporary IDL file save file for routine_info. |
"Absolute pathname for temporary IDL file save file for routine_info. |
540 |
This is used to speed up the reloading of the routine info procedure |
This is used to speed up the reloading of the routine info procedure |
541 |
before use by the shell.") |
before use by the shell.") |
542 |
|
|
|
|
|
543 |
(defvar idlwave-shell-dirstack-query "printd" |
(defvar idlwave-shell-dirstack-query "printd" |
544 |
"Command used by `idlwave-shell-resync-dirs' to query IDL for |
"Command used by `idlwave-shell-resync-dirs' to query IDL for |
545 |
the directory stack.") |
the directory stack.") |
546 |
|
|
547 |
|
(defvar idlwave-shell-wd-is-synched nil) |
548 |
|
|
549 |
(defvar idlwave-shell-path-query "__pa=expand_path(!path,/array)&for i=0,n_elements(__pa)-1 do print,'PATH:<'+__pa[i]+'>'&print,'SYSDIR:<'+!dir+'>'" |
(defvar idlwave-shell-path-query "__pa=expand_path(!path,/array)&for i=0,n_elements(__pa)-1 do print,'PATH:<'+__pa[i]+'>'&print,'SYSDIR:<'+!dir+'>'" |
550 |
"The command which gets !PATH and !DIR infor from the shell.") |
"The command which gets !PATH and !DIR infor from the shell.") |
551 |
|
|
569 |
(defvar idlwave-shell-is-stopped nil) |
(defvar idlwave-shell-is-stopped nil) |
570 |
(defvar idlwave-shell-expression-overlay nil |
(defvar idlwave-shell-expression-overlay nil |
571 |
"The overlay for where IDL is currently stopped.") |
"The overlay for where IDL is currently stopped.") |
572 |
|
(defvar idlwave-shell-output-overlay nil |
573 |
|
"The overlay for the last IDL output.") |
574 |
|
|
575 |
;; If these were already overlays, delete them. This probably means that we |
;; If these were already overlays, delete them. This probably means that we |
576 |
;; are reloading this file. |
;; are reloading this file. |
577 |
(if (overlayp idlwave-shell-stop-line-overlay) |
(if (overlayp idlwave-shell-stop-line-overlay) |
578 |
(delete-overlay idlwave-shell-stop-line-overlay)) |
(delete-overlay idlwave-shell-stop-line-overlay)) |
579 |
(if (overlayp idlwave-shell-expression-overlay) |
(if (overlayp idlwave-shell-expression-overlay) |
580 |
(delete-overlay idlwave-shell-expression-overlay)) |
(delete-overlay idlwave-shell-expression-overlay)) |
581 |
|
(if (overlayp idlwave-shell-output-overlay) |
582 |
|
(delete-overlay idlwave-shell-output-overlay)) |
583 |
|
|
584 |
;; Set to nil initially |
;; Set to nil initially |
585 |
(setq idlwave-shell-stop-line-overlay nil |
(setq idlwave-shell-stop-line-overlay nil |
586 |
idlwave-shell-expression-overlay nil) |
idlwave-shell-expression-overlay nil |
587 |
|
idlwave-shell-output-overlay nil) |
588 |
|
|
589 |
;; Define the shell stop overlay. When left nil, the arrow will be used. |
;; Define the shell stop overlay. When left nil, the arrow will be used. |
590 |
(cond |
(cond |
612 |
(overlay-put idlwave-shell-stop-line-overlay |
(overlay-put idlwave-shell-stop-line-overlay |
613 |
'face idlwave-shell-stop-line-face))))) |
'face idlwave-shell-stop-line-face))))) |
614 |
|
|
615 |
;; Now the expression overlay |
;; Now the expression and output overlays |
616 |
(setq idlwave-shell-expression-overlay (make-overlay 1 1)) |
(setq idlwave-shell-expression-overlay (make-overlay 1 1)) |
617 |
(overlay-put idlwave-shell-expression-overlay |
(overlay-put idlwave-shell-expression-overlay |
618 |
'face idlwave-shell-expression-face) |
'face idlwave-shell-expression-face) |
619 |
|
(setq idlwave-shell-output-overlay (make-overlay 1 1)) |
620 |
|
(overlay-put idlwave-shell-output-overlay |
621 |
|
'face idlwave-shell-output-face) |
622 |
|
|
623 |
(defvar idlwave-shell-bp-query "help,/breakpoints" |
(defvar idlwave-shell-bp-query "help,/breakpoints" |
624 |
"Command to obtain list of breakpoints") |
"Command to obtain list of breakpoints") |
625 |
|
|
631 |
The current command is finished when the IDL prompt is displayed. |
The current command is finished when the IDL prompt is displayed. |
632 |
This is evaluated if it is a list or called with funcall.") |
This is evaluated if it is a list or called with funcall.") |
633 |
|
|
634 |
|
(defvar idlwave-shell-sentinel-hook nil |
635 |
|
"Hook run when the idl process exits.") |
636 |
|
|
637 |
(defvar idlwave-shell-hide-output nil |
(defvar idlwave-shell-hide-output nil |
638 |
"If non-nil the process output is not inserted into the output |
"If non-nil the process output is not inserted into the output |
639 |
buffer.") |
buffer.") |
785 |
Info documentation for this package is available. Use \\[idlwave-info] |
Info documentation for this package is available. Use \\[idlwave-info] |
786 |
to display (complain to your sysadmin if that does not work). |
to display (complain to your sysadmin if that does not work). |
787 |
For Postscript and HTML versions of the documentation, check IDLWAVE's |
For Postscript and HTML versions of the documentation, check IDLWAVE's |
788 |
homepage at `http://www.strw.leidenuniv.nl/~dominik/Tools/idlwave'. |
homepage at `http://idlwave.org'. |
789 |
IDLWAVE has customize support - see the group `idlwave'. |
IDLWAVE has customize support - see the group `idlwave'. |
790 |
|
|
791 |
7. Keybindings |
7. Keybindings |
799 |
(setq comint-process-echoes t) |
(setq comint-process-echoes t) |
800 |
;; Can not use history expansion because "!" is used for system variables. |
;; Can not use history expansion because "!" is used for system variables. |
801 |
(setq comint-input-autoexpand nil) |
(setq comint-input-autoexpand nil) |
802 |
(setq comint-input-ring-size 64) |
; (setq comint-input-ring-size 64) |
803 |
(make-local-variable 'comint-completion-addsuffix) |
(make-local-variable 'comint-completion-addsuffix) |
804 |
(set (make-local-variable 'completion-ignore-case) t) |
(set (make-local-variable 'completion-ignore-case) t) |
805 |
(setq comint-completion-addsuffix '("/" . "")) |
(setq comint-completion-addsuffix '("/" . "")) |
843 |
(setq idlwave-shell-sources-alist nil) |
(setq idlwave-shell-sources-alist nil) |
844 |
(setq idlwave-shell-default-directory default-directory) |
(setq idlwave-shell-default-directory default-directory) |
845 |
(setq idlwave-shell-hide-output nil) |
(setq idlwave-shell-hide-output nil) |
846 |
|
|
847 |
|
;; NB: `make-local-hook' needed for older/alternative Emacs compatibility |
848 |
|
(make-local-hook 'kill-buffer-hook) |
849 |
(add-hook 'kill-buffer-hook 'idlwave-shell-kill-shell-buffer-confirm |
(add-hook 'kill-buffer-hook 'idlwave-shell-kill-shell-buffer-confirm |
850 |
nil 'local) |
nil 'local) |
851 |
(add-hook 'kill-buffer-hook 'idlwave-shell-delete-temp-files nil 'local) |
(add-hook 'kill-buffer-hook 'idlwave-shell-delete-temp-files nil 'local) |
853 |
(use-local-map idlwave-shell-mode-map) |
(use-local-map idlwave-shell-mode-map) |
854 |
(easy-menu-add idlwave-shell-mode-menu idlwave-shell-mode-map) |
(easy-menu-add idlwave-shell-mode-menu idlwave-shell-mode-map) |
855 |
|
|
856 |
(set (make-local-variable 'comint-scroll-to-bottom-on-input) t) |
;; Set the optional comint variables |
857 |
(set (make-local-variable 'comint-scroll-show-maximum-output) t) |
(when idlwave-shell-comint-settings |
858 |
|
(let ((list idlwave-shell-comint-settings) entry) |
859 |
|
(while (setq entry (pop list)) |
860 |
|
(set (make-local-variable (car entry)) (cdr entry))))) |
861 |
|
|
862 |
;; IDLWAVE syntax, and turn on abbreviations |
;; IDLWAVE syntax, and turn on abbreviations |
863 |
(setq local-abbrev-table idlwave-mode-abbrev-table) |
(setq local-abbrev-table idlwave-mode-abbrev-table) |
864 |
(set-syntax-table idlwave-mode-syntax-table) |
(set-syntax-table idlwave-mode-syntax-table) |
865 |
(set (make-local-variable 'comment-start) ";") |
(set (make-local-variable 'comment-start) ";") |
866 |
(setq abbrev-mode t) |
(setq abbrev-mode t) |
867 |
|
|
868 |
|
;; NB: `make-local-hook' needed for older/alternative Emacs compatibility |
869 |
|
(make-local-hook 'post-command-hook) |
870 |
(add-hook 'post-command-hook 'idlwave-command-hook nil t) |
(add-hook 'post-command-hook 'idlwave-command-hook nil t) |
871 |
|
|
872 |
|
;; Read the command history? |
873 |
|
(when (and idlwave-shell-save-command-history |
874 |
|
(stringp idlwave-shell-command-history-file)) |
875 |
|
(set (make-local-variable 'comint-input-ring-file-name) |
876 |
|
idlwave-shell-command-history-file) |
877 |
|
(if (file-regular-p idlwave-shell-command-history-file) |
878 |
|
(comint-read-input-ring))) |
879 |
|
|
880 |
;; Run the hooks. |
;; Run the hooks. |
881 |
(run-hooks 'idlwave-shell-mode-hook) |
(run-hooks 'idlwave-shell-mode-hook) |
882 |
(idlwave-shell-send-command idlwave-shell-initial-commands nil 'hide) |
(idlwave-shell-send-command idlwave-shell-initial-commands nil 'hide) |
917 |
;; The frame exists, so we use it. |
;; The frame exists, so we use it. |
918 |
idlwave-shell-display-wframe |
idlwave-shell-display-wframe |
919 |
;; The frame does not exist. We use the current frame. |
;; The frame does not exist. We use the current frame. |
920 |
;; However, if the current is the shell frame, we make a new frame. |
;; However, if the current is the shell frame, we make a new frame, |
921 |
|
;; or recycle the first existing visible frame |
922 |
(setq idlwave-shell-display-wframe |
(setq idlwave-shell-display-wframe |
923 |
(if (eq (selected-frame) idlwave-shell-idl-wframe) |
(if (eq (selected-frame) idlwave-shell-idl-wframe) |
924 |
(make-frame) |
(or |
925 |
|
(let ((flist (visible-frame-list)) |
926 |
|
(frame (selected-frame))) |
927 |
|
(catch 'exit |
928 |
|
(while flist |
929 |
|
(if (not (eq (car flist) |
930 |
|
idlwave-shell-idl-wframe)) |
931 |
|
(throw 'exit (car flist)) |
932 |
|
(setq flist (cdr flist)))))) |
933 |
|
(make-frame)) |
934 |
(selected-frame)))))) |
(selected-frame)))))) |
935 |
|
|
936 |
(defun idlwave-shell-shell-frame () |
(defun idlwave-shell-shell-frame () |
949 |
(make-frame idlwave-shell-frame-parameters))))) |
(make-frame idlwave-shell-frame-parameters))))) |
950 |
|
|
951 |
;;;###autoload |
;;;###autoload |
952 |
(defun idlwave-shell (&optional arg) |
(defun idlwave-shell (&optional arg quick) |
953 |
"Run an inferior IDL, with I/O through buffer `(idlwave-shell-buffer)'. |
"Run an inferior IDL, with I/O through buffer `(idlwave-shell-buffer)'. |
954 |
If buffer exists but shell process is not running, start new IDL. |
If buffer exists but shell process is not running, start new IDL. |
955 |
If buffer exists and shell process is running, just switch to the buffer. |
If buffer exists and shell process is running, just switch to the buffer. |
958 |
is non-nil, the shell buffer and the source buffers will be in |
is non-nil, the shell buffer and the source buffers will be in |
959 |
separate frames. |
separate frames. |
960 |
|
|
961 |
The command to run comes from variable `idlwave-shell-explicit-file-name'. |
The command to run comes from variable `idlwave-shell-explicit-file-name', |
962 |
|
with options taken from `idlwave-shell-command-line-options'. |
963 |
|
|
964 |
The buffer is put in `idlwave-shell-mode', providing commands for sending |
The buffer is put in `idlwave-shell-mode', providing commands for sending |
965 |
input and controlling the IDL job. See help on `idlwave-shell-mode'. |
input and controlling the IDL job. See help on `idlwave-shell-mode'. |
967 |
|
|
968 |
\(Type \\[describe-mode] in the shell buffer for a list of commands.)" |
\(Type \\[describe-mode] in the shell buffer for a list of commands.)" |
969 |
(interactive "P") |
(interactive "P") |
970 |
|
(if (eq arg 'quick) |
971 |
;; A non-nil arg means, we want a dedicated frame. This will last |
(progn |
972 |
;; for the current editing session. |
(let ((idlwave-shell-use-dedicated-frame nil)) |
973 |
(if arg (setq idlwave-shell-use-dedicated-frame t)) |
(idlwave-shell nil) |
974 |
(if (equal arg '(16)) (setq idlwave-shell-use-dedicated-frame nil)) |
(delete-other-windows)) |
975 |
|
(and idlwave-shell-use-dedicated-frame |
976 |
;; Check if the process still exists. If not, create it. |
(setq idlwave-shell-idl-wframe (selected-frame))) |
977 |
(unless (comint-check-proc (idlwave-shell-buffer)) |
(add-hook 'idlwave-shell-sentinel-hook |
978 |
(let* ((prg (or idlwave-shell-explicit-file-name "idl")) |
'save-buffers-kill-emacs t)) |
979 |
(buf (apply 'make-comint |
|
980 |
idlwave-shell-process-name prg nil |
;; A non-nil arg means, we want a dedicated frame. This will last |
981 |
idlwave-shell-command-line-options)) |
;; for the current editing session. |
982 |
(process (get-buffer-process buf))) |
(if arg (setq idlwave-shell-use-dedicated-frame t)) |
983 |
(setq idlwave-idlwave_routine_info-compiled nil) |
(if (equal arg '(16)) (setq idlwave-shell-use-dedicated-frame nil)) |
984 |
(set-process-filter process 'idlwave-shell-filter) |
|
985 |
(set-process-sentinel process 'idlwave-shell-sentinel) |
;; Check if the process still exists. If not, create it. |
986 |
(set-buffer buf) |
(unless (comint-check-proc (idlwave-shell-buffer)) |
987 |
(idlwave-shell-mode))) |
(let* ((prg (or idlwave-shell-explicit-file-name "idl")) |
988 |
(let ((window (idlwave-display-buffer (idlwave-shell-buffer) nil |
(buf (apply 'make-comint |
989 |
(idlwave-shell-shell-frame))) |
idlwave-shell-process-name prg nil |
990 |
(current-window (selected-window))) |
(if (stringp idlwave-shell-command-line-options) |
991 |
(select-window window) |
(idlwave-split-string |
992 |
(goto-char (point-max)) |
idlwave-shell-command-line-options) |
993 |
(select-window current-window) |
idlwave-shell-command-line-options))) |
994 |
(raise-frame (window-frame window)) |
(process (get-buffer-process buf))) |
995 |
(if (eq (selected-frame) (window-frame window)) |
(setq idlwave-idlwave_routine_info-compiled nil) |
996 |
(select-window window)) |
(set-process-filter process 'idlwave-shell-filter) |
997 |
)) |
(set-process-sentinel process 'idlwave-shell-sentinel) |
998 |
|
(set-buffer buf) |
999 |
|
(idlwave-shell-mode))) |
1000 |
|
(let ((window (idlwave-display-buffer (idlwave-shell-buffer) nil |
1001 |
|
(idlwave-shell-shell-frame))) |
1002 |
|
(current-window (selected-window))) |
1003 |
|
(select-window window) |
1004 |
|
(goto-char (point-max)) |
1005 |
|
(select-window current-window) |
1006 |
|
(if idlwave-shell-ready |
1007 |
|
(raise-frame (window-frame window))) |
1008 |
|
(if (eq (selected-frame) (window-frame window)) |
1009 |
|
(select-window window)) |
1010 |
|
))) |
1011 |
|
|
1012 |
(defun idlwave-shell-recenter-shell-window (&optional arg) |
(defun idlwave-shell-recenter-shell-window (&optional arg) |
1013 |
"Run `idlwave-shell', but make sure the current window stays selected." |
"Run `idlwave-shell', but make sure the current window stays selected." |
1032 |
and if `idlwave-shell-ready' is non-nil." |
and if `idlwave-shell-ready' is non-nil." |
1033 |
|
|
1034 |
;(setq hide nil) ; FIXME: turn this on for debugging only |
;(setq hide nil) ; FIXME: turn this on for debugging only |
1035 |
|
; (message "SENDING %s|||%s" cmd pcmd) ;?????????????????????? |
1036 |
(let (buf proc) |
(let (buf proc) |
1037 |
;; Get or make the buffer and its process |
;; Get or make the buffer and its process |
1038 |
(if (or (not (setq buf (get-buffer (idlwave-shell-buffer)))) |
(if (or (not (setq buf (get-buffer (idlwave-shell-buffer)))) |
1223 |
;; We no longer do the cleanup here - this is done by the process sentinel |
;; We no longer do the cleanup here - this is done by the process sentinel |
1224 |
(when (eq (process-status idlwave-shell-process-name) 'run) |
(when (eq (process-status idlwave-shell-process-name) 'run) |
1225 |
;; OK, process is still running, so we can use it. |
;; OK, process is still running, so we can use it. |
1226 |
(let ((data (match-data))) |
(setq idlwave-shell-wd-is-synched nil) ;; something might have changed cwd |
1227 |
|
(let ((data (match-data)) p) |
1228 |
(unwind-protect |
(unwind-protect |
1229 |
(progn |
(progn |
1230 |
;; May change the original match data. |
;; May change the original match data. |
1231 |
(let (p) |
(while (setq p (string-match "\C-M" string)) |
1232 |
(while (setq p (string-match "\C-M" string)) |
(aset string p ?\ )) |
1233 |
(aset string p ? ))) |
|
|
;;; Test/Debug code |
|
|
;; (save-excursion (set-buffer (get-buffer-create "*test*")) |
|
|
;; (goto-char (point-max)) |
|
|
;; (insert "%%%" string)) |
|
1234 |
;; |
;; |
1235 |
;; Keep output |
;; Keep output |
1236 |
|
|
1243 |
; (concat idlwave-shell-command-output string)) |
; (concat idlwave-shell-command-output string)) |
1244 |
;; Insert the string. Do this before getting the |
;; Insert the string. Do this before getting the |
1245 |
;; state. |
;; state. |
1246 |
|
(while (setq p (string-match "\C-G" string)) |
1247 |
|
(ding) |
1248 |
|
(aset string p ?\C-j )) |
1249 |
(if idlwave-shell-hide-output |
(if idlwave-shell-hide-output |
1250 |
(save-excursion |
(save-excursion |
1251 |
(set-buffer |
(set-buffer |
1253 |
(goto-char (point-max)) |
(goto-char (point-max)) |
1254 |
(insert string)) |
(insert string)) |
1255 |
(idlwave-shell-comint-filter proc string)) |
(idlwave-shell-comint-filter proc string)) |
1256 |
;; Watch for prompt - need to accumulate the current line |
;; Watch for magic - need to accumulate the current line |
1257 |
;; since it may not be sent all at once. |
;; since it may not be sent all at once. |
1258 |
(if (string-match "\n" string) |
(if (string-match "\n" string) |
1259 |
(progn |
(progn |
1268 |
(concat idlwave-shell-accumulation string))) |
(concat idlwave-shell-accumulation string))) |
1269 |
|
|
1270 |
|
|
1271 |
;; Check for prompt in current line |
;;; Test/Debug code |
1272 |
|
; (save-excursion (set-buffer |
1273 |
|
; (get-buffer-create "*idlwave-shell-output*")) |
1274 |
|
; (goto-char (point-max)) |
1275 |
|
; (insert "\nSTRING===>\n" string "\n<====\n")) |
1276 |
|
|
1277 |
|
;; Check for prompt in current accumulating line |
1278 |
(if (setq idlwave-shell-ready |
(if (setq idlwave-shell-ready |
1279 |
(string-match idlwave-shell-prompt-pattern |
(string-match idlwave-shell-prompt-pattern |
1280 |
idlwave-shell-accumulation)) |
idlwave-shell-accumulation)) |
1282 |
(if idlwave-shell-hide-output |
(if idlwave-shell-hide-output |
1283 |
(save-excursion |
(save-excursion |
1284 |
(set-buffer idlwave-shell-hidden-output-buffer) |
(set-buffer idlwave-shell-hidden-output-buffer) |
1285 |
(goto-char (point-min)) |
; (goto-char (point-min)) |
1286 |
(re-search-forward idlwave-shell-prompt-pattern nil t) |
; (re-search-forward idlwave-shell-prompt-pattern nil t) |
1287 |
|
(goto-char (point-max)) |
1288 |
|
(re-search-backward idlwave-shell-prompt-pattern nil t) |
1289 |
|
(goto-char (match-end 0)) |
1290 |
(setq idlwave-shell-command-output |
(setq idlwave-shell-command-output |
1291 |
(buffer-substring (point-min) (point))) |
(buffer-substring (point-min) (point))) |
1292 |
|
;; Test/Debug |
1293 |
|
; (save-excursion (set-buffer |
1294 |
|
; (get-buffer-create "*idlwave-shell-output*")) |
1295 |
|
; (goto-char (point-max)) |
1296 |
|
; (insert "\nOUPUT===>\n" idlwave-shell-command-output "\n<===\n")) |
1297 |
|
|
1298 |
(delete-region (point-min) (point))) |
(delete-region (point-min) (point))) |
1299 |
(setq idlwave-shell-command-output |
(setq idlwave-shell-command-output |
1300 |
(save-excursion |
(save-excursion |
1306 |
(beginning-of-line nil) |
(beginning-of-line nil) |
1307 |
(point)) |
(point)) |
1308 |
comint-last-input-end)))) |
comint-last-input-end)))) |
|
;;; Test/Debug code |
|
|
;; (save-excursion (set-buffer |
|
|
;; (get-buffer-create "*idlwave-shell-output*")) |
|
|
;; (goto-char (point-max)) |
|
|
;; (insert "%%%" string)) |
|
1309 |
;; Scan for state and do post command - bracket them |
;; Scan for state and do post command - bracket them |
1310 |
;; with idlwave-shell-ready=nil since they |
;; with idlwave-shell-ready=nil since they |
1311 |
;; may call idlwave-shell-send-command. |
;; may call idlwave-shell-send-command. |
1335 |
(save-excursion |
(save-excursion |
1336 |
(set-buffer (idlwave-shell-buffer)) |
(set-buffer (idlwave-shell-buffer)) |
1337 |
(goto-char (point-max)) |
(goto-char (point-max)) |
1338 |
(insert (format "\n\n Process %s %s" process event)))) |
(insert (format "\n\n Process %s %s" process event)) |
1339 |
|
(if (and idlwave-shell-save-command-history |
1340 |
|
(stringp idlwave-shell-command-history-file)) |
1341 |
|
(condition-case nil |
1342 |
|
(comint-write-input-ring) |
1343 |
|
(error nil))))) |
1344 |
|
|
1345 |
(when (and (> (length (frame-list)) 1) |
(when (and (> (length (frame-list)) 1) |
1346 |
(frame-live-p idlwave-shell-idl-wframe)) |
(frame-live-p idlwave-shell-idl-wframe)) |
1347 |
(delete-frame idlwave-shell-idl-wframe) |
(delete-frame idlwave-shell-idl-wframe) |
1348 |
(setq idlwave-shell-idl-wframe nil |
(setq idlwave-shell-idl-wframe nil |
1349 |
idlwave-shell-display-wframe nil)) |
idlwave-shell-display-wframe nil)) |
1350 |
(when (window-live-p win) |
(when (and (window-live-p win) |
1351 |
|
(not (one-window-p 'nomini))) |
1352 |
(delete-window win)) |
(delete-window win)) |
1353 |
(idlwave-shell-cleanup))) |
(idlwave-shell-cleanup) |
1354 |
|
;; Run the hook, if possible in the shell buffer. |
1355 |
|
(if (get-buffer buf) |
1356 |
|
(save-excursion |
1357 |
|
(set-buffer buf) |
1358 |
|
(run-hooks 'idlwave-shell-sentinel-hook)) |
1359 |
|
(run-hooks 'idlwave-shell-sentinel-hook)))) |
1360 |
|
|
1361 |
(defun idlwave-shell-scan-for-state () |
(defun idlwave-shell-scan-for-state () |
1362 |
"Scan for state info. |
"Scan for state info. |
1656 |
(let ((text idlwave-shell-command-output) |
(let ((text idlwave-shell-command-output) |
1657 |
(start 0) |
(start 0) |
1658 |
sep sep-re file type spec specs name cs key keys class entry) |
sep sep-re file type spec specs name cs key keys class entry) |
1659 |
|
; (message "GOT: %s" text) ;?????????????????????? |
1660 |
;; Initialize variables |
;; Initialize variables |
1661 |
(setq idlwave-compiled-routines nil |
(setq idlwave-compiled-routines nil |
1662 |
idlwave-unresolved-routines nil) |
idlwave-unresolved-routines nil) |
1669 |
text (substring text (match-end 0))) |
text (substring text (match-end 0))) |
1670 |
;; Set dummy values and kill the text |
;; Set dummy values and kill the text |
1671 |
(setq sep "@" sep-re "@ *" text "") |
(setq sep "@" sep-re "@ *" text "") |
1672 |
(message "Routine Info warning: No match for BEGIN line")) |
(message "Routine Info warning: No match for BEGIN line in \n>>>>\n%s\n<<<<\n" |
1673 |
|
idlwave-shell-command-output)) |
1674 |
(if (string-match "^>>>END OF IDLWAVE ROUTINE INFO.*" text) |
(if (string-match "^>>>END OF IDLWAVE ROUTINE INFO.*" text) |
1675 |
(setq text (substring text 0 (match-beginning 0))) |
(setq text (substring text 0 (match-beginning 0))) |
1676 |
(message "Routine Info warning: No match for END line")) |
(message "Routine Info warning: No match for END line in \n>>>>\n%s\n<<<<\n" |
1677 |
|
idlwave-shell-command-output)) |
1678 |
(if (string-match "\\S-" text) |
(if (string-match "\\S-" text) |
1679 |
;; Obviously, the pro worked. Make a note that we have it now. |
;; Obviously, the pro worked. Make a note that we have it now. |
1680 |
(setq idlwave-idlwave_routine_info-compiled t)) |
(setq idlwave-idlwave_routine_info-compiled t)) |
1792 |
We assume that we are after a file name when completing one of the |
We assume that we are after a file name when completing one of the |
1793 |
args of an executive .run, .rnew or .compile. Also, in a string |
args of an executive .run, .rnew or .compile. Also, in a string |
1794 |
constant we complete file names. Otherwise return nil, so that |
constant we complete file names. Otherwise return nil, so that |
1795 |
other completion functions can do thier work." |
other completion functions can do their work." |
1796 |
(let* ((comint-file-name-chars idlwave-shell-file-name-chars) |
;; Comint does something funny with the default directory, |
1797 |
(completion-ignore-case (default-value 'completion-ignore-case))) |
;; so we set it here from out safe own variable |
1798 |
(comint-dynamic-complete-filename))) |
(setq default-directory |
1799 |
|
(file-name-as-directory idlwave-shell-default-directory)) |
1800 |
|
(if (not idlwave-shell-wd-is-synched) |
1801 |
|
;; Some IDL stuff has been executed since last update, so we need to |
1802 |
|
;; do it again. |
1803 |
|
(idlwave-shell-send-command |
1804 |
|
idlwave-shell-dirstack-query |
1805 |
|
`(progn |
1806 |
|
(idlwave-shell-filter-directory) |
1807 |
|
(setq idlwave-shell-wd-is-synched t) |
1808 |
|
(switch-to-buffer (idlwave-shell-buffer)) |
1809 |
|
(goto-char ,(point)) ;; This is necesary on Emacs, don't know why |
1810 |
|
;; after the update, we immediately redo the completion, so the |
1811 |
|
;; user will hardly notice we did the update. |
1812 |
|
(idlwave-shell-complete-filename)) |
1813 |
|
'hide) |
1814 |
|
(let* ((comint-file-name-chars idlwave-shell-file-name-chars) |
1815 |
|
(completion-ignore-case (default-value 'completion-ignore-case))) |
1816 |
|
(comint-dynamic-complete-filename)))) |
1817 |
|
|
1818 |
(defun idlwave-shell-executive-command () |
(defun idlwave-shell-executive-command () |
1819 |
"Return the name of the current executive command, if any." |
"Return the name of the current executive command, if any." |
2251 |
(interactive "P") |
(interactive "P") |
2252 |
(idlwave-shell-print arg 'help)) |
(idlwave-shell-print arg 'help)) |
2253 |
|
|
2254 |
|
(defmacro idlwave-shell-mouse-examine (help &optional ev) |
2255 |
|
"Create a function for generic examination of expressions." |
2256 |
|
`(lambda (event) |
2257 |
|
"Expansion function for expression examination." |
2258 |
|
(interactive "e") |
2259 |
|
(let ((transient-mark-mode t) |
2260 |
|
(zmacs-regions t) |
2261 |
|
(tracker (if (featurep 'xemacs) 'mouse-track |
2262 |
|
'mouse-drag-region))) |
2263 |
|
(funcall tracker event) |
2264 |
|
(idlwave-shell-print (if (idlwave-region-active-p) '(16) nil) |
2265 |
|
,help ,ev)))) |
2266 |
|
|
2267 |
(defun idlwave-shell-mouse-print (event) |
(defun idlwave-shell-mouse-print (event) |
2268 |
"Call `idlwave-shell-print' at the mouse position." |
"Print value of variable at the mouse position, with `help'" |
2269 |
(interactive "e") |
(interactive "e") |
2270 |
(mouse-set-point event) |
(funcall (idlwave-shell-mouse-examine nil) event)) |
|
(idlwave-shell-print nil nil 'mouse)) |
|
2271 |
|
|
2272 |
(defun idlwave-shell-mouse-help (event) |
(defun idlwave-shell-mouse-help (event) |
2273 |
"Call `idlwave-shell-print' at the mouse position." |
"Print value of variable at the mouse position, with `print'." |
2274 |
|
(interactive "e") |
2275 |
|
(funcall (idlwave-shell-mouse-examine 'help) event)) |
2276 |
|
|
2277 |
|
(defun idlwave-shell-examine-select (event) |
2278 |
|
"Pop-up a list to select from for examining the expression" |
2279 |
(interactive "e") |
(interactive "e") |
2280 |
(mouse-set-point event) |
(funcall (idlwave-shell-mouse-examine nil event) event)) |
2281 |
(idlwave-shell-print nil 'help 'mouse)) |
|
2282 |
|
(defmacro idlwave-shell-examine (help) |
2283 |
|
"Create a function for key-driven expression examination." |
2284 |
|
`(lambda () |
2285 |
|
(interactive) |
2286 |
|
(idlwave-shell-print nil ,help))) |
2287 |
|
|
2288 |
|
(defun idlwave-shell-define-key-both (key hook) |
2289 |
|
"Define a key in both the shell and buffer mode maps." |
2290 |
|
(define-key idlwave-mode-map key hook) |
2291 |
|
(define-key idlwave-shell-mode-map key hook)) |
2292 |
|
|
2293 |
|
(defvar idlwave-shell-examine-label nil |
2294 |
|
"Label to include with examine text if separate.") |
2295 |
|
|
2296 |
|
(defun idlwave-shell-print (arg &optional help ev) |
2297 |
|
"Print current expression. |
2298 |
|
|
2299 |
|
With HELP non-nil, show help on expression. If HELP is a string, |
2300 |
|
the expression will be put in place of ___, e.g.: |
2301 |
|
|
2302 |
|
print,size(___,/DIMENSIONS) |
2303 |
|
|
2304 |
|
Otherwise, print is called on the expression. |
2305 |
|
|
|
(defun idlwave-shell-print (arg &optional help mouse) |
|
|
"Print current expression. With HELP, show help on expression. |
|
2306 |
An expression is an identifier plus 1 pair of matched parentheses |
An expression is an identifier plus 1 pair of matched parentheses |
2307 |
directly following the identifier - an array or function |
directly following the identifier - an array or function call. |
2308 |
call. Alternatively, an expression is the contents of any matched |
Alternatively, an expression is the contents of any matched |
2309 |
parentheses when the open parentheses is not directly preceded by an |
parentheses when the open parenthesis is not directly preceded by an |
2310 |
identifier. If point is at the beginning or within an expression |
identifier. If point is at the beginning or within an expression |
2311 |
return the inner-most containing expression, otherwise, return the |
return the inner-most containing expression, otherwise, return the |
2312 |
preceding expression. |
preceding expression. |
2313 |
|
|
2314 |
With prefix arg ARG, or when called from the shell buffer, prompt |
With prefix arg ARG prompt for an expression. |
2315 |
for an expression." |
|
2316 |
|
With double prefix arg, use the current region. |
2317 |
|
|
2318 |
|
If EV is a valid event passed, pop-up a list from |
2319 |
|
idlw-shell-examine-alist from which to select the help command text." |
2320 |
(interactive "P") |
(interactive "P") |
2321 |
(save-excursion |
(save-excursion |
2322 |
(let (expr beg end cmd) |
(let* ((process (get-buffer-process (current-buffer))) |
2323 |
(if (and (not mouse) |
(process-mark (if process (process-mark process))) |
2324 |
(or arg (eq major-mode 'idlwave-shell-mode))) |
(stack-label |
2325 |
(setq expr (read-string "Expression: ")) |
(if (and (integerp idlwave-shell-calling-stack-index) |
2326 |
|
(> idlwave-shell-calling-stack-index 0)) |
2327 |
|
(format " [-%d:%s]" |
2328 |
|
idlwave-shell-calling-stack-index |
2329 |
|
idlwave-shell-calling-stack-routine))) |
2330 |
|
expr beg end cmd examine-hook) |
2331 |
|
(cond |
2332 |
|
((and (equal arg '(16)) |
2333 |
|
(< (- (region-end) (region-beginning)) 2000)) |
2334 |
|
(setq beg (region-beginning) |
2335 |
|
end (region-end))) |
2336 |
|
(arg |
2337 |
|
(setq expr (read-string "Expression: "))) |
2338 |
|
(t |
2339 |
(idlwave-with-special-syntax1 |
(idlwave-with-special-syntax1 |
2340 |
;; Move to beginning of current or previous expression |
;; Move to beginning of current or previous expression |
2341 |
(if (looking-at "\\<\\|(") |
(if (looking-at "\\<\\|(") |
2354 |
(while (looking-at "\\>[[(]\\|\\.") |
(while (looking-at "\\>[[(]\\|\\.") |
2355 |
;; an array |
;; an array |
2356 |
(forward-sexp)) |
(forward-sexp)) |
2357 |
(setq end (point)) |
(setq end (point))))) |
2358 |
(setq expr (buffer-substring beg end)))) |
|
2359 |
|
;; Get expression, but first move the begin mark if a |
2360 |
|
;; process-mark is inside the region, to keep the overlay from |
2361 |
|
;; wandering in the Shell. |
2362 |
|
(when (and beg end) |
2363 |
|
(if (and process-mark (> process-mark beg) (< process-mark end)) |
2364 |
|
(setq beg (marker-position process-mark))) |
2365 |
|
(setq expr (buffer-substring beg end))) |
2366 |
|
|
2367 |
|
;; Show the overlay(s) and attach any necessary hooks and filters |
2368 |
(when (and beg end idlwave-shell-expression-overlay) |
(when (and beg end idlwave-shell-expression-overlay) |
2369 |
(move-overlay idlwave-shell-expression-overlay beg end |
(move-overlay idlwave-shell-expression-overlay beg end |
2370 |
(current-buffer)) |
(current-buffer)) |
2371 |
(add-hook 'pre-command-hook 'idlwave-shell-delete-expression-overlay)) |
(add-hook 'pre-command-hook |
2372 |
(if (and (integerp idlwave-shell-calling-stack-index) |
'idlwave-shell-delete-expression-overlay)) |
2373 |
(> idlwave-shell-calling-stack-index 0)) |
(setq examine-hook |
2374 |
|
(if idlwave-shell-separate-examine-output |
2375 |
|
'idlwave-shell-examine-display |
2376 |
|
'idlwave-shell-examine-highlight)) |
2377 |
|
(add-hook 'pre-command-hook |
2378 |
|
'idlwave-shell-delete-output-overlay) |
2379 |
|
|
2380 |
|
;; Remove empty or comment-only lines |
2381 |
|
(while (string-match "\n[ \t]*\\(;.*\\)?\r*\n" expr) |
2382 |
|
(setq expr (replace-match "\n" t t expr))) |
2383 |
|
;; Concatenate continuation lines |
2384 |
|
(while (string-match "[ \t]*\\$.*\\(;.*\\)?\\(\n[ \t]*\\|$\\)" expr) |
2385 |
|
(setq expr (replace-match "" t t expr))) |
2386 |
|
;; Remove final newline |
2387 |
|
(if (string-match "\n[ \t\r]*\\'" expr) |
2388 |
|
(setq expr (replace-match "" t t expr))) |
2389 |
|
;; Pop-up the examine selection list, if appropriate |
2390 |
|
(if (and ev idlwave-shell-examine-alist) |
2391 |
|
(let* ((help-cons |
2392 |
|
(assoc |
2393 |
|
(idlwave-popup-select |
2394 |
|
ev (mapcar 'car idlwave-shell-examine-alist) |
2395 |
|
"Examine with") |
2396 |
|
idlwave-shell-examine-alist))) |
2397 |
|
(setq help (cdr help-cons)) |
2398 |
|
(if idlwave-shell-separate-examine-output |
2399 |
|
(setq idlwave-shell-examine-label |
2400 |
|
(concat |
2401 |
|
(format "==>%s<==\n%s:" expr (car help-cons)) |
2402 |
|
stack-label "\n")))) |
2403 |
|
(setq idlwave-shell-examine-label |
2404 |
|
(concat |
2405 |
|
(format "==>%s<==\n%s:" expr |
2406 |
|
(cond ((null help) "print") |
2407 |
|
((stringp help) help) |
2408 |
|
(t (symbol-name help)))) |
2409 |
|
stack-label "\n"))) |
2410 |
|
|
2411 |
|
;; Send the command |
2412 |
|
(if stack-label |
2413 |
(setq cmd (idlwave-retrieve-expression-from-level |
(setq cmd (idlwave-retrieve-expression-from-level |
2414 |
expr |
expr |
2415 |
idlwave-shell-calling-stack-index |
idlwave-shell-calling-stack-index |
2416 |
idlwave-shell-calling-stack-routine |
idlwave-shell-calling-stack-routine |
2417 |
help)) |
help)) |
2418 |
(setq cmd (concat (if help "help," "print,") expr))) |
(setq cmd (idlwave-shell-help-statement help expr))) |
2419 |
(if idlwave-shell-print-expression-function |
;(idlwave-shell-recenter-shell-window) |
2420 |
(idlwave-shell-send-command |
(idlwave-shell-send-command |
2421 |
cmd |
cmd |
2422 |
(list idlwave-shell-print-expression-function expr) |
examine-hook |
2423 |
'hide) |
(if idlwave-shell-separate-examine-output 'hide))))) |
2424 |
(idlwave-shell-recenter-shell-window) |
|
2425 |
(idlwave-shell-send-command cmd))))) |
(defvar idlwave-shell-examine-window-alist nil |
2426 |
|
"Variable to hold the win/height pairs for all *Examine* windows.") |
2427 |
|
|
2428 |
|
(defun idlwave-shell-examine-display () |
2429 |
|
"View the examine command output in a separate buffer." |
2430 |
|
(let (win cur-beg cur-end) |
2431 |
|
(save-excursion |
2432 |
|
(set-buffer (get-buffer-create "*Examine*")) |
2433 |
|
(use-local-map idlwave-shell-examine-map) |
2434 |
|
(setq buffer-read-only nil) |
2435 |
|
(goto-char (point-max)) |
2436 |
|
(save-restriction |
2437 |
|
(narrow-to-region (point) (point)) |
2438 |
|
(if (string-match "^% Syntax error." idlwave-shell-command-output) |
2439 |
|
(insert "% Syntax error.\n") |
2440 |
|
(insert idlwave-shell-command-output) |
2441 |
|
;; Just take the last bit between the prompts (if more than one). |
2442 |
|
(let* ((end (or |
2443 |
|
(re-search-backward idlwave-shell-prompt-pattern nil t) |
2444 |
|
(point-max))) |
2445 |
|
(beg (progn |
2446 |
|
(goto-char |
2447 |
|
(or (progn (if (re-search-backward |
2448 |
|
idlwave-shell-prompt-pattern nil t) |
2449 |
|
(match-end 0))) |
2450 |
|
(point-min))) |
2451 |
|
(re-search-forward "\n"))) |
2452 |
|
(str (buffer-substring beg end))) |
2453 |
|
(delete-region (point-min) (point-max)) |
2454 |
|
(insert str) |
2455 |
|
(if idlwave-shell-examine-label |
2456 |
|
(progn (goto-char (point-min)) |
2457 |
|
(insert idlwave-shell-examine-label) |
2458 |
|
(setq idlwave-shell-examine-label nil))))) |
2459 |
|
(setq cur-beg (point-min) |
2460 |
|
cur-end (point-max)) |
2461 |
|
(setq buffer-read-only t) |
2462 |
|
(move-overlay idlwave-shell-output-overlay cur-beg cur-end |
2463 |
|
(current-buffer)) |
2464 |
|
|
2465 |
|
;; Look for the examine buffer in all windows. If one is |
2466 |
|
;; found in a frame all by itself, use that, otherwise, switch |
2467 |
|
;; to or create an examine window in this frame, and resize if |
2468 |
|
;; it's a newly created window |
2469 |
|
(let* ((winlist (get-buffer-window-list "*Examine*" nil 'visible))) |
2470 |
|
(setq win (idlwave-display-buffer |
2471 |
|
"*Examine*" |
2472 |
|
nil |
2473 |
|
(let ((list winlist) thiswin) |
2474 |
|
(catch 'exit |
2475 |
|
(save-selected-window |
2476 |
|
(while (setq thiswin (pop list)) |
2477 |
|
(select-window thiswin) |
2478 |
|
(if (one-window-p) |
2479 |
|
(throw 'exit (window-frame thiswin))))))))) |
2480 |
|
(set-window-start win (point-min)) ; Ensure the point is visible. |
2481 |
|
(save-selected-window |
2482 |
|
(select-window win) |
2483 |
|
(let ((elt (assoc win idlwave-shell-examine-window-alist))) |
2484 |
|
(when (and (not (one-window-p)) |
2485 |
|
(or (not (memq win winlist)) ;a newly created window |
2486 |
|
(eq (window-height) (cdr elt)))) |
2487 |
|
;; Autosize it. |
2488 |
|
(enlarge-window (- (/ (frame-height) 2) |
2489 |
|
(window-height))) |
2490 |
|
(shrink-window-if-larger-than-buffer) |
2491 |
|
;; Clean the window list of dead windows |
2492 |
|
(setq idlwave-shell-examine-window-alist |
2493 |
|
(delq nil |
2494 |
|
(mapcar (lambda (x) (if (window-live-p (car x)) x)) |
2495 |
|
idlwave-shell-examine-window-alist))) |
2496 |
|
;; And add the new value. |
2497 |
|
(if (setq elt (assoc win idlwave-shell-examine-window-alist)) |
2498 |
|
(setcdr elt (window-height)) |
2499 |
|
(add-to-list 'idlwave-shell-examine-window-alist |
2500 |
|
(cons win (window-height))))))))) |
2501 |
|
;; Recenter for maximum output, after widened |
2502 |
|
(save-selected-window |
2503 |
|
(select-window win) |
2504 |
|
(goto-char (point-max)) |
2505 |
|
(skip-chars-backward "\n") |
2506 |
|
(recenter -1))))) |
2507 |
|
|
2508 |
|
(defvar idlwave-shell-examine-map (make-sparse-keymap)) |
2509 |
|
(define-key idlwave-shell-examine-map "q" 'idlwave-shell-examine-display-quit) |
2510 |
|
(define-key idlwave-shell-examine-map "c" 'idlwave-shell-examine-display-clear) |
2511 |
|
|
2512 |
|
(defun idlwave-shell-examine-display-quit () |
2513 |
|
(interactive) |
2514 |
|
(let ((win (selected-window))) |
2515 |
|
(if (one-window-p) |
2516 |
|
(delete-frame (window-frame win)) |
2517 |
|
(delete-window win)))) |
2518 |
|
|
2519 |
|
(defun idlwave-shell-examine-display-clear () |
2520 |
|
(interactive) |
2521 |
|
(save-excursion |
2522 |
|
(let ((buf (get-buffer "*Examine*"))) |
2523 |
|
(when (bufferp buf) |
2524 |
|
(set-buffer buf) |
2525 |
|
(setq buffer-read-only nil) |
2526 |
|
(erase-buffer) |
2527 |
|
(setq buffer-read-only t))))) |
2528 |
|
|
2529 |
(defun idlwave-retrieve-expression-from-level (expr level routine help) |
(defun idlwave-retrieve-expression-from-level (expr level routine help) |
2530 |
"Return IDL command to print the expression EXPR from stack level LEVEL. |
"Return IDL command to print the expression EXPR from stack level LEVEL. |
2537 |
level. |
level. |
2538 |
|
|
2539 |
Since this function depends upon the undocumented IDL routine routine_names, |
Since this function depends upon the undocumented IDL routine routine_names, |
2540 |
there is no guarantie that this will work with future versions of IDL." |
there is no guarantee that this will work with future versions of IDL." |
2541 |
(let ((prefix "___") ;; No real variables should starts with this. |
(let ((prefix "___") ;; No real variables should starts with this. |
2542 |
(fetch (- 0 level)) |
(fetch (- 0 level)) |
2543 |
(start 0) |
(start 0) |
2544 |
var tvar fetch-vars pre post) |
var tvar fetch-vars pre post) |
2545 |
|
|
2546 |
;; FIXME: In the following we try to find the variables in expression |
;; FIXME: In the following we try to find the variables in expression |
2547 |
;; This is quite empirical - I don't know in what situations this will |
;; This is quite empirical - I don't know in what situations this will |
2548 |
;; break. We will look for identifiers and exclude cases where we |
;; break. We will look for identifiers and exclude cases where we |
2549 |
;; know it is not a variable. To distinguish array references from |
;; know it is not a variable. To distinguish array references from |
2550 |
;; function calls, we require that arrays use [] instead of () |
;; function calls, we require that arrays use [] instead of () |
2551 |
|
|
2552 |
(while (string-match |
(while (string-match |
2553 |
"\\(\\`\\|[^a-zA-Z0-9$_]\\)\\([a-zA-Z][a-zA-Z0-9$_]*\\)\\([^a-zA-Z0-9$_]\\|\\'\\)" expr start) |
"\\(\\`\\|[^a-zA-Z0-9$_]\\)\\([a-zA-Z][a-zA-Z0-9$_]*\\)\\([^a-zA-Z0-9$_]\\|\\'\\)" expr start) |
2554 |
(setq var (match-string 2 expr) |
(setq var (match-string 2 expr) |
2555 |
tvar (concat prefix var) |
tvar (concat prefix var) |
2556 |
start (match-beginning 2) |
start (match-beginning 2) |
2557 |
pre (substring expr 0 (match-beginning 2)) |
pre (substring expr 0 (match-beginning 2)) |
2558 |
post (substring expr (match-end 2))) |
post (substring expr (match-end 2))) |
2559 |
(cond |
(cond |
2560 |
;; Exclude identifiers which are not variables |
;; Exclude identifiers which are not variables |
2561 |
((string-match ",[ \t]*/\\'" pre)) ;; a `/' KEYWORD |
((string-match ",[ \t]*/\\'" pre)) ;; a `/' KEYWORD |
2562 |
((and (string-match "[,(][ \t]*\\'" pre) |
((and (string-match "[,(][ \t]*\\'" pre) |
2563 |
(string-match "\\`[ \t]*=" post))) ;; a `=' KEYWORD |
(string-match "\\`[ \t]*=" post))) ;; a `=' KEYWORD |
2564 |
((string-match "\\`(" post)) ;; a function |
((string-match "\\`(" post)) ;; a function |
2565 |
((string-match "->[ \t]*\\'" pre)) ;; a method |
((string-match "->[ \t]*\\'" pre)) ;; a method |
2566 |
((string-match "\\.\\'" pre)) ;; structure member |
((string-match "\\.\\'" pre)) ;; structure member |
2567 |
(t ;; seems to be a variable - arrange to get it and replace |
(t ;; seems to be a variable - arrange to get it and replace |
2568 |
;; its name in the expression with the temproary name. |
;; its name in the expression with the temproary name. |
2569 |
(push (cons var tvar) fetch-vars) |
(push (cons var tvar) fetch-vars) |
2570 |
(setq expr (concat pre tvar post))))) |
(setq expr (concat pre tvar post)))) |
2571 |
|
(if (= start 0) (setq start 1))) |
2572 |
;; Make a command line that first copies the relevant variables |
;; Make a command line that first copies the relevant variables |
2573 |
;; and then prints the expression. |
;; and then prints the expression. |
2574 |
(concat |
(concat |
2577 |
(format "%s = routine_names('%s',fetch=%d)" (cdr x) (car x) fetch)) |
(format "%s = routine_names('%s',fetch=%d)" (cdr x) (car x) fetch)) |
2578 |
(nreverse fetch-vars) |
(nreverse fetch-vars) |
2579 |
" & ") |
" & ") |
2580 |
(if idlwave-shell-print-expression-function " & " "\n") |
"\n" |
2581 |
(if help "help, " "print, ") |
(idlwave-shell-help-statement help expr) |
|
expr |
|
2582 |
(format " ; [-%d:%s]" level routine)))) |
(format " ; [-%d:%s]" level routine)))) |
2583 |
|
|
2584 |
|
(defun idlwave-shell-help-statement (help expr) |
2585 |
|
"Construct a help statement for printing expression EXPR. |
2586 |
|
|
2587 |
|
HELP can be non-nil for `help,', nil for 'print,' or any string into which |
2588 |
|
to insert expression in place of the marker ___, e.g.: print, |
2589 |
|
size(___,/DIMENSIONS)" |
2590 |
|
(cond |
2591 |
|
((null help) (concat "print, " expr)) |
2592 |
|
((stringp help) |
2593 |
|
(if (string-match "\\(^\\|[^_]\\)\\(___\\)\\([^_]\\|$\\)" help) |
2594 |
|
(concat (substring help 0 (match-beginning 2)) |
2595 |
|
expr |
2596 |
|
(substring help (match-end 2))))) |
2597 |
|
(t (concat "help, " expr)))) |
2598 |
|
|
2599 |
|
|
2600 |
|
(defun idlwave-shell-examine-highlight () |
2601 |
|
"Highlight the most recent IDL output." |
2602 |
|
(let* ((buffer (get-buffer (idlwave-shell-buffer))) |
2603 |
|
(process (get-buffer-process buffer)) |
2604 |
|
(process-mark (if process (process-mark process))) |
2605 |
|
output-begin output-end) |
2606 |
|
(save-excursion |
2607 |
|
(set-buffer buffer) |
2608 |
|
(goto-char process-mark) |
2609 |
|
(beginning-of-line) |
2610 |
|
(setq output-end (point)) |
2611 |
|
(re-search-backward idlwave-shell-prompt-pattern nil t) |
2612 |
|
(beginning-of-line 2) |
2613 |
|
(setq output-begin (point))) |
2614 |
|
|
2615 |
|
;; First make sure the shell window is visible |
2616 |
|
(idlwave-display-buffer (idlwave-shell-buffer) |
2617 |
|
nil (idlwave-shell-shell-frame)) |
2618 |
|
(if (and idlwave-shell-output-overlay process-mark) |
2619 |
|
(move-overlay idlwave-shell-output-overlay |
2620 |
|
output-begin output-end buffer)))) |
2621 |
|
|
2622 |
|
(defun idlwave-shell-delete-output-overlay () |
2623 |
|
(if (eq this-command 'idlwave-shell-mouse-nop) |
2624 |
|
nil |
2625 |
|
(condition-case nil |
2626 |
|
(if idlwave-shell-output-overlay |
2627 |
|
(delete-overlay idlwave-shell-output-overlay)) |
2628 |
|
(error nil)) |
2629 |
|
(remove-hook 'pre-command-hook 'idlwave-shell-delete-output-overlay))) |
2630 |
|
|
2631 |
(defun idlwave-shell-delete-expression-overlay () |
(defun idlwave-shell-delete-expression-overlay () |
2632 |
(condition-case nil |
(if (eq this-command 'idlwave-shell-mouse-nop) |
2633 |
(if idlwave-shell-expression-overlay |
nil |
2634 |
(delete-overlay idlwave-shell-expression-overlay)) |
(condition-case nil |
2635 |
(error nil)) |
(if idlwave-shell-expression-overlay |
2636 |
(remove-hook 'pre-command-hook 'idlwave-shell-delete-expression-overlay)) |
(delete-overlay idlwave-shell-expression-overlay)) |
2637 |
|
(error nil)) |
2638 |
|
(remove-hook 'pre-command-hook 'idlwave-shell-delete-expression-overlay))) |
2639 |
|
|
2640 |
(defvar idlwave-shell-bp-alist nil |
(defvar idlwave-shell-bp-alist nil |
2641 |
"Alist of breakpoints. |
"Alist of breakpoints. |
2673 |
(let ((oldbuf (current-buffer))) |
(let ((oldbuf (current-buffer))) |
2674 |
(save-excursion |
(save-excursion |
2675 |
(set-buffer (idlwave-find-file-noselect |
(set-buffer (idlwave-find-file-noselect |
2676 |
idlwave-shell-temp-pro-file 'tmp)) |
(idlwave-shell-temp-file 'pro) 'tmp)) |
2677 |
|
(set (make-local-variable 'comment-start-skip) ";+[ \t]*") |
2678 |
|
(set (make-local-variable 'comment-start) ";") |
2679 |
(erase-buffer) |
(erase-buffer) |
2680 |
(insert-buffer-substring oldbuf beg end) |
(insert-buffer-substring oldbuf beg end) |
2681 |
(if (not (save-excursion |
(if (not (save-excursion |
2715 |
(error nil)))) |
(error nil)))) |
2716 |
|
|
2717 |
(defun idlwave-display-buffer (buf not-this-window-p &optional frame) |
(defun idlwave-display-buffer (buf not-this-window-p &optional frame) |
2718 |
(if (or (< emacs-major-version 20) |
(if (not (frame-live-p frame)) (setq frame nil)) |
2719 |
(and (= emacs-major-version 20) |
(display-buffer buf not-this-window-p frame)) |
|
(< emacs-minor-version 3))) |
|
|
;; Only two args. |
|
|
(display-buffer buf not-this-window-p) |
|
|
;; Three ares possible. |
|
|
(display-buffer buf not-this-window-p frame))) |
|
2720 |
|
|
2721 |
(defvar idlwave-shell-bp-buffer " *idlwave-shell-bp*" |
(defvar idlwave-shell-bp-buffer " *idlwave-shell-bp*" |
2722 |
"Scratch buffer for parsing IDL breakpoint lists and other stuff.") |
"Scratch buffer for parsing IDL breakpoint lists and other stuff.") |
2759 |
(insert idlwave-shell-command-output) |
(insert idlwave-shell-command-output) |
2760 |
(goto-char (point-min)) |
(goto-char (point-min)) |
2761 |
(let ((old-bp-alist idlwave-shell-bp-alist) |
(let ((old-bp-alist idlwave-shell-bp-alist) |
2762 |
file line index module) |
;; Searching the breakpoints |
2763 |
|
;; In IDL 5.5, the breakpoint reporting format changed. |
2764 |
|
(bp-re54 "^[ \t]*\\([0-9]+\\)[ \t]+\\(\\S-+\\)?[ \t]+\\([0-9]+\\)[ \t]+\\(\\S-+\\)") |
2765 |
|
(bp-re55 "^\\s-*\\([0-9]+\\)\\s-+\\([0-9]+\\)\\s-+\\(Uncompiled\\|Func=\\|Pro=\\)\\(\\S-+\\)?\\s-+\\(\\S-+\\)") |
2766 |
|
file line index module |
2767 |
|
bp-re indmap) |
2768 |
(setq idlwave-shell-bp-alist (list nil)) |
(setq idlwave-shell-bp-alist (list nil)) |
2769 |
(when (re-search-forward "^\\s-*Index.*\n\\s-*-" nil t) |
;; Search for either header type, and set the correct regexp |
2770 |
|
(when (or |
2771 |
|
(if (re-search-forward "^\\s-*Index.*\n\\s-*-" nil t) |
2772 |
|
(setq bp-re bp-re54 ; versions <= 5.4 |
2773 |
|
indmap '(1 2 3 4))) |
2774 |
|
(if (re-search-forward |
2775 |
|
"^\\s-*Index\\s-*Line\\s-*Attributes\\s-*File" nil t) |
2776 |
|
(setq bp-re bp-re55 ; versions >= 5.5 |
2777 |
|
indmap '(1 4 2 5)))) |
2778 |
;; There seems to be a breakpoint listing here. |
;; There seems to be a breakpoint listing here. |
2779 |
;; Parse breakpoint lines. |
;; Parse breakpoint lines. |
2780 |
;; Breakpoints have the form: |
;; Breakpoints have the form |
2781 |
|
;; for IDL<=v5.4: |
2782 |
;; Index Module Line File |
;; Index Module Line File |
2783 |
;; All seperated by whitespace. |
;; All separated by whitespace. |
2784 |
;; Module may be missing if the file is not compiled. |
;; Module may be missing if the file is not compiled. |
2785 |
;; |
;; for IDL>=v5.5: |
2786 |
(while (re-search-forward |
;; Index Line Attributes File |
2787 |
"^[ \t]*\\([0-9]+\\)[ \t]+\\(\\S-+\\)?[ \t]+\\([0-9]+\\)[ \t]+\\(\\S-+\\)" nil t) |
;; (attributes replaces module, "Uncompiled" included) |
2788 |
(setq index (match-string 1) |
(while (re-search-forward bp-re nil t) |
2789 |
module (match-string 2) |
(setq index (match-string (nth 0 indmap)) |
2790 |
line (string-to-int (match-string 3)) |
module (match-string (nth 1 indmap)) |
2791 |
file (idlwave-shell-file-name (match-string 4))) |
line (string-to-int (match-string (nth 2 indmap))) |
2792 |
|
file (idlwave-shell-file-name (match-string (nth 3 indmap)))) |
2793 |
;; Add the breakpoint info to the list |
;; Add the breakpoint info to the list |
2794 |
(nconc idlwave-shell-bp-alist |
(nconc idlwave-shell-bp-alist |
2795 |
(list (cons (list file line) |
(list (cons (list file line) |
2844 |
The breakpoint will be placed at the beginning of the statement on the |
The breakpoint will be placed at the beginning of the statement on the |
2845 |
line specified by BP or at the next IDL statement if that line is not |
line specified by BP or at the next IDL statement if that line is not |
2846 |
a statement. |
a statement. |
2847 |
Determines IDL's internal representation for the breakpoint which may |
Determines IDL's internal representation for the breakpoint, which may |
2848 |
have occurred at a different line then used with the breakpoint |
have occurred at a different line than used with the breakpoint |
2849 |
command." |
command." |
2850 |
|
|
2851 |
;; Get and save the old breakpoints |
;; Get and save the old breakpoints |
2852 |
(idlwave-shell-send-command |
(idlwave-shell-send-command |
2853 |
idlwave-shell-bp-query |
idlwave-shell-bp-query |
2854 |
'(progn |
'(progn |
2855 |
(idlwave-shell-filter-bp) |
(idlwave-shell-filter-bp) |
2856 |
(setq idlwave-shell-old-bp idlwave-shell-bp-alist)) |
(setq idlwave-shell-old-bp idlwave-shell-bp-alist)) |
2857 |
'hide) |
'hide) |
2858 |
;; Get sources for IDL compiled procedures followed by setting |
;; Get sources for IDL compiled procedures followed by setting |
2859 |
;; breakpoint. |
;; breakpoint. |
2860 |
(idlwave-shell-send-command |
(idlwave-shell-send-command |
2861 |
idlwave-shell-sources-query |
idlwave-shell-sources-query |
2862 |
`(progn |
`(progn |
2863 |
(idlwave-shell-sources-filter) |
(idlwave-shell-sources-filter) |
2864 |
(idlwave-shell-set-bp2 (quote ,bp))) |
(idlwave-shell-set-bp2 (quote ,bp))) |
2865 |
'hide)) |
'hide)) |
2866 |
|
|
2867 |
(defun idlwave-shell-set-bp2 (bp) |
(defun idlwave-shell-set-bp2 (bp) |
3091 |
idlwave-routines) |
idlwave-routines) |
3092 |
(idlwave-shell-update-routine-info t))) |
(idlwave-shell-update-routine-info t))) |
3093 |
|
|
3094 |
(defvar idlwave-shell-sources-query "help,/source" |
(defvar idlwave-shell-sources-query "help,/source,/full" |
3095 |
"IDL command to obtain source files for compiled procedures.") |
"IDL command to obtain source files for compiled procedures.") |
3096 |
|
|
3097 |
(defvar idlwave-shell-sources-alist nil |
(defvar idlwave-shell-sources-alist nil |
3218 |
(let ((def-dir (if (eq major-mode 'idlwave-shell-mode) |
(let ((def-dir (if (eq major-mode 'idlwave-shell-mode) |
3219 |
default-directory |
default-directory |
3220 |
idlwave-shell-default-directory))) |
idlwave-shell-default-directory))) |
3221 |
(if idlwave-shell-use-truename |
(if idlwave-shell-use-truename |
3222 |
(file-truename name def-dir) |
(file-truename name def-dir) |
3223 |
(expand-file-name name def-dir)))) |
(expand-file-name name def-dir)))) |
3224 |
|
|
|
|
|
3225 |
;; Keybindings -------------------------------------------------------------- |
;; Keybindings -------------------------------------------------------------- |
3226 |
|
|
3227 |
(defvar idlwave-shell-mode-map (copy-keymap comint-mode-map) |
(defvar idlwave-shell-mode-map (copy-keymap comint-mode-map) |
3248 |
(define-key idlwave-shell-mode-map [(down)] 'idlwave-shell-down-or-history) |
(define-key idlwave-shell-mode-map [(down)] 'idlwave-shell-down-or-history) |
3249 |
(define-key idlwave-mode-map "\C-c\C-y" 'idlwave-shell-char-mode-loop) |
(define-key idlwave-mode-map "\C-c\C-y" 'idlwave-shell-char-mode-loop) |
3250 |
(define-key idlwave-mode-map "\C-c\C-x" 'idlwave-shell-send-char) |
(define-key idlwave-mode-map "\C-c\C-x" 'idlwave-shell-send-char) |
3251 |
(define-key idlwave-mode-map |
|
3252 |
(if (featurep 'xemacs) [(shift button2)] [(shift mouse-2)]) |
;; The mouse bindings for PRINT and HELP |
3253 |
'idlwave-shell-mouse-print) |
(idlwave-shell-define-key-both |
3254 |
(define-key idlwave-mode-map |
(if (featurep 'xemacs) |
3255 |
(if (featurep 'xemacs) [(shift control button2)] [(shift control mouse-2)]) |
[(shift button2)] |
3256 |
'idlwave-shell-mouse-help) |
[(shift down-mouse-2)]) |
3257 |
(define-key idlwave-shell-mode-map |
'idlwave-shell-mouse-print) |
3258 |
(if (featurep 'xemacs) [(shift button2)] [(shift mouse-2)]) |
(idlwave-shell-define-key-both |
3259 |
'idlwave-shell-mouse-print) |
(if (featurep 'xemacs) |
3260 |
(define-key idlwave-shell-mode-map |
[(control meta button2)] |
3261 |
(if (featurep 'xemacs) [(shift control button2)] [(shift control mouse-2)]) |
[(control meta down-mouse-2)]) |
3262 |
'idlwave-shell-mouse-help) |
'idlwave-shell-mouse-help) |
3263 |
|
(idlwave-shell-define-key-both |
3264 |
|
(if (featurep 'xemacs) |
3265 |
|
[(control shift button2)] |
3266 |
|
[(control shift down-mouse-2)]) |
3267 |
|
'idlwave-shell-examine-select) |
3268 |
|
;; Add this one from the idlwave-mode-map |
3269 |
(define-key idlwave-shell-mode-map |
(define-key idlwave-shell-mode-map |
3270 |
(if (featurep 'xemacs) [(shift button3)] [(shift mouse-3)]) |
(if (featurep 'xemacs) |
3271 |
|
[(shift button3)] |
3272 |
|
[(shift mouse-3)]) |
3273 |
'idlwave-mouse-context-help) |
'idlwave-mouse-context-help) |
3274 |
|
|
3275 |
|
;; For Emacs, we need to turn off the button release events. |
3276 |
|
(defun idlwave-shell-mouse-nop (event) |
3277 |
|
(interactive "e")) |
3278 |
|
(unless (featurep 'xemacs) |
3279 |
|
(idlwave-shell-define-key-both |
3280 |
|
[(shift mouse-2)] 'idlwave-shell-mouse-nop) |
3281 |
|
(idlwave-shell-define-key-both |
3282 |
|
[(shift control mouse-2)] 'idlwave-shell-mouse-nop) |
3283 |
|
(idlwave-shell-define-key-both |
3284 |
|
[(control meta mouse-2)] 'idlwave-shell-mouse-nop)) |
3285 |
|
|
3286 |
|
|
3287 |
;; The following set of bindings is used to bind the debugging keys. |
;; The following set of bindings is used to bind the debugging keys. |
3288 |
;; If `idlwave-shell-activate-prefix-keybindings' is non-nil, the first key |
;; If `idlwave-shell-activate-prefix-keybindings' is non-nil, the first key |
3289 |
;; in the list gets bound the C-c C-d prefix map. |
;; in the list gets bound the C-c C-d prefix map. |
3484 |
(let ((image-string "/* XPM */ |
(let ((image-string "/* XPM */ |
3485 |
static char * file[] = { |
static char * file[] = { |
3486 |
\"14 12 3 1\", |
\"14 12 3 1\", |
3487 |
\" c #FFFFFFFFFFFF s backgroundColor\", |
\" c None s backgroundColor\", |
3488 |
\". c #4B4B4B4B4B4B\", |
\". c #4B4B4B4B4B4B\", |
3489 |
\"R c #FFFF00000000\", |
\"R c #FFFF00000000\", |
3490 |
\" \", |
\" \", |
3507 |
((and (not (featurep 'xemacs)) |
((and (not (featurep 'xemacs)) |
3508 |
(fboundp 'image-type-available-p) |
(fboundp 'image-type-available-p) |
3509 |
(image-type-available-p 'xpm)) |
(image-type-available-p 'xpm)) |
3510 |
(list 'image :type 'xpm :data image-string)) |
(list 'image :type 'xpm :data image-string :ascent 'center)) |
3511 |
(t nil)))) |
(t nil)))) |
3512 |
|
|
3513 |
(provide 'idlw-shell) |
(provide 'idlw-shell) |