Mercurial > emacs
comparison lisp/progmodes/idlw-shell.el @ 76070:1029d540daf5
(idlwave-shell-mode): Clean up pending commands, for
restart. (idlwave-shell-current-module): Fix handling of module name by
type. (idlwave-shell-break-in): Update type handling.
(idlwave-shell-bp-get): Encode type in BP structure.
(idlwave-shell-set-bp): Fix setting condition on disabled BPs.
(idlwave-shell-module-source-query): Query routine info based on type.
Fix path parsing for non-compiled files.
(idlwave-shell-module-source-filter): Don't signal error in filter if no
source found. (idlwave-shell-set-bp-in-module): Use fallback source to
prevent filter race.
author | J.D. Smith <jdsmith@as.arizona.edu> |
---|---|
date | Thu, 22 Feb 2007 20:05:04 +0000 |
parents | e3694f1cb928 |
children | 9c80ddcdba82 |
comparison
equal
deleted
inserted
replaced
76069:898ccefda9ce | 76070:1029d540daf5 |
---|---|
1024 (set-marker comint-last-input-end (point)) | 1024 (set-marker comint-last-input-end (point)) |
1025 (setq idlwave-idlwave_routine_info-compiled nil) | 1025 (setq idlwave-idlwave_routine_info-compiled nil) |
1026 (setq idlwave-shell-ready nil) | 1026 (setq idlwave-shell-ready nil) |
1027 (setq idlwave-shell-bp-alist nil) | 1027 (setq idlwave-shell-bp-alist nil) |
1028 (idlwave-shell-update-bp-overlays) ; Throw away old overlays | 1028 (idlwave-shell-update-bp-overlays) ; Throw away old overlays |
1029 (setq idlwave-shell-sources-alist nil) | 1029 (setq idlwave-shell-post-command-hook nil ;clean up any old stuff |
1030 idlwave-shell-sources-alist nil) | |
1030 (setq idlwave-shell-default-directory default-directory) | 1031 (setq idlwave-shell-default-directory default-directory) |
1031 (setq idlwave-shell-hide-output nil) | 1032 (setq idlwave-shell-hide-output nil) |
1032 | 1033 |
1033 ;; NB: `make-local-hook' needed for older/alternative Emacs compatibility | 1034 ;; NB: `make-local-hook' needed for older/alternative Emacs compatibility |
1034 ;; (make-local-hook 'kill-buffer-hook) | 1035 ;; (make-local-hook 'kill-buffer-hook) |
1301 `idlwave-shell-pending-commands'. If PREEMPT is 'wait, wait for all | 1302 `idlwave-shell-pending-commands'. If PREEMPT is 'wait, wait for all |
1302 output to complete and the next prompt to arrive before returning | 1303 output to complete and the next prompt to arrive before returning |
1303 \(useful if you need an answer now\). IDL is considered ready if the | 1304 \(useful if you need an answer now\). IDL is considered ready if the |
1304 prompt is present and if `idlwave-shell-ready' is non-nil. | 1305 prompt is present and if `idlwave-shell-ready' is non-nil. |
1305 | 1306 |
1306 If SHOW-IF-ERROR is non-nil, show the output it it contains an error | 1307 If SHOW-IF-ERROR is non-nil, show the output if it contains an error |
1307 message, independent of what HIDE is set to." | 1308 message, independent of what HIDE is set to." |
1308 | 1309 |
1309 ; (setq hide nil) ; FIXME: turn this on for debugging only | 1310 ; (setq hide nil) ; FIXME: turn this on for debugging only |
1310 ; (if (null cmd) | 1311 ; (if (null cmd) |
1311 ; (progn | 1312 ; (progn |
2619 ;; In pro file | 2620 ;; In pro file |
2620 (save-restriction | 2621 (save-restriction |
2621 (widen) | 2622 (widen) |
2622 (save-excursion | 2623 (save-excursion |
2623 (if (idlwave-prev-index-position) | 2624 (if (idlwave-prev-index-position) |
2624 (upcase (idlwave-unit-name))))))) | 2625 (let* ((module (idlwave-what-module)) |
2626 (name (idlwave-make-full-name (nth 2 module) (car module))) | |
2627 (type (nth 1 module))) | |
2628 (list (upcase name) type))))))) | |
2625 | 2629 |
2626 (defun idlwave-shell-clear-current-bp () | 2630 (defun idlwave-shell-clear-current-bp () |
2627 "Remove breakpoint at current line. | 2631 "Remove breakpoint at current line. |
2628 This command can be called from the shell buffer if IDL is currently stopped | 2632 This command can be called from the shell buffer if IDL is currently stopped |
2629 at a breakpoint." | 2633 at a breakpoint." |
2632 (if bp (idlwave-shell-clear-bp bp)))) | 2636 (if bp (idlwave-shell-clear-bp bp)))) |
2633 | 2637 |
2634 | 2638 |
2635 (defun idlwave-shell-toggle-enable-current-bp (&optional bp force | 2639 (defun idlwave-shell-toggle-enable-current-bp (&optional bp force |
2636 no-update) | 2640 no-update) |
2637 "Disable or enable current bp." | 2641 "Disable or enable current breakpoint or a breakpoint passed in BP. |
2642 If FORCE is 'disable or 'enable, for that condition instead of | |
2643 toggling. If NO-UPDATE is non-nil, don't update the breakpoint | |
2644 list after toggling." | |
2638 (interactive) | 2645 (interactive) |
2639 (let* ((bp (or bp (idlwave-shell-find-current-bp))) | 2646 (let* ((bp (or bp (idlwave-shell-find-current-bp))) |
2640 (disabled (idlwave-shell-bp-get bp 'disabled))) | 2647 (disabled (idlwave-shell-bp-get bp 'disabled))) |
2641 (cond ((eq force 'disable) (setq disabled nil)) | 2648 (cond ((eq force 'disable) (setq disabled nil)) |
2642 ((eq force 'enable) (setq disabled t))) | 2649 ((eq force 'enable) (setq disabled t))) |
2683 "Look for a module name near point and set a break point for it. | 2690 "Look for a module name near point and set a break point for it. |
2684 The command looks for an identifier near point and sets a breakpoint | 2691 The command looks for an identifier near point and sets a breakpoint |
2685 for the first line of the corresponding module. If MODULE is `t', set | 2692 for the first line of the corresponding module. If MODULE is `t', set |
2686 in the current routine." | 2693 in the current routine." |
2687 (interactive) | 2694 (interactive) |
2688 (let ((module (idlwave-fix-module-if-obj_new (idlwave-what-module)))) | 2695 (let* ((module (idlwave-fix-module-if-obj_new (idlwave-what-module))) |
2696 (type (nth 1 module)) | |
2697 (name (car module)) | |
2698 (class (nth 2 module))) | |
2689 (if module | 2699 (if module |
2690 (progn | 2700 (progn |
2691 (setq module (idlwave-make-full-name (nth 2 module) (car module))) | 2701 (setq module (idlwave-make-full-name (nth 2 module) (car module))) |
2692 (idlwave-shell-module-source-query module) | 2702 (idlwave-shell-module-source-query module type) |
2693 (idlwave-shell-set-bp-in-module module)) | 2703 (idlwave-shell-set-bp-in-module name type class)) |
2694 (error "No identifier at point")))) | 2704 (error "No identifier at point")))) |
2695 | 2705 |
2696 | 2706 |
2697 (defun idlwave-shell-set-bp-in-module (module) | 2707 (defun idlwave-shell-set-bp-in-module (name type class) |
2698 "Set breakpoint in module. Assumes that `idlwave-shell-sources-alist' | 2708 "Set breakpoint in module. Assumes that `idlwave-shell-sources-alist' |
2699 contains an entry for that module." | 2709 contains an entry for that module." |
2700 (let ((source-file (car-safe | 2710 (let ((source-file |
2701 (cdr-safe | 2711 (car-safe (cdr-safe |
2702 (assoc (upcase module) | 2712 (or |
2703 idlwave-shell-sources-alist)))) | 2713 (assoc (upcase (idlwave-make-full-name class name)) |
2714 idlwave-shell-sources-alist) | |
2715 (nth 3 (idlwave-best-rinfo-assoc name type class | |
2716 (idlwave-routines))))))) | |
2704 buf) | 2717 buf) |
2705 (if (or (not source-file) | 2718 (if (or (not source-file) |
2706 (not (file-regular-p source-file)) | 2719 (not (file-regular-p source-file)) |
2707 (not (setq buf | 2720 (not (setq buf |
2708 (or (idlwave-get-buffer-visiting source-file) | 2721 (or (idlwave-get-buffer-visiting source-file) |
3374 `(progn | 3387 `(progn |
3375 (idlwave-shell-filter-bp (quote ,no-show))) | 3388 (idlwave-shell-filter-bp (quote ,no-show))) |
3376 'hide)) | 3389 'hide)) |
3377 | 3390 |
3378 (defun idlwave-shell-bp-get (bp &optional item) | 3391 (defun idlwave-shell-bp-get (bp &optional item) |
3379 "Get a value for a breakpoint. | 3392 "Get a value for a breakpoint. BP has the form of elements in |
3380 BP has the form of elements in idlwave-shell-bp-alist. Optional | 3393 idlwave-shell-bp-alist. Optional second arg ITEM is the |
3381 second arg ITEM is the particular value to retrieve. ITEM can be | 3394 particular value to retrieve. ITEM can be 'file, 'line, 'index, |
3382 'file, 'line, 'index, 'module, 'count, 'cmd, 'condition, 'disabled or | 3395 'module, 'count, 'cmd, 'condition, 'disabled, 'type, or |
3383 'data. 'data returns a list of 'count, 'cmd and 'condition. Defaults | 3396 'data. 'data returns a list of 'count, 'cmd and 'condition. |
3384 to 'index." | 3397 Defaults to 'index." |
3385 (cond | 3398 (cond |
3386 ;; Frame | 3399 ;; Frame |
3387 ((eq item 'line) (nth 1 (car bp))) | 3400 ((eq item 'line) (nth 1 (car bp))) |
3388 ((eq item 'file) (nth 0 (car bp))) | 3401 ((eq item 'file) (nth 0 (car bp))) |
3389 ;; idlwave-shell breakpoint data | 3402 ;; idlwave-shell breakpoint data |
3391 ((eq item 'count) (nth 0 (cdr (cdr bp)))) | 3404 ((eq item 'count) (nth 0 (cdr (cdr bp)))) |
3392 ((eq item 'cmd) (nth 1 (cdr (cdr bp)))) | 3405 ((eq item 'cmd) (nth 1 (cdr (cdr bp)))) |
3393 ((eq item 'condition) (nth 2 (cdr (cdr bp)))) | 3406 ((eq item 'condition) (nth 2 (cdr (cdr bp)))) |
3394 ((eq item 'disabled) (nth 3 (cdr (cdr bp)))) | 3407 ((eq item 'disabled) (nth 3 (cdr (cdr bp)))) |
3395 ;; IDL breakpoint info | 3408 ;; IDL breakpoint info |
3396 ((eq item 'module) (nth 1 (car (cdr bp)))) | 3409 ((eq item 'module) |
3410 (let ((module (nth 1 (car (cdr bp))))) | |
3411 (if (listp module) (car module) module))) | |
3412 ((eq item 'type) | |
3413 (let ((module (nth 1 (car (cdr bp))))) | |
3414 (if (listp module) (nth 1 module)))) | |
3397 ;; index - default | 3415 ;; index - default |
3398 (t (nth 0 (car (cdr bp)))))) | 3416 (t (nth 0 (car (cdr bp)))))) |
3399 | 3417 |
3400 (defun idlwave-shell-filter-bp (&optional no-show) | 3418 (defun idlwave-shell-filter-bp (&optional no-show) |
3401 "Get the breakpoints from `idlwave-shell-command-output'. Create | 3419 "Get the breakpoints from `idlwave-shell-command-output'. Create |
3484 (defun idlwave-shell-bp (frame &optional data module) | 3502 (defun idlwave-shell-bp (frame &optional data module) |
3485 "Create a breakpoint structure containing FRAME and DATA. Second | 3503 "Create a breakpoint structure containing FRAME and DATA. Second |
3486 and third args, DATA and MODULE, are optional. Returns a breakpoint | 3504 and third args, DATA and MODULE, are optional. Returns a breakpoint |
3487 of the format used in `idlwave-shell-bp-alist'. Can be used in commands | 3505 of the format used in `idlwave-shell-bp-alist'. Can be used in commands |
3488 attempting match a breakpoint in `idlwave-shell-bp-alist'." | 3506 attempting match a breakpoint in `idlwave-shell-bp-alist'." |
3489 (cons frame (cons (list nil module) data))) | 3507 (cons frame ;; (file line) |
3508 (cons (list nil module) ;; (index_id (module type) | module) | |
3509 data))) ;; (count command condition disabled) | |
3490 | 3510 |
3491 (defvar idlwave-shell-old-bp nil | 3511 (defvar idlwave-shell-old-bp nil |
3492 "List of breakpoints previous to setting a new breakpoint.") | 3512 "List of breakpoints previous to setting a new breakpoint.") |
3493 | 3513 |
3494 (defun idlwave-shell-sources-bp (bp) | 3514 (defun idlwave-shell-sources-bp (bp) |
3520 (idlwave-shell-filter-bp (quote ,no-show)) | 3540 (idlwave-shell-filter-bp (quote ,no-show)) |
3521 (setq idlwave-shell-old-bp idlwave-shell-bp-alist)) | 3541 (setq idlwave-shell-old-bp idlwave-shell-bp-alist)) |
3522 'hide) | 3542 'hide) |
3523 | 3543 |
3524 ;; Get sources for this routine in the sources list | 3544 ;; Get sources for this routine in the sources list |
3525 (idlwave-shell-module-source-query (idlwave-shell-bp-get bp 'module)) | 3545 (idlwave-shell-module-source-query (idlwave-shell-bp-get bp 'module) |
3546 (idlwave-shell-bp-get bp 'type)) | |
3526 (let* | 3547 (let* |
3527 ((arg (idlwave-shell-bp-get bp 'count)) | 3548 ((arg (idlwave-shell-bp-get bp 'count)) |
3528 (key (cond | 3549 (key (cond |
3529 ((not (and arg (numberp arg))) "") | 3550 ((not (and arg (numberp arg))) "") |
3530 ((= arg 1) | 3551 ((= arg 1) |
3533 (format ",after=%d" arg)))) | 3554 (format ",after=%d" arg)))) |
3534 (condition (idlwave-shell-bp-get bp 'condition)) | 3555 (condition (idlwave-shell-bp-get bp 'condition)) |
3535 (disabled (idlwave-shell-bp-get bp 'disabled)) | 3556 (disabled (idlwave-shell-bp-get bp 'disabled)) |
3536 (key (concat key | 3557 (key (concat key |
3537 (if condition (concat ",CONDITION=\"" condition "\"")))) | 3558 (if condition (concat ",CONDITION=\"" condition "\"")))) |
3538 (key (concat key (if disabled ",/DISABLE"))) | 3559 ;; IDL can't simultaneously set a condition and disable a |
3560 ;; breakpoint, but it does keep both of these when resetting | |
3561 ;; the same BP. We assume DISABLE and CONDITION are not set | |
3562 ;; together for a newly created breakpoint. | |
3563 (key (concat key (if (and disabled (not condition)) ",/DISABLE"))) | |
3539 (line (idlwave-shell-bp-get bp 'line))) | 3564 (line (idlwave-shell-bp-get bp 'line))) |
3540 (idlwave-shell-send-command | 3565 (idlwave-shell-send-command |
3541 (concat "breakpoint,'" | 3566 (concat "breakpoint,'" |
3542 (idlwave-shell-sources-bp bp) "'," | 3567 (idlwave-shell-sources-bp bp) "'," |
3543 (if (integerp line) (setq line (int-to-string line))) | 3568 (if (integerp line) (setq line (int-to-string line))) |
3934 "Alist of IDL procedure names and compiled source files. | 3959 "Alist of IDL procedure names and compiled source files. |
3935 Elements of the alist have the form: | 3960 Elements of the alist have the form: |
3936 | 3961 |
3937 (module name . (source-file-truename idlwave-internal-filename)).") | 3962 (module name . (source-file-truename idlwave-internal-filename)).") |
3938 | 3963 |
3939 (defun idlwave-shell-module-source-query (module) | 3964 (defun idlwave-shell-module-source-query (module &optional type) |
3940 "Determine the source file for a given module." | 3965 "Determine the source file for a given module. |
3966 Query as a function if TYPE set to something beside 'pro." | |
3941 (if module | 3967 (if module |
3942 (idlwave-shell-send-command | 3968 (idlwave-shell-send-command |
3943 (format "print,(routine_info('%s',/SOURCE)).PATH" module) | 3969 (format "print,(routine_info('%s',/SOURCE%s)).PATH" module |
3970 (if (eq type 'pro) "" ",/FUNCTIONS")) | |
3944 `(idlwave-shell-module-source-filter ,module) | 3971 `(idlwave-shell-module-source-filter ,module) |
3945 'hide))) | 3972 'hide 'wait))) |
3946 | 3973 |
3947 (defun idlwave-shell-module-source-filter (module) | 3974 (defun idlwave-shell-module-source-filter (module) |
3948 "Get module source, and update idlwave-shell-sources-alist." | 3975 "Get module source, and update idlwave-shell-sources-alist." |
3949 (let ((old (assoc (upcase module) idlwave-shell-sources-alist)) | 3976 (let ((old (assoc (upcase module) idlwave-shell-sources-alist)) |
3950 filename) | 3977 filename) |
3951 (if (string-match "\.PATH *[\n\r]\\([^\r\n]+\\)[\n\r]" | 3978 (when (string-match "\.PATH *[\n\r]\\([^%][^\r\n]+\\)[\n\r]" |
3952 idlwave-shell-command-output) | 3979 idlwave-shell-command-output) |
3953 (setq filename (substring idlwave-shell-command-output | 3980 (setq filename (substring idlwave-shell-command-output |
3954 (match-beginning 1) (match-end 1))) | 3981 (match-beginning 1) (match-end 1))) |
3955 (error "No file matching module found.")) | 3982 (if old |
3956 (if old | 3983 (setcdr old (list (idlwave-shell-file-name filename) filename)) |
3957 (setcdr old (list (idlwave-shell-file-name filename) filename)) | 3984 (setq idlwave-shell-sources-alist |
3958 (setq idlwave-shell-sources-alist | 3985 (append idlwave-shell-sources-alist |
3959 (append idlwave-shell-sources-alist | 3986 (list (cons (upcase module) |
3960 (list (cons (upcase module) | 3987 (list (idlwave-shell-file-name filename) |
3961 (list (idlwave-shell-file-name filename) | 3988 filename))))))))) |
3962 filename)))))))) | |
3963 | 3989 |
3964 (defun idlwave-shell-sources-query () | 3990 (defun idlwave-shell-sources-query () |
3965 "Determine source files for all IDL compiled procedures. | 3991 "Determine source files for all IDL compiled procedures. |
3966 Queries IDL using the string in `idlwave-shell-sources-query'." | 3992 Queries IDL using the string in `idlwave-shell-sources-query'." |
3967 (interactive) | 3993 (interactive) |
4099 (define-key idlwave-mode-map key hook) | 4125 (define-key idlwave-mode-map key hook) |
4100 (define-key idlwave-shell-mode-map key hook)) | 4126 (define-key idlwave-shell-mode-map key hook)) |
4101 | 4127 |
4102 ;(define-key idlwave-shell-mode-map "\M-?" 'comint-dynamic-list-completions) | 4128 ;(define-key idlwave-shell-mode-map "\M-?" 'comint-dynamic-list-completions) |
4103 ;(define-key idlwave-shell-mode-map "\t" 'comint-dynamic-complete) | 4129 ;(define-key idlwave-shell-mode-map "\t" 'comint-dynamic-complete) |
4130 | |
4104 (define-key idlwave-shell-mode-map "\C-w" 'comint-kill-region) | 4131 (define-key idlwave-shell-mode-map "\C-w" 'comint-kill-region) |
4105 (define-key idlwave-shell-mode-map "\t" 'idlwave-shell-complete) | 4132 (define-key idlwave-shell-mode-map "\t" 'idlwave-shell-complete) |
4106 (define-key idlwave-shell-mode-map "\M-\t" 'idlwave-shell-complete) | 4133 (define-key idlwave-shell-mode-map "\M-\t" 'idlwave-shell-complete) |
4107 (define-key idlwave-shell-mode-map "\C-c\C-s" 'idlwave-shell) | 4134 (define-key idlwave-shell-mode-map "\C-c\C-s" 'idlwave-shell) |
4108 (define-key idlwave-shell-mode-map "\C-c?" 'idlwave-routine-info) | 4135 (define-key idlwave-shell-mode-map "\C-c?" 'idlwave-routine-info) |