comparison lisp/progmodes/idlw-shell.el @ 83556:07774e5c3ff5

Merged from emacs@sv.gnu.org Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-619 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-620 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-621 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-622 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-623 Remove RCS keywords * emacs@sv.gnu.org/emacs--devo--0--patch-624 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-625 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-626 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-627 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-628 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-629 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-630 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-631 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-632 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-633 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-634 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-635 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-636 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-637 Remove RCS keywords * emacs@sv.gnu.org/emacs--devo--0--patch-638 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-639 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-640 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-641 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-642 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-643 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-644 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-645 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-646 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-647 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-648 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-649 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-197 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-198 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-199 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-200 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-201 Update from CVS: lisp/nnweb.el (nnweb-google-parse-1): Update parser. * emacs@sv.gnu.org/gnus--rel--5.10--patch-202 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-596
author Karoly Lorentey <karoly@lorentey.hu>
date Sat, 24 Feb 2007 19:26:54 +0000
parents b8d9a391daf3 9c80ddcdba82
children dc002877ce12
comparison
equal deleted inserted replaced
83555:053bf1a38bfa 83556:07774e5c3ff5
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 ((count (idlwave-shell-bp-get bp 'count))
3528 (key (cond
3529 ((not (and arg (numberp arg))) "")
3530 ((= arg 1)
3531 ",/once")
3532 ((> arg 1)
3533 (format ",after=%d" arg))))
3534 (condition (idlwave-shell-bp-get bp 'condition)) 3549 (condition (idlwave-shell-bp-get bp 'condition))
3535 (disabled (idlwave-shell-bp-get bp 'disabled)) 3550 (disabled (idlwave-shell-bp-get bp 'disabled))
3536 (key (concat key 3551 (key (concat (if (and count (numberp count))
3537 (if condition (concat ",CONDITION=\"" condition "\"")))) 3552 (cond
3538 (key (concat key (if disabled ",/DISABLE"))) 3553 ((= count 1) ",/once")
3554 ((> count 1) (format ",after=%d" count))))
3555 (if condition (concat ",CONDITION=\"" condition "\""))
3556 ;; IDL can't simultaneously set a condition/count
3557 ;; and disable a breakpoint, but it does keep both
3558 ;; of these when resetting the same BP. We assume
3559 ;; DISABLE and CONDITION/COUNT are not set
3560 ;; together for a newly created breakpoint.
3561 (if (and disabled (not condition) (not count))
3562 ",/DISABLE")))
3539 (line (idlwave-shell-bp-get bp 'line))) 3563 (line (idlwave-shell-bp-get bp 'line)))
3540 (idlwave-shell-send-command 3564 (idlwave-shell-send-command
3541 (concat "breakpoint,'" 3565 (concat "breakpoint,'"
3542 (idlwave-shell-sources-bp bp) "'," 3566 (idlwave-shell-sources-bp bp) "',"
3543 (if (integerp line) (setq line (int-to-string line))) 3567 (if (integerp line) (setq line (int-to-string line)))
3934 "Alist of IDL procedure names and compiled source files. 3958 "Alist of IDL procedure names and compiled source files.
3935 Elements of the alist have the form: 3959 Elements of the alist have the form:
3936 3960
3937 (module name . (source-file-truename idlwave-internal-filename)).") 3961 (module name . (source-file-truename idlwave-internal-filename)).")
3938 3962
3939 (defun idlwave-shell-module-source-query (module) 3963 (defun idlwave-shell-module-source-query (module &optional type)
3940 "Determine the source file for a given module." 3964 "Determine the source file for a given module.
3965 Query as a function if TYPE set to something beside 'pro."
3941 (if module 3966 (if module
3942 (idlwave-shell-send-command 3967 (idlwave-shell-send-command
3943 (format "print,(routine_info('%s',/SOURCE)).PATH" module) 3968 (format "print,(routine_info('%s',/SOURCE%s)).PATH" module
3969 (if (eq type 'pro) "" ",/FUNCTIONS"))
3944 `(idlwave-shell-module-source-filter ,module) 3970 `(idlwave-shell-module-source-filter ,module)
3945 'hide))) 3971 'hide 'wait)))
3946 3972
3947 (defun idlwave-shell-module-source-filter (module) 3973 (defun idlwave-shell-module-source-filter (module)
3948 "Get module source, and update idlwave-shell-sources-alist." 3974 "Get module source, and update idlwave-shell-sources-alist."
3949 (let ((old (assoc (upcase module) idlwave-shell-sources-alist)) 3975 (let ((old (assoc (upcase module) idlwave-shell-sources-alist))
3950 filename) 3976 filename)
3951 (if (string-match "\.PATH *[\n\r]\\([^\r\n]+\\)[\n\r]" 3977 (when (string-match "\.PATH *[\n\r]\\([^%][^\r\n]+\\)[\n\r]"
3952 idlwave-shell-command-output) 3978 idlwave-shell-command-output)
3953 (setq filename (substring idlwave-shell-command-output 3979 (setq filename (substring idlwave-shell-command-output
3954 (match-beginning 1) (match-end 1))) 3980 (match-beginning 1) (match-end 1)))
3955 (error "No file matching module found.")) 3981 (if old
3956 (if old 3982 (setcdr old (list (idlwave-shell-file-name filename) filename))
3957 (setcdr old (list (idlwave-shell-file-name filename) filename)) 3983 (setq idlwave-shell-sources-alist
3958 (setq idlwave-shell-sources-alist 3984 (append idlwave-shell-sources-alist
3959 (append idlwave-shell-sources-alist 3985 (list (cons (upcase module)
3960 (list (cons (upcase module) 3986 (list (idlwave-shell-file-name filename)
3961 (list (idlwave-shell-file-name filename) 3987 filename)))))))))
3962 filename))))))))
3963 3988
3964 (defun idlwave-shell-sources-query () 3989 (defun idlwave-shell-sources-query ()
3965 "Determine source files for all IDL compiled procedures. 3990 "Determine source files for all IDL compiled procedures.
3966 Queries IDL using the string in `idlwave-shell-sources-query'." 3991 Queries IDL using the string in `idlwave-shell-sources-query'."
3967 (interactive) 3992 (interactive)
4099 (define-key idlwave-mode-map key hook) 4124 (define-key idlwave-mode-map key hook)
4100 (define-key idlwave-shell-mode-map key hook)) 4125 (define-key idlwave-shell-mode-map key hook))
4101 4126
4102 ;(define-key idlwave-shell-mode-map "\M-?" 'comint-dynamic-list-completions) 4127 ;(define-key idlwave-shell-mode-map "\M-?" 'comint-dynamic-list-completions)
4103 ;(define-key idlwave-shell-mode-map "\t" 'comint-dynamic-complete) 4128 ;(define-key idlwave-shell-mode-map "\t" 'comint-dynamic-complete)
4129
4104 (define-key idlwave-shell-mode-map "\C-w" 'comint-kill-region) 4130 (define-key idlwave-shell-mode-map "\C-w" 'comint-kill-region)
4105 (define-key idlwave-shell-mode-map "\t" 'idlwave-shell-complete) 4131 (define-key idlwave-shell-mode-map "\t" 'idlwave-shell-complete)
4106 (define-key idlwave-shell-mode-map "\M-\t" 'idlwave-shell-complete) 4132 (define-key idlwave-shell-mode-map "\M-\t" 'idlwave-shell-complete)
4107 (define-key idlwave-shell-mode-map "\C-c\C-s" 'idlwave-shell) 4133 (define-key idlwave-shell-mode-map "\C-c\C-s" 'idlwave-shell)
4108 (define-key idlwave-shell-mode-map "\C-c?" 'idlwave-routine-info) 4134 (define-key idlwave-shell-mode-map "\C-c?" 'idlwave-routine-info)