emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/progmodes/idlw-shell.el [lexbind]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/progmodes/idlw-shell.el [lexbind]
Date: Wed, 08 Dec 2004 19:34:47 -0500

Index: emacs/lisp/progmodes/idlw-shell.el
diff -c emacs/lisp/progmodes/idlw-shell.el:3.15.2.6 
emacs/lisp/progmodes/idlw-shell.el:3.15.2.7
*** emacs/lisp/progmodes/idlw-shell.el:3.15.2.6 Fri Nov 12 04:21:21 2004
--- emacs/lisp/progmodes/idlw-shell.el  Wed Dec  8 23:31:44 2004
***************
*** 1,10 ****
  ;; idlw-shell.el --- run IDL as an inferior process of Emacs.
! ;; Copyright (c) 1999, 2000, 2001,2002 Free Software Foundation
  
! ;; Author: Carsten Dominik <address@hidden>
! ;;         Chris Chase <address@hidden>
  ;; Maintainer: J.D. Smith <address@hidden>
! ;; Version: 4.15
  ;; Keywords: processes
  
  ;; This file is part of GNU Emacs.
--- 1,11 ----
  ;; idlw-shell.el --- run IDL as an inferior process of Emacs.
! ;; Copyright (c) 1999,2000,2001,2002,2003,2004 Free Software Foundation
  
! ;; Authors: J.D. Smith <address@hidden>
! ;;          Carsten Dominik <address@hidden>
! ;;          Chris Chase <address@hidden>
  ;; Maintainer: J.D. Smith <address@hidden>
! ;; Version: 5.5
  ;; Keywords: processes
  
  ;; This file is part of GNU Emacs.
***************
*** 44,50 ****
  ;;
  ;; INSTALLATION:
  ;; =============
! ;;
  ;; Follow the instructions in the INSTALL file of the distribution.
  ;; In short, put this file on your load path and add the following
  ;; lines to your .emacs file:
--- 45,51 ----
  ;;
  ;; INSTALLATION:
  ;; =============
! ;; 
  ;; Follow the instructions in the INSTALL file of the distribution.
  ;; In short, put this file on your load path and add the following
  ;; lines to your .emacs file:
***************
*** 57,65 ****
  ;;
  ;;   The newest version of this file can be found on the maintainers
  ;;   web site.
! ;;
  ;;     http://idlwave.org
! ;;
  ;; DOCUMENTATION
  ;; =============
  ;;
--- 58,66 ----
  ;;
  ;;   The newest version of this file can be found on the maintainers
  ;;   web site.
! ;; 
  ;;     http://idlwave.org
! ;; 
  ;; DOCUMENTATION
  ;; =============
  ;;
***************
*** 76,82 ****
  ;; it is a bug in XEmacs.
  ;; The Debug menu in source buffers *does* display the bindings correctly.
  ;;
! ;;
  ;; CUSTOMIZATION VARIABLES
  ;; =======================
  ;;
--- 77,83 ----
  ;; it is a bug in XEmacs.
  ;; The Debug menu in source buffers *does* display the bindings correctly.
  ;;
! ;; 
  ;; CUSTOMIZATION VARIABLES
  ;; =======================
  ;;
***************
*** 100,111 ****
    (condition-case () (require 'custom) (error nil))
    (if (and (featurep 'custom)
           (fboundp 'custom-declare-variable)
!          (fboundp 'defface))
        ;; We've got what we needed
        (setq idlwave-shell-have-new-custom t)
      ;; We have the old or no custom-library, hack around it!
      (defmacro defgroup (&rest args) nil)
!     (defmacro defcustom (var value doc &rest args)
        `(defvar ,var ,value ,doc))))
  
  ;;; Customizations: idlwave-shell group
--- 101,112 ----
    (condition-case () (require 'custom) (error nil))
    (if (and (featurep 'custom)
           (fboundp 'custom-declare-variable)
!          (fboundp 'defface))     
        ;; We've got what we needed
        (setq idlwave-shell-have-new-custom t)
      ;; We have the old or no custom-library, hack around it!
      (defmacro defgroup (&rest args) nil)
!     (defmacro defcustom (var value doc &rest args) 
        `(defvar ,var ,value ,doc))))
  
  ;;; Customizations: idlwave-shell group
***************
*** 117,126 ****
    :group 'idlwave)
  
  (defcustom idlwave-shell-prompt-pattern "^ ?IDL> "
!   "*Regexp to match IDL prompt at beginning of a line.
! For example, \"^IDL> \" or \"^WAVE> \".
! The \"^\" means beginning of line.
! This variable is used to initialise `comint-prompt-regexp' in the
  process buffer.
  
  This is a fine thing to set in your `.emacs' file."
--- 118,127 ----
    :group 'idlwave)
  
  (defcustom idlwave-shell-prompt-pattern "^ ?IDL> "
!   "*Regexp to match IDL prompt at beginning of a line. 
! For example, \"^IDL> \" or \"^WAVE> \". 
! The \"^\" means beginning of line, and is required.
! This variable is used to initialize `comint-prompt-regexp' in the 
  process buffer.
  
  This is a fine thing to set in your `.emacs' file."
***************
*** 208,213 ****
--- 209,232 ----
    :group 'idlwave-shell-general-setup
    :type 'boolean)
  
+ (defcustom idlwave-shell-automatic-electric-debug 'breakpoint
+   "Enter the electric-debug minor mode automatically.  
+ This occurs at a breakpoint or any other halt.  The mode is exited
+ upon return to the main level.  Can be set to 'breakpoint to enter
+ electric debug mode only when breakpoints are tripped."
+   :group 'idlwave-shell-general-setup
+   :type '(choice
+         (const :tag "never" nil)
+         (const :tag "always" t)
+         (const :tag "for breakpoints only" breakpoint)))
+ 
+ (defcustom idlwave-shell-electric-zap-to-file t
+   "When entering electric debug mode, select the window displaying the
+ file at which point is stopped.  This takes point away from the shell
+ window, but is useful for stepping, etc."
+   :group 'idlwave-shell-general-setup
+   :type 'boolean)
+ 
  ;; (defcustom idlwave-shell-debug-modifiers... See idlwave.el
  
  (defvar idlwave-shell-activate-alt-keybindings nil
***************
*** 247,259 ****
          (integer :tag "x size")
          (integer :tag "y size")))
  
  ;; Commands Sent to Shell... etc.
  (defgroup idlwave-shell-command-setup nil
    "Setup for command parameters of the Shell interaction for IDLWAVE."
    :prefix "idlwave-shell"
    :group 'idlwave)
  
! (defcustom idlwave-shell-initial-commands "!more=0"
    "Initial commands, separated by newlines, to send to IDL.
  This string is sent to the IDL process by `idlwave-shell-mode' which is
  invoked by `idlwave-shell'."
--- 266,279 ----
          (integer :tag "x size")
          (integer :tag "y size")))
  
+ 
  ;; Commands Sent to Shell... etc.
  (defgroup idlwave-shell-command-setup nil
    "Setup for command parameters of the Shell interaction for IDLWAVE."
    :prefix "idlwave-shell"
    :group 'idlwave)
  
! (defcustom idlwave-shell-initial-commands "!more=0 & 
defsysv,'!ERROR_STATE',EXISTS=__e & if __e then begin & 
!ERROR_STATE.MSG_PREFIX=\"% \" & delvar,__e & endif"
    "Initial commands, separated by newlines, to send to IDL.
  This string is sent to the IDL process by `idlwave-shell-mode' which is
  invoked by `idlwave-shell'."
***************
*** 267,273 ****
    :group 'idlwave-shell-command-setup
    :type 'boolean)
  
! (defcustom idlwave-shell-command-history-file "~/.idlwhist"
    "The file in which the command history of the idlwave shell is saved.
  In order to change the size of the history, see the variable
  `comint-input-ring-size'.
--- 287,293 ----
    :group 'idlwave-shell-command-setup
    :type 'boolean)
  
! (defcustom idlwave-shell-command-history-file "idlwhist"
    "The file in which the command history of the idlwave shell is saved.
  In order to change the size of the history, see the variable
  `comint-input-ring-size'.
***************
*** 275,297 ****
  is non-nil."
    :group 'idlwave-shell-command-setup
    :type 'file)
! 
  (defcustom idlwave-shell-show-commands
    '(run misc breakpoint)
    "*A list of command types to show output from in the shell.
! Possibilities are 'run, 'debug, 'breakpoint, and 'misc .  Unlisted
! types are not displayed in the shell.  The single type 'everything
! causes all the copious shell traffic to be displayed."
    :group 'idlwave-shell-command-setup
    :type '(choice
          (const everything)
          (set :tag "Checklist" :greedy t
!              (const :tag "All .run and .compile commands"  run)
!              (const :tag "All breakpoint commands"         breakpoint)
!              (const :tag "All debug and stepping commands" debug)
!              (const :tag "Return, close, etc. commands"    misc))))
  
! (defcustom idlwave-shell-examine-alist
    '(("Print"                  . "print,___")
      ("Help"                   . "help,___")
      ("Structure Help"         . "help,___,/STRUCTURE")
--- 295,317 ----
  is non-nil."
    :group 'idlwave-shell-command-setup
    :type 'file)
!   
  (defcustom idlwave-shell-show-commands
    '(run misc breakpoint)
    "*A list of command types to show output from in the shell.
! Possibilities are 'run, 'debug, 'breakpoint, and 'misc.  Unselected
! types are not displayed in the shell.  The type 'everything causes all
! the copious shell traffic to be displayed."
    :group 'idlwave-shell-command-setup
    :type '(choice
          (const everything)
          (set :tag "Checklist" :greedy t
!              (const :tag "All .run and .compile commands"        run)  
!              (const :tag "All breakpoint commands"               breakpoint)
!              (const :tag "All debug and stepping commands"       debug)
!              (const :tag "Close, window, retall, etc. commands"  misc))))
  
! (defcustom idlwave-shell-examine-alist 
    '(("Print"                  . "print,___")
      ("Help"                   . "help,___")
      ("Structure Help"         . "help,___,/STRUCTURE")
***************
*** 302,315 ****
      ("Ptr Valid"              . "print,ptr_valid(___)")
      ("Widget Valid"     . "print,widget_info(___,/VALID)")
      ("Widget Geometry"  . "help,widget_info(___,/GEOMETRY)"))
!   "Alist of special examine commands for popup selection.
  The keys are used in the selection popup created by
  `idlwave-shell-examine-select', and the corresponding value is sent as
  a command to the shell, with special sequence `___' replaced by the
  expression being examined."
    :group 'idlwave-shell-command-setup
    :type '(repeat
!         (cons
           (string :tag "Label  ")
           (string :tag "Command"))))
  
--- 322,335 ----
      ("Ptr Valid"              . "print,ptr_valid(___)")
      ("Widget Valid"     . "print,widget_info(___,/VALID)")
      ("Widget Geometry"  . "help,widget_info(___,/GEOMETRY)"))
!   "Alist of special examine commands for popup selection.  
  The keys are used in the selection popup created by
  `idlwave-shell-examine-select', and the corresponding value is sent as
  a command to the shell, with special sequence `___' replaced by the
  expression being examined."
    :group 'idlwave-shell-command-setup
    :type '(repeat
!         (cons 
           (string :tag "Label  ")
           (string :tag "Command"))))
  
***************
*** 320,326 ****
    "*Non-nil mean, put output of examine commands in their own buffer."
    :group 'idlwave-shell-command-setup
    :type 'boolean)
! 
  (defcustom idlwave-shell-comint-settings
    '((comint-scroll-to-bottom-on-input . t)
      (comint-scroll-to-bottom-on-output . t)
--- 340,346 ----
    "*Non-nil mean, put output of examine commands in their own buffer."
    :group 'idlwave-shell-command-setup
    :type 'boolean)
!   
  (defcustom idlwave-shell-comint-settings
    '((comint-scroll-to-bottom-on-input . t)
      (comint-scroll-to-bottom-on-output . t)
***************
*** 353,359 ****
    '("^<onechar>$" "^<chars>$" "^</chars>$")
    "The three regular expressions which match the magic spells for input modes.
  
! When the first regexp matches in the output streem of IDL, IDLWAVE
  prompts for a single character and sends it immediately to IDL, similar
  to the command \\[idlwave-shell-send-char].
  
--- 373,379 ----
    '("^<onechar>$" "^<chars>$" "^</chars>$")
    "The three regular expressions which match the magic spells for input modes.
  
! When the first regexp matches in the output stream of IDL, IDLWAVE
  prompts for a single character and sends it immediately to IDL, similar
  to the command \\[idlwave-shell-send-char].
  
***************
*** 383,396 ****
    answer = GET_KBRD(1)
  
  Since the IDLWAVE shell defines the system variable `!IDLWAVE_VERSION',
! you could actually check if you are running under Emacs before printing
  the magic strings.  Here is a procedure which uses this.
  
  Usage:
  ======
  idlwave_char_input               ; Make IDLWAVE send one character
  idlwave_char_input,/on           ; Start the loop to send characters
! idlwave_char_input,/off          ; End the loop to send chracters
  
  
  pro idlwave_char_input,on=on,off=off
--- 403,416 ----
    answer = GET_KBRD(1)
  
  Since the IDLWAVE shell defines the system variable `!IDLWAVE_VERSION',
! you could actually check if you are running under Emacs before printing 
  the magic strings.  Here is a procedure which uses this.
  
  Usage:
  ======
  idlwave_char_input               ; Make IDLWAVE send one character
  idlwave_char_input,/on           ; Start the loop to send characters
! idlwave_char_input,/off          ; End the loop to send characters
  
  
  pro idlwave_char_input,on=on,off=off
***************
*** 400,406 ****
        if keyword_set(on) then         print,'<chars>' $
          else if keyword_set(off) then print,'</chars>' $
          else                          print,'<onechar>'
!   endif
  end"
    :group 'idlwave-shell-command-setup
    :type '(list
--- 420,426 ----
        if keyword_set(on) then         print,'<chars>' $
          else if keyword_set(off) then print,'</chars>' $
          else                          print,'<onechar>'
!   endif 
  end"
    :group 'idlwave-shell-command-setup
    :type '(list
***************
*** 453,458 ****
--- 473,497 ----
    :group 'idlwave-shell-highlighting-and-faces
    :type 'symbol)
  
+ (defcustom idlwave-shell-electric-stop-color "Violet"
+   "*The color for the default face or overlay arrow when stopped."
+   :group 'idlwave-shell-highlighting-and-faces
+   :type 'string)
+ 
+ (defcustom idlwave-shell-electric-stop-line-face 
+   (prog1
+       (copy-face 'modeline 'idlwave-shell-electric-stop-line-face)
+     (set-face-background 'idlwave-shell-electric-stop-line-face 
+                        idlwave-shell-electric-stop-color)
+     (condition-case nil
+       (set-face-foreground 'idlwave-shell-electric-stop-line-face nil)
+       (error nil)))
+   "*The face for `idlwave-shell-stop-line-overlay' when in electric debug 
mode.
+ Allows you to choose the font, color and other properties for the line
+ where IDL is stopped, when in Electric Debug Mode."
+   :group 'idlwave-shell-highlighting-and-faces
+   :type 'symbol)
+ 
  (defcustom idlwave-shell-mark-breakpoints t
    "*Non-nil means, mark breakpoints in the source files.
  Legal values are:
***************
*** 483,493 ****
      (defface idlwave-shell-bp-face
        '((((class color)) (:foreground "Black" :background "Pink"))
        (t (:underline t)))
!       "Face for highlighting lines-with-breakpoints."
        :group 'idlwave-shell-highlighting-and-faces)
    ;; Just copy the underline face to be on the safe side.
    (copy-face 'underline 'idlwave-shell-bp-face))
  
  (defcustom idlwave-shell-expression-face 'secondary-selection
    "*The face for `idlwave-shell-expression-overlay'.
  Allows you to choose the font, color and other properties for
--- 522,551 ----
      (defface idlwave-shell-bp-face
        '((((class color)) (:foreground "Black" :background "Pink"))
        (t (:underline t)))
!       "Face for highlighting lines with breakpoints."
        :group 'idlwave-shell-highlighting-and-faces)
    ;; Just copy the underline face to be on the safe side.
    (copy-face 'underline 'idlwave-shell-bp-face))
  
+ (defcustom idlwave-shell-disabled-breakpoint-face 
+   'idlwave-shell-disabled-bp-face
+   "*The face for disabled breakpoint lines in the source code.
+ Allows you to choose the font, color and other properties for
+ lines which have a breakpoint.  See also `idlwave-shell-mark-breakpoints'."
+   :group 'idlwave-shell-highlighting-and-faces
+   :type 'symbol)
+ 
+ (if idlwave-shell-have-new-custom
+     ;; We have the new customize - use it to define a customizable face
+     (defface idlwave-shell-disabled-bp-face
+       '((((class color)) (:foreground "Black" :background "gray"))
+       (t (:underline t)))
+       "Face for highlighting lines with breakpoints."
+       :group 'idlwave-shell-highlighting-and-faces)
+   ;; Just copy the underline face to be on the safe side.
+   (copy-face 'underline 'idlwave-shell-disabled-bp-face))
+ 
+ 
  (defcustom idlwave-shell-expression-face 'secondary-selection
    "*The face for `idlwave-shell-expression-overlay'.
  Allows you to choose the font, color and other properties for
***************
*** 508,538 ****
  (defvar comint-last-input-start)
  (defvar comint-last-input-end)
  
- (defvar idlwave-shell-temp-pro-file nil
-   "Absolute pathname for temporary IDL file for compiling regions")
- 
- (defvar idlwave-shell-temp-rinfo-save-file nil
-   "Absolute pathname for temporary IDL file save file for routine_info.
- This is used to speed up the reloading of the routine info procedure
- before use by the shell.")
- 
  (defun idlwave-shell-temp-file (type)
    "Return a temp file, creating it if necessary.
  
! TYPE is either `pro' or `rinfo', and `idlwave-shell-temp-pro-file' or
! `idlwave-shell-temp-rinfo-save-file' is set (respectively)."
!   (cond
     ((eq type 'rinfo)
!     (or idlwave-shell-temp-rinfo-save-file
!       (setq idlwave-shell-temp-rinfo-save-file
              (idlwave-shell-make-temp-file idlwave-shell-temp-pro-prefix))))
     ((eq type 'pro)
      (or idlwave-shell-temp-pro-file
!       (setq idlwave-shell-temp-pro-file
              (idlwave-shell-make-temp-file idlwave-shell-temp-pro-prefix))))
!    (t (error "Wrong argument (idlwave-shell-temp-file): %s"
             (symbol-name type)))))
! 
  
  (defun idlwave-shell-make-temp-file (prefix)
    "Create a temporary file."
--- 566,588 ----
  (defvar comint-last-input-start)
  (defvar comint-last-input-end)
  
  (defun idlwave-shell-temp-file (type)
    "Return a temp file, creating it if necessary.
  
! TYPE is either 'pro or 'rinfo, and idlwave-shell-temp-pro-file or
! idlwave-shell-temp-rinfo-save-file is set (respectively)."
!   (cond 
     ((eq type 'rinfo)
!     (or idlwave-shell-temp-rinfo-save-file 
!       (setq idlwave-shell-temp-rinfo-save-file 
              (idlwave-shell-make-temp-file idlwave-shell-temp-pro-prefix))))
     ((eq type 'pro)
      (or idlwave-shell-temp-pro-file
!       (setq idlwave-shell-temp-pro-file 
              (idlwave-shell-make-temp-file idlwave-shell-temp-pro-prefix))))
!    (t (error "Wrong argument (idlwave-shell-temp-file): %s" 
             (symbol-name type)))))
!     
  
  (defun idlwave-shell-make-temp-file (prefix)
    "Create a temporary file."
***************
*** 558,572 ****
        nil)
        file)))
  
  (defvar idlwave-shell-dirstack-query "cd,current=___cur & print,___cur"
!   "Command used by `idlwave-shell-resync-dirs' to query IDL for
  the directory stack.")
  
! (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+'>'"
!   "The command which gets !PATH and !DIR infor from the shell.")
  
  (defvar idlwave-shell-mode-line-info nil
!   "Additional info displayed in the mode line")
  
  (defvar idlwave-shell-default-directory nil
    "The default directory in the idlwave-shell buffer, of outside use.")
--- 608,634 ----
        nil)
        file)))
  
+ ;; Other variables
+ (defvar idlwave-shell-temp-pro-file
+   nil
+   "Absolute pathname for temporary IDL file for compiling regions")
+ 
+ (defvar idlwave-shell-temp-rinfo-save-file
+   nil
+   "Absolute pathname for temporary IDL file save file for routine_info.
+ This is used to speed up the reloading of the routine info procedure
+ before use by the shell.")
+ 
  (defvar idlwave-shell-dirstack-query "cd,current=___cur & print,___cur"
!   "Command used by `idlwave-shell-resync-dirs' to query IDL for 
  the directory stack.")
  
! (defvar idlwave-shell-path-query 
"print,'PATH:<'+transpose(expand_path(!PATH,/ARRAY))+'>' & 
print,'SYSDIR:<'+!dir+'>'"
! 
!   "The command which gets !PATH and !DIR info from the shell.")
  
  (defvar idlwave-shell-mode-line-info nil
!   "Additional info displayed in the mode line")  
  
  (defvar idlwave-shell-default-directory nil
    "The default directory in the idlwave-shell buffer, of outside use.")
***************
*** 617,623 ****
            window-system)                ; Window systems always
      (progn
        (setq idlwave-shell-stop-line-overlay (make-overlay 1 1))
!       (overlay-put idlwave-shell-stop-line-overlay
                   'face idlwave-shell-stop-line-face))))
  
   (t
--- 679,685 ----
            window-system)                ; Window systems always
      (progn
        (setq idlwave-shell-stop-line-overlay (make-overlay 1 1))
!       (overlay-put idlwave-shell-stop-line-overlay 
                   'face idlwave-shell-stop-line-face))))
  
   (t
***************
*** 625,631 ****
    (if window-system
        (progn
        (setq idlwave-shell-stop-line-overlay (make-overlay 1 1))
!       (overlay-put idlwave-shell-stop-line-overlay
                     'face idlwave-shell-stop-line-face)))))
  
  ;; Now the expression and output overlays
--- 687,693 ----
    (if window-system
        (progn
        (setq idlwave-shell-stop-line-overlay (make-overlay 1 1))
!       (overlay-put idlwave-shell-stop-line-overlay 
                     'face idlwave-shell-stop-line-face)))))
  
  ;; Now the expression and output overlays
***************
*** 652,658 ****
  
  (defvar idlwave-shell-hide-output nil
    "If non-nil the process output is not inserted into the output
!   buffer.")
  
  (defvar idlwave-shell-accumulation nil
    "Accumulate last line of output.")
--- 714,724 ----
  
  (defvar idlwave-shell-hide-output nil
    "If non-nil the process output is not inserted into the output
! buffer.")
! 
! (defvar idlwave-shell-show-if-error nil
!   "If non-nil the process output is inserted into the output buffer if
! it contains an error message, even if hide-output is non-nil.")
  
  (defvar idlwave-shell-accumulation nil
    "Accumulate last line of output.")
***************
*** 682,688 ****
  
  ;;; The following are the types of messages we attempt to catch to
  ;;; resync our idea of where IDL execution currently is.
! ;;;
  
  (defvar idlwave-shell-halt-frame nil
    "The frame associated with halt/breakpoint messages.")
--- 748,754 ----
  
  ;;; The following are the types of messages we attempt to catch to
  ;;; resync our idea of where IDL execution currently is.
! ;;; 
  
  (defvar idlwave-shell-halt-frame nil
    "The frame associated with halt/breakpoint messages.")
***************
*** 694,719 ****
    "The frame associated with trace messages.")
  
  (defconst idlwave-shell-halt-messages
!   '("^% Execution halted at"
!     "^% Interrupted at:"
      "^% Stepped to:"
!     "^% At "
      "^% Stop encountered:"
      )
    "*A list of regular expressions matching IDL messages.
  These are the messages containing file and line information where
  IDL is currently stopped.")
  
  (defconst idlwave-shell-halt-messages-re
    (mapconcat 'identity idlwave-shell-halt-messages "\\|")
    "The regular expression computed from idlwave-shell-halt-messages")
  
! (defconst idlwave-shell-trace-messages
!   '("^% At "    ;; First line of a trace message
!     )
!   "*A list of regular expressions matching IDL trace messages.
! These are the messages containing file and line information where
! IDL will begin looking for the next statement to execute.")
  
  (defconst idlwave-shell-step-messages
    '("^% Stepped to:"
--- 760,784 ----
    "The frame associated with trace messages.")
  
  (defconst idlwave-shell-halt-messages
!   '("^% Interrupted at:"
      "^% Stepped to:"
!     "^% Skipped to:"
      "^% Stop encountered:"
      )
    "*A list of regular expressions matching IDL messages.
  These are the messages containing file and line information where
  IDL is currently stopped.")
  
+ 
  (defconst idlwave-shell-halt-messages-re
    (mapconcat 'identity idlwave-shell-halt-messages "\\|")
    "The regular expression computed from idlwave-shell-halt-messages")
  
! (defconst idlwave-shell-trace-message-re
!   "^% At "    ;; First line of a trace message
!   "*A regular expression matching IDL trace messages.  These are the
! messages containing file and line information of a current
! traceback.")
  
  (defconst idlwave-shell-step-messages
    '("^% Stepped to:"
***************
*** 725,730 ****
--- 790,832 ----
  (defvar idlwave-shell-break-message "^% Breakpoint at:"
    "*Regular expression matching an IDL breakpoint message line.")
  
+ (defconst idlwave-shell-electric-debug-help
+   "   ==> IDLWAVE Electric Debug Mode Help <==
+  
+  Break Point Setting and Clearing:
+   b                Set breakpoint ([C-u b] for conditional, [C-n b] nth hit, 
etc.).
+   d                Clear nearby breakpoint.
+   a          Clear all breakpoints.
+   i                Set breakpoint in routine named here.
+   j          Set breakpoint at beginning of containing routine.
+   \\          Toggle breakpoint disable
+   ]          Go to next breakpoint in file.
+   [          Go to previous breakpoint in file.
+ 
+  Stepping, Continuing, and the Stack:
+   s or SPACE Step, into function calls.
+   n                Step, over function calls.
+   k                Skip one statement.
+   m                Continue to end of function.
+   o                Continue past end of function.
+   u                Continue to end of block.
+   h                Continue to line at cursor position.
+   r                Continue execution to next breakpoint, if any.
+   + or =     Show higher level in calling stack.
+   - or _     Show lower level in calling stack.
+ 
+  Examining Expressions (with prefix for examining the region):
+   p                Print expression near point or in region ([C-u p]).
+   ?          Help on expression near point or in region ([C-u ?]).
+   x          Examine expression near point or in region ([C-u x]) with 
+              letter completion of the examine type.
+ 
+  Miscellaneous:
+   q                Quit - end debugging session and return to the Shell's 
main level.
+   v                Turn Electric Debugging Mode off (C-c C-d C-v to return).
+   t                Print a calling-level traceback in the shell.
+   z                Reset IDL.
+   C-?        Show this help menu.")
  
  (defvar idlwave-shell-bp-alist)
  ;(defvar idlwave-shell-post-command-output)
***************
*** 768,785 ****
     `\\[idlwave-routine-info]' displays information about an IDL routine near 
point,
     just like in `idlwave-mode'.  The module used is the one at point or
     the one whose argument list is being edited.
!    To update IDLWAVE's knowledge about compiled or edited modules, use
     \\[idlwave-update-routine-info].
     \\[idlwave-find-module] find the source of a module.
     \\[idlwave-resolve] tells IDL to compile an unresolved module.
     \\[idlwave-context-help] shows the online help on the item at
     point, if online help has been installed.
! 
  
  4. Debugging
     ---------
     A complete set of commands for compiling and debugging IDL programs
!    is available from the menu.  Also keybindings starting with a
     `C-c C-d' prefix are available for most commands in the *idl* buffer
     and also in source buffers.  The best place to learn about the
     keybindings is again the menu.
--- 870,887 ----
     `\\[idlwave-routine-info]' displays information about an IDL routine near 
point,
     just like in `idlwave-mode'.  The module used is the one at point or
     the one whose argument list is being edited.
!    To update IDLWAVE's knowledge about compiled or edited modules, use 
     \\[idlwave-update-routine-info].
     \\[idlwave-find-module] find the source of a module.
     \\[idlwave-resolve] tells IDL to compile an unresolved module.
     \\[idlwave-context-help] shows the online help on the item at
     point, if online help has been installed.
!   
  
  4. Debugging
     ---------
     A complete set of commands for compiling and debugging IDL programs
!    is available from the menu.  Also keybindings starting with a 
     `C-c C-d' prefix are available for most commands in the *idl* buffer
     and also in source buffers.  The best place to learn about the
     keybindings is again the menu.
***************
*** 794,805 ****
     \\[idlwave-shell-resync-dirs] queries IDL in order to change Emacs current 
directory
     to correspond to the IDL process current directory.
  
! 5. Hooks
     -----
     Turning on `idlwave-shell-mode' runs `comint-mode-hook' and
     `idlwave-shell-mode-hook' (in that order).
  
! 6. Documentation and Customization
     -------------------------------
     Info documentation for this package is available.  Use \\[idlwave-info]
     to display (complain to your sysadmin if that does not work).
--- 896,919 ----
     \\[idlwave-shell-resync-dirs] queries IDL in order to change Emacs current 
directory
     to correspond to the IDL process current directory.
  
! 5. Expression Examination
!    ----------------------
! 
!    Expressions near point can be examined with print,
!    \\[idlwave-shell-print] or \\[idlwave-shell-mouse-print] with the
!    mouse, help, \\[idlwave-shell-help-expression] or
!    \\[idlwave-shell-mouse-help] with the mouse, or with a
!    configureable set of custom examine commands using
!    \\[idlwave-shell-examine-select].  The mouse examine commands can
!    also work by click and drag, to select an expression for
!    examination.
! 
! 6. Hooks
     -----
     Turning on `idlwave-shell-mode' runs `comint-mode-hook' and
     `idlwave-shell-mode-hook' (in that order).
  
! 7. Documentation and Customization
     -------------------------------
     Info documentation for this package is available.  Use \\[idlwave-info]
     to display (complain to your sysadmin if that does not work).
***************
*** 807,821 ****
     homepage at `http://idlwave.org'.
     IDLWAVE has customize support - see the group `idlwave'.
  
! 7. Keybindings
     -----------
  \\{idlwave-shell-mode-map}"
  
    (interactive)
    ;; We don't do `kill-all-local-variables' here, because this is done by
!   ;; comint - idlwave-shell-mode only add on top of that.
    (setq comint-prompt-regexp idlwave-shell-prompt-pattern)
    (setq comint-process-echoes t)
    ;; Can not use history expansion because "!" is used for system variables.
    (setq comint-input-autoexpand nil)
  ;  (setq comint-input-ring-size 64)
--- 921,942 ----
     homepage at `http://idlwave.org'.
     IDLWAVE has customize support - see the group `idlwave'.
  
! 8. Keybindings
     -----------
  \\{idlwave-shell-mode-map}"
  
    (interactive)
+   (idlwave-setup) ; Make sure config files and paths, etc. are available.
+   (unless (file-name-absolute-p idlwave-shell-command-history-file)
+     (setq idlwave-shell-command-history-file
+         (expand-file-name idlwave-shell-command-history-file
+                           idlwave-config-directory)))
+ 
    ;; We don't do `kill-all-local-variables' here, because this is done by
!   ;; comint
    (setq comint-prompt-regexp idlwave-shell-prompt-pattern)
    (setq comint-process-echoes t)
+ 
    ;; Can not use history expansion because "!" is used for system variables.
    (setq comint-input-autoexpand nil)
  ;  (setq comint-input-ring-size 64)
***************
*** 851,856 ****
--- 972,981 ----
          idlwave-shell-step-frame nil)
    (idlwave-shell-display-line nil)
    (setq idlwave-shell-calling-stack-index 0)
+   (setq idlwave-shell-only-prompt-pattern
+       (concat "\\`[ \t\n]*" 
+               (substring idlwave-shell-prompt-pattern 1) 
+               "[ \t\n]*\\'"))
  
    (when idlwave-shell-query-for-class
        (add-to-list (make-local-variable 'idlwave-determine-class-special)
***************
*** 884,889 ****
--- 1009,1037 ----
        (while (setq entry (pop list))
        (set (make-local-variable (car entry)) (cdr entry)))))
  
+   
+   (unless (memq 'comint-carriage-motion 
+               (default-value 'comint-output-filter-functions))
+     ;; Strip those pesky ctrl-m's.
+     (add-hook 'comint-output-filter-functions
+             (lambda (string)
+               (when (string-match "\r" string)
+                 (let ((pmark (process-mark (get-buffer-process 
+                                             (current-buffer)))))
+                   (save-excursion
+                     ;; bare CR -> delete preceding line
+                     (goto-char comint-last-output-start)
+                     (while (search-forward "\r" pmark t)
+                       (delete-region (point) (line-beginning-position)))))))
+               'append 'local)
+     (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m nil 
'local))
+ 
+   ;; Python-mode, bundled with many Emacs installs, quite cavalierly
+   ;; adds this function to the global default hook.  It interferes
+   ;; with overlay-arrows.
+   (remove-hook 'comint-output-filter-functions 'py-pdbtrack-track-stack-file)
+ 
+ 
    ;; IDLWAVE syntax, and turn on abbreviations
    (setq local-abbrev-table idlwave-mode-abbrev-table)
    (set-syntax-table idlwave-mode-syntax-table)
***************
*** 902,927 ****
      (if (file-regular-p idlwave-shell-command-history-file)
        (comint-read-input-ring)))
  
    ;; Run the hooks.
    (run-hooks 'idlwave-shell-mode-hook)
    (idlwave-shell-send-command idlwave-shell-initial-commands nil 'hide)
!   ;; Define a system variable which knows the version of IDLWAVE
!   (idlwave-shell-send-command
!    (format "defsysv,'!idlwave_version','%s',1" idlwave-mode-version)
     nil 'hide)
    (if (and (not idlwave-path-alist)
!          (not idlwave-sys-dir))
        (idlwave-shell-send-command idlwave-shell-path-query
                                  'idlwave-shell-get-path-info
                                  'hide)))
  
! (defun idlwave-shell-get-path-info ()
    (let* ((rpl (idlwave-shell-path-filter))
         (sysdir (car rpl))
!        (dirs (cdr rpl)))
!     (setq idlwave-sys-dir sysdir)
!     (setq idlwave-path-alist (mapcar (lambda(x) (cons x nil))
!                                    dirs))))
  
  (if (not (fboundp 'idl-shell))
      (fset 'idl-shell 'idlwave-shell))
--- 1050,1100 ----
      (if (file-regular-p idlwave-shell-command-history-file)
        (comint-read-input-ring)))
  
+   ;; Turn off the non-debug toolbar buttons (open,save,etc.)
+   (set (make-local-variable 'tool-bar-map) nil)
+ 
    ;; Run the hooks.
    (run-hooks 'idlwave-shell-mode-hook)
    (idlwave-shell-send-command idlwave-shell-initial-commands nil 'hide)
!   ;; Turn off IDL's ^d interpreting, and define a system
!   ;; variable which knows the version of IDLWAVE
!   (idlwave-shell-send-command 
!    (format "defsysv,'!idlwave_version','%s',1" 
!          idlwave-mode-version)
     nil 'hide)
+   ;; Get the paths if they weren't read in from file
    (if (and (not idlwave-path-alist)
!          (or (not (stringp idlwave-system-directory))
!              (eq (length idlwave-system-directory) 0)))
        (idlwave-shell-send-command idlwave-shell-path-query
                                  'idlwave-shell-get-path-info
                                  'hide)))
  
! (defun idlwave-shell-get-path-info (&optional no-write)
!   "Get the path lists, writing to file unless NO-WRITE is set."
    (let* ((rpl (idlwave-shell-path-filter))
         (sysdir (car rpl))
!        (dirs (cdr rpl))
!        (old-path-alist idlwave-path-alist))
!     (when sysdir
!       (setq idlwave-system-directory sysdir)
!       (put 'idlwave-system-directory 'from-shell t))
!     ;; Preserve any existing flags
!     (setq idlwave-path-alist 
!         (mapcar (lambda (x)
!                   (let ((old-entry (assoc x old-path-alist)))
!                     (if old-entry
!                         (cons x (cdr old-entry))
!                       (list x))))
!                 dirs))
!     (put 'idlwave-path-alist 'from-shell t)
!     (if idlwave-path-alist 
!       (if (and idlwave-auto-write-paths
!                (not idlwave-library-path)
!                (not no-write) )
!           (idlwave-write-paths))
!       ;; Fall back
!       (setq idlwave-path-alist old-path-alist))))
  
  (if (not (fboundp 'idl-shell))
      (fset 'idl-shell 'idlwave-shell))
***************
*** 951,958 ****
                         (frame (selected-frame)))
                     (catch 'exit
                       (while flist
!                        (if (not (eq (car flist)
!                                     idlwave-shell-idl-wframe))
                             (throw 'exit (car flist))
                           (setq flist (cdr flist))))))
                   (make-frame))
--- 1124,1131 ----
                         (frame (selected-frame)))
                     (catch 'exit
                       (while flist
!                        (if (not (eq (car flist) 
!                                     idlwave-shell-idl-wframe)) 
                             (throw 'exit (car flist))
                           (setq flist (cdr flist))))))
                   (make-frame))
***************
*** 970,978 ****
            ;; We do not have a source frame, so we use this one.
            (setq idlwave-shell-display-wframe (selected-frame)))
        ;; Return a new frame
!       (setq idlwave-shell-idl-wframe
              (make-frame idlwave-shell-frame-parameters)))))
! 
  ;;;###autoload
  (defun idlwave-shell (&optional arg quick)
    "Run an inferior IDL, with I/O through buffer `(idlwave-shell-buffer)'.
--- 1143,1151 ----
            ;; We do not have a source frame, so we use this one.
            (setq idlwave-shell-display-wframe (selected-frame)))
        ;; Return a new frame
!       (setq idlwave-shell-idl-wframe 
              (make-frame idlwave-shell-frame-parameters)))))
!   
  ;;;###autoload
  (defun idlwave-shell (&optional arg quick)
    "Run an inferior IDL, with I/O through buffer `(idlwave-shell-buffer)'.
***************
*** 999,1012 ****
          (delete-other-windows))
        (and idlwave-shell-use-dedicated-frame
             (setq idlwave-shell-idl-wframe (selected-frame)))
!       (add-hook 'idlwave-shell-sentinel-hook
                  'save-buffers-kill-emacs t))
  
      ;; A non-nil arg means, we want a dedicated frame.  This will last
      ;; for the current editing session.
      (if arg (setq idlwave-shell-use-dedicated-frame t))
      (if (equal arg '(16)) (setq idlwave-shell-use-dedicated-frame nil))
! 
      ;; Check if the process still exists.  If not, create it.
      (unless (comint-check-proc (idlwave-shell-buffer))
        (let* ((prg (or idlwave-shell-explicit-file-name "idl"))
--- 1172,1185 ----
          (delete-other-windows))
        (and idlwave-shell-use-dedicated-frame
             (setq idlwave-shell-idl-wframe (selected-frame)))
!       (add-hook 'idlwave-shell-sentinel-hook 
                  'save-buffers-kill-emacs t))
  
      ;; A non-nil arg means, we want a dedicated frame.  This will last
      ;; for the current editing session.
      (if arg (setq idlwave-shell-use-dedicated-frame t))
      (if (equal arg '(16)) (setq idlwave-shell-use-dedicated-frame nil))
!     
      ;; Check if the process still exists.  If not, create it.
      (unless (comint-check-proc (idlwave-shell-buffer))
        (let* ((prg (or idlwave-shell-explicit-file-name "idl"))
***************
*** 1031,1038 ****
        (if idlwave-shell-ready
          (raise-frame (window-frame window)))
        (if (eq (selected-frame) (window-frame window))
!         (select-window window))
!       )))
  
  (defun idlwave-shell-recenter-shell-window (&optional arg)
    "Run `idlwave-shell', but make sure the current window stays selected."
--- 1204,1219 ----
        (if idlwave-shell-ready
          (raise-frame (window-frame window)))
        (if (eq (selected-frame) (window-frame window))
!         (select-window window))))
!   ;; Save the paths at the end
!   (add-hook 'idlwave-shell-sentinel-hook 
!           (lambda ()
!             (if (and 
!                  idlwave-auto-write-paths
!                  idlwave-path-alist
!                  (not idlwave-library-path)
!                  (get 'idlwave-path-alist 'from-shell))
!                 (idlwave-write-paths)))))
  
  (defun idlwave-shell-recenter-shell-window (&optional arg)
    "Run `idlwave-shell', but make sure the current window stays selected."
***************
*** 1041,1074 ****
      (idlwave-shell arg)
      (select-window window)))
  
! (defun idlwave-shell-hide-p (type)
    "Whether to hide this type of command.
  Return either nil or 'hide."
    (if (listp idlwave-shell-show-commands)
!       (if (not (memq type idlwave-shell-show-commands)) 'hide)))
  
! (defun idlwave-shell-send-command (&optional cmd pcmd hide preempt)
    "Send a command to IDL process.
  
! \(CMD PCMD HIDE\) are placed at the end of
! ` idlwave-shell-pending-commands'.  If IDL is ready the first command,
  CMD, in `idlwave-shell-pending-commands' is sent to the IDL process.
  If optional second argument PCMD is non-nil it will be placed on
! `idlwave-shell-post-command-hook' when CMD is executed.  If the
! optional third argument HIDE is non-nil, then hide output from CMD.
  If optional fourth argument PREEMPT is non-nil CMD is put at front of
  `idlwave-shell-pending-commands'.  If PREEMPT is 'wait, wait for all
  output to complete and the next prompt to arrive before returning
  \(useful if you need an answer now\). IDL is considered ready if the
! prompt is present and if `idlwave-shell-ready' is non-nil."
  
  ;  (setq hide nil)  ;  FIXME: turn this on for debugging only
! ;  (if (null cmd)
  ;      (progn
! ;     (message "SENDING Pending commands: %s"
  ;              (prin1-to-string idlwave-shell-pending-commands)))
  ;    (message "SENDING %s|||%s" cmd pcmd))
!   (if (and (symbolp idlwave-shell-show-commands)
           (eq idlwave-shell-show-commands 'everything))
        (setq hide nil))
    (let ((save-buffer (current-buffer))
--- 1222,1277 ----
      (idlwave-shell arg)
      (select-window window)))
  
! (defun idlwave-shell-hide-p (type &optional list)
    "Whether to hide this type of command.
  Return either nil or 'hide."
+   (let ((list (or list idlwave-shell-show-commands)))
+     (if (listp list)
+       (if (not (memq type list)) 'hide))))
+ 
+ (defun idlwave-shell-add-or-remove-show (type)
+   "Add or remove a show command from the list."
    (if (listp idlwave-shell-show-commands)
!       (setq idlwave-shell-show-commands
!           (if (memq type idlwave-shell-show-commands)
!               (delq type idlwave-shell-show-commands)
!             (add-to-list'idlwave-shell-show-commands type)))
!     (setq idlwave-shell-show-commands (list type))))
  
! 
! (defun idlwave-shell-send-command (&optional cmd pcmd hide preempt 
!                                            show-if-error)
    "Send a command to IDL process.
  
! \(CMD PCMD HIDE\) are placed at the end of `
! idlwave-shell-pending-commands'.  If IDL is ready the first command,
  CMD, in `idlwave-shell-pending-commands' is sent to the IDL process.
+ 
  If optional second argument PCMD is non-nil it will be placed on
! `idlwave-shell-post-command-hook' when CMD is executed.
! 
! If the optional third argument HIDE is non-nil, then hide output from
! CMD, unless it is the symbol 'mostly, in which case only output
! beginning with \"%\" is hidden, and all other output (i.e., the
! results of a PRINT command), is shown.  This helps with, e.g.,
! stepping through code with output.
! 
  If optional fourth argument PREEMPT is non-nil CMD is put at front of
  `idlwave-shell-pending-commands'.  If PREEMPT is 'wait, wait for all
  output to complete and the next prompt to arrive before returning
  \(useful if you need an answer now\). IDL is considered ready if the
! prompt is present and if `idlwave-shell-ready' is non-nil.  
! 
! If SHOW-IF-ERROR is non-nil, show the output it it contains an error
! message, independent of what HIDE is set to."
  
  ;  (setq hide nil)  ;  FIXME: turn this on for debugging only
! ;  (if (null cmd) 
  ;      (progn
! ;     (message "SENDING Pending commands: %s" 
  ;              (prin1-to-string idlwave-shell-pending-commands)))
  ;    (message "SENDING %s|||%s" cmd pcmd))
!   (if (and (symbolp idlwave-shell-show-commands) 
           (eq idlwave-shell-show-commands 'everything))
        (setq hide nil))
    (let ((save-buffer (current-buffer))
***************
*** 1093,1103 ****
          (setq idlwave-shell-pending-commands
                (if preempt
                    ;; Put at front.
!                   (append (list (list cmd pcmd hide))
                            idlwave-shell-pending-commands)
                  ;; Put at end.
!                 (append idlwave-shell-pending-commands
!                         (list (list cmd pcmd hide))))))
        ;; Check if IDL ready
        (let ((save-point (point-marker)))
        (goto-char (process-mark proc))
--- 1296,1306 ----
          (setq idlwave-shell-pending-commands
                (if preempt
                    ;; Put at front.
!                   (append (list (list cmd pcmd hide show-if-error))
                            idlwave-shell-pending-commands)
                  ;; Put at end.
!                 (append idlwave-shell-pending-commands 
!                         (list (list cmd pcmd hide show-if-error))))))
        ;; Check if IDL ready
        (let ((save-point (point-marker)))
        (goto-char (process-mark proc))
***************
*** 1112,1118 ****
            (let* ((lcmd (car idlwave-shell-pending-commands))
                   (cmd (car lcmd))
                   (pcmd (nth 1 lcmd))
!                  (hide (nth 2 lcmd)))
              ;; If this is an executive command, reset the stack pointer
              (if (eq (string-to-char cmd) ?.)
                  (setq idlwave-shell-calling-stack-index 0))
--- 1315,1322 ----
            (let* ((lcmd (car idlwave-shell-pending-commands))
                   (cmd (car lcmd))
                   (pcmd (nth 1 lcmd))
!                  (hide (nth 2 lcmd))
!                  (show-if-error (nth 3 lcmd)))
              ;; If this is an executive command, reset the stack pointer
              (if (eq (string-to-char cmd) ?.)
                  (setq idlwave-shell-calling-stack-index 0))
***************
*** 1120,1125 ****
--- 1324,1331 ----
              (setq idlwave-shell-post-command-hook pcmd)
              ;; Output hiding
              (setq idlwave-shell-hide-output hide)
+             ;;Showing errors
+             (setq idlwave-shell-show-if-error show-if-error)
              ;; Pop command
              (setq idlwave-shell-pending-commands
                    (cdr idlwave-shell-pending-commands))
***************
*** 1142,1148 ****
      (if (or (not (setq buf (get-buffer (idlwave-shell-buffer))))
            (not (setq proc (get-buffer-process buf))))
        (funcall errf "Shell is not running"))
!     (if (equal c ?\C-g)
        (funcall errf "Abort")
        (comint-send-string proc (char-to-string c)))))
  
--- 1348,1354 ----
      (if (or (not (setq buf (get-buffer (idlwave-shell-buffer))))
            (not (setq proc (get-buffer-process buf))))
        (funcall errf "Shell is not running"))
!     (if (equal c ?\C-g)       
        (funcall errf "Abort")
        (comint-send-string proc (char-to-string c)))))
  
***************
*** 1183,1189 ****
      (if idlwave-shell-ready
        (funcall errf "No IDL program seems to be waiting for input"))
  
!     ;; OK, start the loop
      (message "Character mode on:  Sending single chars (`C-g' to exit)")
      (message
       (catch 'exit
--- 1389,1395 ----
      (if idlwave-shell-ready
        (funcall errf "No IDL program seems to be waiting for input"))
  
!     ;; OK, start the loop 
      (message "Character mode on:  Sending single chars (`C-g' to exit)")
      (message
       (catch 'exit
***************
*** 1224,1231 ****
      (if (and idlwave-shell-arrows-do-history
             (>= (1+ (save-excursion (end-of-line) (point))) proc-pos))
        (progn
!         (goto-char proc-pos)
!         (and (not (eolp)) (kill-line nil))
          (comint-previous-input arg))
        (previous-line arg))))
  
--- 1430,1438 ----
      (if (and idlwave-shell-arrows-do-history
             (>= (1+ (save-excursion (end-of-line) (point))) proc-pos))
        (progn
!         ;;(goto-char proc-pos)
!         (goto-char (point-max))
!         ;;(and (not (eolp)) (kill-line nil))
          (comint-previous-input arg))
        (previous-line arg))))
  
***************
*** 1252,1295 ****
    "Return t if the shell process is running."
    (eq (process-status idlwave-shell-process-name) 'run))
  
  (defvar idlwave-shell-hidden-output-buffer " *idlwave-shell-hidden-output*"
    "Buffer containing hidden output from IDL commands.")
! 
  (defun idlwave-shell-filter (proc string)
!   "Replace Carriage returns in output. Watch for prompt.
  When the IDL prompt is received executes `idlwave-shell-post-command-hook'
  and then calls `idlwave-shell-send-command' for any pending commands."
    ;; We no longer do the cleanup here - this is done by the process sentinel
    (when (eq (process-status idlwave-shell-process-name) 'run)
      ;; OK, process is still running, so we can use it.
!     (let ((data (match-data)) p)
        (unwind-protect
            (progn
!             ;; May change the original match data.
!           (while (setq p (string-match "\C-M" string))
!             (aset string p ?\  ))
! 
!             ;;
!             ;; Keep output
! 
! ; Should not keep output because the concat is costly.  If hidden put
! ; the output in a hide-buffer.  Then when the output is needed in post
! ; processing can access either the hide buffer or the idlwave-shell
! ; buffer.  Then watching for the prompt is easier.  Furthermore, if it
! ; is hidden and there is no post command, could throw away output.
! ;           (setq idlwave-shell-command-output
! ;                 (concat idlwave-shell-command-output string))
!             ;; Insert the string. Do this before getting the
!             ;; state.
            (while (setq p (string-match "\C-G" string))
              (ding)
              (aset string p ?\C-j ))
              (if idlwave-shell-hide-output
!                 (save-excursion
!                   (set-buffer
!                    (get-buffer-create idlwave-shell-hidden-output-buffer))
!                   (goto-char (point-max))
!                   (insert string))
              (idlwave-shell-comint-filter proc string))
              ;; Watch for magic - need to accumulate the current line
              ;; since it may not be sent all at once.
--- 1459,1504 ----
    "Return t if the shell process is running."
    (eq (process-status idlwave-shell-process-name) 'run))
  
+ (defvar idlwave-shell-only-prompt-pattern nil)
+ (defun idlwave-shell-filter-hidden-output (output)
+   "Filter hidden output, leaving the good stuff.
+ 
+ Remove everything to the first newline, and all lines with % in front
+ of them, with optional follow-on lines starting with two spaces.  This
+ works well enough, since any print output typically arrives before
+ error messages, etc."
+   (setq output (substring output (string-match "\n" output)))
+   (while (string-match "\\(\n\\|\\`\\)%.*\\(\n  .*\\)*" output)
+     (setq output (replace-match "" nil t output)))
+   (unless 
+       (string-match idlwave-shell-only-prompt-pattern output)
+     output))
+ 
  (defvar idlwave-shell-hidden-output-buffer " *idlwave-shell-hidden-output*"
    "Buffer containing hidden output from IDL commands.")
!   
  (defun idlwave-shell-filter (proc string)
!   "Watch for IDL prompt and filter incoming text.
  When the IDL prompt is received executes `idlwave-shell-post-command-hook'
  and then calls `idlwave-shell-send-command' for any pending commands."
    ;; We no longer do the cleanup here - this is done by the process sentinel
    (when (eq (process-status idlwave-shell-process-name) 'run)
      ;; OK, process is still running, so we can use it.
!     (let ((data (match-data)) p full-output)
        (unwind-protect
            (progn
!           ;; Ring the bell if necessary
            (while (setq p (string-match "\C-G" string))
              (ding)
              (aset string p ?\C-j ))
              (if idlwave-shell-hide-output
!               (save-excursion
!                 (while (setq p (string-match "\C-M" string))
!                   (aset string p ?\  ))
!                 (set-buffer
!                  (get-buffer-create idlwave-shell-hidden-output-buffer))
!                 (goto-char (point-max))
!                 (insert string))
              (idlwave-shell-comint-filter proc string))
              ;; Watch for magic - need to accumulate the current line
              ;; since it may not be sent all at once.
***************
*** 1299,1337 ****
                      (idlwave-shell-input-mode-magic
                       (concat idlwave-shell-accumulation string)))
                  (setq idlwave-shell-accumulation
!                       (substring string
!                                  (progn (string-match "\\(.*\n\\)*" string)
                                          (match-end 0)))))
                (setq idlwave-shell-accumulation
                      (concat idlwave-shell-accumulation string)))
! 
! 
  ;;; Test/Debug code
! ;          (save-excursion (set-buffer
! ;                           (get-buffer-create "*idlwave-shell-output*"))
! ;                          (goto-char (point-max))
! ;                          (insert "\nSTRING===>\n" string "\n<====\n"))
! 
            ;; Check for prompt in current accumulating output
            (if (setq idlwave-shell-ready
                      (string-match idlwave-shell-prompt-pattern
                                    idlwave-shell-accumulation))
                (progn
                  (if idlwave-shell-hide-output
                      (save-excursion
                        (set-buffer idlwave-shell-hidden-output-buffer)
                        (goto-char (point-max))
                        (re-search-backward idlwave-shell-prompt-pattern nil t)
                        (goto-char (match-end 0))
                        (setq idlwave-shell-command-output
                              (buffer-substring (point-min) (point)))
- 
- ;;; Test/Debug
- ;                      (save-excursion (set-buffer
- ;                                       (get-buffer-create 
"*idlwave-shell-output*"))
- ;                                      (goto-char (point-max))
- ;                                      (insert "\nOUPUT===>\n" 
idlwave-shell-command-output "\n<===\n"))
- 
                        (delete-region (point-min) (point)))
                      (setq idlwave-shell-command-output
                          (with-current-buffer (process-buffer proc)
--- 1508,1542 ----
                      (idlwave-shell-input-mode-magic
                       (concat idlwave-shell-accumulation string)))
                  (setq idlwave-shell-accumulation
!                       (substring string 
!                                  (progn (string-match "\\(.*[\n\r]+\\)*" 
!                                                       string)
                                          (match-end 0)))))
                (setq idlwave-shell-accumulation
                      (concat idlwave-shell-accumulation string)))
!           
!           
  ;;; Test/Debug code
! ;           (save-excursion (set-buffer
! ;                            (get-buffer-create "*idlwave-shell-output*"))
! ;                           (goto-char (point-max))
! ;                           (insert "\nSTRING===>\n" string "\n<====\n"))
!           
            ;; Check for prompt in current accumulating output
            (if (setq idlwave-shell-ready
                      (string-match idlwave-shell-prompt-pattern
                                    idlwave-shell-accumulation))
                (progn
+                 ;; Gather the command output
                  (if idlwave-shell-hide-output
                      (save-excursion
                        (set-buffer idlwave-shell-hidden-output-buffer)
+                       (setq full-output (buffer-string))
                        (goto-char (point-max))
                        (re-search-backward idlwave-shell-prompt-pattern nil t)
                        (goto-char (match-end 0))
                        (setq idlwave-shell-command-output
                              (buffer-substring (point-min) (point)))
                        (delete-region (point-min) (point)))
                      (setq idlwave-shell-command-output
                          (with-current-buffer (process-buffer proc)
***************
*** 1342,1363 ****
                               (point))
                             comint-last-input-end))))
  
!                   ;; Scan for state and do post command - bracket them
!                   ;; with idlwave-shell-ready=nil since they
!                   ;; may call idlwave-shell-send-command.
                    (let ((idlwave-shell-ready nil))
!                     (idlwave-shell-scan-for-state)
!                     ;; Unset idlwave-shell-ready to prevent sending
!                     ;; commands to IDL while running hook.
                      (if (listp idlwave-shell-post-command-hook)
!                         (eval idlwave-shell-post-command-hook)
                        (funcall idlwave-shell-post-command-hook))
!                     ;; Reset to default state for next command.
                      ;; Also we do not want to find this prompt again.
                      (setq idlwave-shell-accumulation nil
                            idlwave-shell-command-output nil
                            idlwave-shell-post-command-hook nil
                            idlwave-shell-hide-output nil
                          idlwave-shell-wait-for-output nil))
                    ;; Done with post command. Do pending command if
                    ;; any.
--- 1547,1588 ----
                               (point))
                             comint-last-input-end))))
  
!                   ;; Scan for state and do post commands - bracket
!                   ;; them with idlwave-shell-ready=nil since they may
!                   ;; call idlwave-shell-send-command themselves.
                    (let ((idlwave-shell-ready nil))
!                   (idlwave-shell-scan-for-state)
!                   ;; Show the output in the shell if it contains an error
!                   (if idlwave-shell-hide-output
!                       (if (and idlwave-shell-show-if-error
!                                (eq idlwave-shell-current-state 'error))
!                           (idlwave-shell-comint-filter proc full-output)
!                         ;; If it's only *mostly* hidden, filter % lines, 
!                         ;; and show anything that remains
!                         (if (eq idlwave-shell-hide-output 'mostly)
!                             (let ((filtered
!                                    (idlwave-shell-filter-hidden-output 
!                                     full-output)))
!                               (if filtered 
!                                   (idlwave-shell-comint-filter 
!                                    proc filtered))))))
!                   
!                   ;; Call the post-command hook
                      (if (listp idlwave-shell-post-command-hook)
!                         (progn
!                         ;(message "Calling list")
!                         ;(prin1 idlwave-shell-post-command-hook)
!                         (eval idlwave-shell-post-command-hook))
!                     ;(message "Calling command function")
                        (funcall idlwave-shell-post-command-hook))
! 
!                   ;; Reset to default state for next command.
                      ;; Also we do not want to find this prompt again.
                      (setq idlwave-shell-accumulation nil
                            idlwave-shell-command-output nil
                            idlwave-shell-post-command-hook nil
                            idlwave-shell-hide-output nil
+                         idlwave-shell-show-if-error nil
                          idlwave-shell-wait-for-output nil))
                    ;; Done with post command. Do pending command if
                    ;; any.
***************
*** 1369,1375 ****
  ;                              (get-buffer-create "*idlwave-shell-output*"))
  ;                             (goto-char (point-max))
  ;                             (insert "\n<=== WAITING ON OUTPUT ==>\n"))
!                 (accept-process-output proc nil 100))))
          (store-match-data data)))))
  
  (defun idlwave-shell-sentinel (process event)
--- 1594,1600 ----
  ;                              (get-buffer-create "*idlwave-shell-output*"))
  ;                             (goto-char (point-max))
  ;                             (insert "\n<=== WAITING ON OUTPUT ==>\n"))
!                 (accept-process-output proc 1))))
          (store-match-data data)))))
  
  (defun idlwave-shell-sentinel (process event)
***************
*** 1386,1392 ****
            (condition-case nil
                (comint-write-input-ring)
              (error nil)))))
! 
      (when (and (> (length (frame-list)) 1)
               (frame-live-p idlwave-shell-idl-wframe))
        (delete-frame idlwave-shell-idl-wframe)
--- 1611,1617 ----
            (condition-case nil
                (comint-write-input-ring)
              (error nil)))))
!           
      (when (and (> (length (frame-list)) 1)
               (frame-live-p idlwave-shell-idl-wframe))
        (delete-frame idlwave-shell-idl-wframe)
***************
*** 1403,1470 ****
          (run-hooks 'idlwave-shell-sentinel-hook))
        (run-hooks 'idlwave-shell-sentinel-hook))))
  
  (defun idlwave-shell-scan-for-state ()
!   "Scan for state info.
! Looks for messages in output from last IDL command indicating where
! IDL has stopped. The types of messages we are interested in are
! execution halted, stepped, breakpoint, interrupted at and trace
! messages.  We ignore error messages otherwise.
! For breakpoint messages process any attached count or command
! parameters.
! Update the windows if a message is found."
!   (cond
!    ;; Make sure we have output
!    ((not idlwave-shell-command-output))
! 
!    ;; First Priority: Syntax and other errors
!    ((or
!      (string-match idlwave-shell-syntax-error idlwave-shell-command-output)
!      (string-match idlwave-shell-other-error idlwave-shell-command-output))
!     (save-excursion
!       (set-buffer
!        (get-buffer-create idlwave-shell-error-buffer))
!       (erase-buffer)
!       (insert idlwave-shell-command-output)
!       (goto-char (point-min))
!       (setq idlwave-shell-error-last (point)))
!     (idlwave-shell-goto-next-error))
  
!    ;; Second Priority: Various types of HALT messages.
!    ((string-match idlwave-shell-halt-messages-re
!                 idlwave-shell-command-output)
!     ;; Grab the file and line state info.
!     (setq idlwave-shell-calling-stack-index 0)
!     (setq idlwave-shell-halt-frame
!         (idlwave-shell-parse-line
!          (substring idlwave-shell-command-output (match-end 0))))
!     (idlwave-shell-display-line (idlwave-shell-pc-frame)))
! 
!    ;; Last Priority: Breakpoints
!    ((string-match idlwave-shell-break-message
!                 idlwave-shell-command-output)
!     (setq idlwave-shell-calling-stack-index 0)
!     (setq idlwave-shell-halt-frame
!         (idlwave-shell-parse-line
!          (substring idlwave-shell-command-output (match-end 0))))
!     ;; We used to count hits on breakpoints
!     ;; this is no longer supported since IDL breakpoints
!     ;; have learned counting.
!     ;; Do breakpoint command processing
!     (let ((bp (assoc
!              (list
!               (nth 0 idlwave-shell-halt-frame)
!               (nth 1 idlwave-shell-halt-frame))
!              idlwave-shell-bp-alist)))
!       (if bp
!         (let ((cmd (idlwave-shell-bp-get bp 'cmd)))
!           (if cmd
!               ;; Execute command
!               (if (listp cmd) (eval cmd) (funcall cmd))))
!       ;; A breakpoint that we did not know about - perhaps it was
!       ;; set by the user or IDL isn't reporting breakpoints like
!       ;; we expect.  Lets update our list.
!       (idlwave-shell-bp-query)))
!     (idlwave-shell-display-line (idlwave-shell-pc-frame)))))
  
  (defvar idlwave-shell-error-buffer " *idlwave-shell-errors*"
    "Buffer containing syntax errors from IDL compilations.")
--- 1628,1726 ----
          (run-hooks 'idlwave-shell-sentinel-hook))
        (run-hooks 'idlwave-shell-sentinel-hook))))
  
+ (defvar idlwave-shell-current-state nil)
  (defun idlwave-shell-scan-for-state ()
!   "Scan for state info.  Looks for messages in output from last IDL
! command indicating where IDL has stopped. The types of messages we are
! interested in are execution halted, stepped, breakpoint, interrupted
! at and trace messages.  For breakpoint messages process any attached
! count or command parameters.  Update the stop line if a message is
! found.  The variable `idlwave-shell-current-state' is set to 'error,
! 'halt, or 'breakpoint, which describes the status, or nil for none of
! the above."
!   (let (trace)
!     (cond
!      ;; Make sure we have output
!      ((not idlwave-shell-command-output))
!      
!      ;; First Priority: Syntax and other errors
!      ((or 
!        (string-match idlwave-shell-syntax-error
!                    idlwave-shell-command-output)
!        (string-match idlwave-shell-other-error
!                    idlwave-shell-command-output))
!       (save-excursion
!       (set-buffer
!        (get-buffer-create idlwave-shell-error-buffer))
!       (erase-buffer)
!       (insert idlwave-shell-command-output)
!       (goto-char (point-min))
!       (setq idlwave-shell-error-last (point)))
!       (setq idlwave-shell-current-state 'error)
!       (idlwave-shell-goto-next-error))
!    
!      ;; Second Priority: Halting errors
!      ((string-match idlwave-shell-halting-error
!                   idlwave-shell-command-output)
!       ;; Grab the file and line state info.
!       (setq idlwave-shell-calling-stack-index 0)
!       (setq idlwave-shell-halt-frame
!           (idlwave-shell-parse-line 
!            (substring idlwave-shell-command-output 
!                       (match-beginning 2)))
!           idlwave-shell-current-state 'error)
!       (idlwave-shell-display-line (idlwave-shell-pc-frame)))
!      
!      ;; Third Priority: Various types of innocuous HALT and
!      ;; TRACEBACK messages.
!      ((or (setq trace (string-match idlwave-shell-trace-message-re
!                                   idlwave-shell-command-output))
!         (string-match idlwave-shell-halt-messages-re
!                       idlwave-shell-command-output))
!       ;; Grab the file and line state info.
!       (setq idlwave-shell-calling-stack-index 0)
!       (setq idlwave-shell-halt-frame
!           (idlwave-shell-parse-line 
!            (substring idlwave-shell-command-output (match-end 0))))
!       (setq idlwave-shell-current-state 'halt)
!       ;; Don't debug trace messages
!       (idlwave-shell-display-line (idlwave-shell-pc-frame) nil
!                                 (if trace 'no-debug)))
!      
!      ;; Fourth Priority: Breakpoints 
!      ((string-match idlwave-shell-break-message
!                   idlwave-shell-command-output)
!       (setq idlwave-shell-calling-stack-index 0)
!       (setq idlwave-shell-halt-frame 
!           (idlwave-shell-parse-line 
!            (substring idlwave-shell-command-output (match-end 0))))
!       ;; We used to count hits on breakpoints
!       ;; this is no longer supported since IDL breakpoints
!       ;; have learned counting.
!       ;; Do breakpoint command processing
!       (let ((bp (assoc 
!                (list
!                 (nth 0 idlwave-shell-halt-frame)
!                 (nth 1 idlwave-shell-halt-frame))
!                idlwave-shell-bp-alist)))
!       ;(message "Scanning with %s" bp)
!       (if bp
!           (let ((cmd (idlwave-shell-bp-get bp 'cmd)))
!             (if cmd ;; Execute any breakpoint command
!                 (if (listp cmd) (eval cmd) (funcall cmd))))
!         ;; A breakpoint that we did not know about - perhaps it was
!         ;; set by the user...  Let's update our list.
!         (idlwave-shell-bp-query)))
!       (setq idlwave-shell-current-state 'breakpoint)      
!       (idlwave-shell-display-line (idlwave-shell-pc-frame)))
!      
!      ;; Last Priority: Can't Step errors
!      ((string-match idlwave-shell-cant-continue-error
!                   idlwave-shell-command-output)
!       (setq idlwave-shell-current-state 'breakpoint))
  
!      ;; Otherwise, no particular state
!      (t (setq idlwave-shell-current-state nil)))))
  
  (defvar idlwave-shell-error-buffer " *idlwave-shell-errors*"
    "Buffer containing syntax errors from IDL compilations.")
***************
*** 1473,1493 ****
  ;; in module and file names.  I am not sure if it will be necessary to
  ;; change this.  Currently it seems to work the way it is.
  (defvar idlwave-shell-syntax-error
!   "^% Syntax error.\\s-*\n\\s-*At:\\s-*\\(.*\\),\\s-*Line\\s-*\\(.*\\)"
!   "A regular expression to match an IDL syntax error.
! The first \(..\) pair should match the file name.  The second pair
! should match the line number.")
  
  (defvar idlwave-shell-other-error
    "^% .*\n\\s-*At:\\s-*\\(.*\\),\\s-*Line\\s-*\\(.*\\)"
!   "A regular expression to match any IDL error.
! The first \(..\) pair should match the file name.  The second pair
! should match the line number.")
  
  (defvar idlwave-shell-file-line-message
!   (concat
     "\\("                                 ; program name group (1)
!    "\\<[a-zA-Z][a-zA-Z0-9_$:]*"          ; start with a letter, followed by 
[..]
     "\\([ \t]*\n[ \t]*[a-zA-Z0-9_$:]+\\)*"; continuation lines program name (2)
     "\\)"                                 ; end program name group (1)
     "[ \t\n]+"                            ; white space
--- 1729,1756 ----
  ;; in module and file names.  I am not sure if it will be necessary to
  ;; change this.  Currently it seems to work the way it is.
  (defvar idlwave-shell-syntax-error
!   "^% Syntax error.\\s-*\n\\s-*At:\\s-*\\(.*\\),\\s-*Line\\s-*\\(.*\\)" 
!   "A regular expression to match an IDL syntax error.  
! The 1st pair matches the file name, the second pair matches the line
! number.")
  
  (defvar idlwave-shell-other-error
    "^% .*\n\\s-*At:\\s-*\\(.*\\),\\s-*Line\\s-*\\(.*\\)"
!   "A regular expression to match any IDL error.")
! 
! (defvar idlwave-shell-halting-error 
!   "^% .*\n\\([^%].*\n\\)*% Execution halted 
at:\\(\\s-*\\S-+\\s-*[0-9]+\\s-*.*\\)\n"
!   "A regular expression to match errors which halt execution.")
! 
! (defvar idlwave-shell-cant-continue-error 
!   "^% Can't continue from this point.\n"
!   "A regular expression to match errors stepping errors.")
  
  (defvar idlwave-shell-file-line-message
!   (concat 
     "\\("                                 ; program name group (1)
!    "\\$MAIN\\$\\|"                     ; main level routine
!    "\\<[a-zA-Z][a-zA-Z0-9_$:]*"          ; start with a letter followed by 
[..]
     "\\([ \t]*\n[ \t]*[a-zA-Z0-9_$:]+\\)*"; continuation lines program name (2)
     "\\)"                                 ; end program name group (1)
     "[ \t\n]+"                            ; white space
***************
*** 1502,1520 ****
     "\\)"                                 ; end line number group (5)
     )
    "*A regular expression to parse out the file name and line number.
! The 1st group should match the subroutine name.
  The 3rd group is the line number.
  The 5th group is the file name.
  All parts may contain linebreaks surrounded by spaces.  This is important
  in IDL5 which inserts random linebreaks in long module and file names.")
  
! (defun idlwave-shell-parse-line (string)
    "Parse IDL message for the subroutine, file name and line number.
  We need to work hard here to remove the stupid line breaks inserted by
  IDL5.  These line breaks can be right in the middle of procedure
  or file names.
  It is very difficult to come up with a robust solution.  This one seems
! to be pretty good though.
  
  Here is in what ways it improves over the previous solution:
  
--- 1765,1783 ----
     "\\)"                                 ; end line number group (5)
     )
    "*A regular expression to parse out the file name and line number.
! The 1st group should match the subroutine name.  
  The 3rd group is the line number.
  The 5th group is the file name.
  All parts may contain linebreaks surrounded by spaces.  This is important
  in IDL5 which inserts random linebreaks in long module and file names.")
  
! (defun idlwave-shell-parse-line (string &optional skip-main)
    "Parse IDL message for the subroutine, file name and line number.
  We need to work hard here to remove the stupid line breaks inserted by
  IDL5.  These line breaks can be right in the middle of procedure
  or file names.
  It is very difficult to come up with a robust solution.  This one seems
! to be pretty good though.  
  
  Here is in what ways it improves over the previous solution:
  
***************
*** 1528,1542 ****
  However, the function checks the existence of the files with and
  without this last part - thus the function only breaks if file name
  plus garbage match an existing regular file.  This is hopefully very
! unlikely."
  
    (let (number procedure file)
!     (when (and (not (string-match ":\\s-*\\$MAIN" string))
!               (string-match idlwave-shell-file-line-message string))
        (setq procedure (match-string 1 string)
            number (match-string 3 string)
            file (match-string 5 string))
! 
        ;; Repair the strings
        (setq procedure (idlwave-shell-repair-string procedure))
        (setq number (idlwave-shell-repair-string number))
--- 1791,1808 ----
  However, the function checks the existence of the files with and
  without this last part - thus the function only breaks if file name
  plus garbage match an existing regular file.  This is hopefully very
! unlikely.
! 
! If optional arg SKIP-MAIN is non-nil, don't parse $MAIN$ routine stop
! statements."
  
    (let (number procedure file)
!     (when (and (not (if skip-main (string-match ":\\s-*\\$MAIN" string)))
!              (string-match idlwave-shell-file-line-message string))
        (setq procedure (match-string 1 string)
            number (match-string 3 string)
            file (match-string 5 string))
!       
        ;; Repair the strings
        (setq procedure (idlwave-shell-repair-string procedure))
        (setq number (idlwave-shell-repair-string number))
***************
*** 1562,1568 ****
  file name."
    (let ((file1 "") (file2 "") (start 0))
      ;; We scan no further than to the next "^%" line
!     (if (string-match "^%" file)
        (setq file (substring file 0 (match-beginning 0))))
      ;; Take out the line breaks
      (while (string-match "[ \t]*\n[ \t]*" file start)
--- 1828,1834 ----
  file name."
    (let ((file1 "") (file2 "") (start 0))
      ;; We scan no further than to the next "^%" line
!     (if (string-match "^%" file) 
        (setq file (substring file 0 (match-beginning 0))))
      ;; Take out the line breaks
      (while (string-match "[ \t]*\n[ \t]*" file start)
***************
*** 1617,1626 ****
  The size is given by `idlwave-shell-graphics-window-size'."
    (interactive "P")
    (let ((n (if n (prefix-numeric-value n) 0)))
!     (idlwave-shell-send-command
       (apply 'format "window,%d,xs=%d,ys=%d"
            n idlwave-shell-graphics-window-size)
!      nil (idlwave-shell-hide-p 'misc))))
  
  (defun idlwave-shell-resync-dirs ()
    "Resync the buffer's idea of the current directory.
--- 1883,1892 ----
  The size is given by `idlwave-shell-graphics-window-size'."
    (interactive "P")
    (let ((n (if n (prefix-numeric-value n) 0)))
!     (idlwave-shell-send-command 
       (apply 'format "window,%d,xs=%d,ys=%d"
            n idlwave-shell-graphics-window-size)
!      nil (idlwave-shell-hide-p 'misc) nil t)))
  
  (defun idlwave-shell-resync-dirs ()
    "Resync the buffer's idea of the current directory.
***************
*** 1633,1646 ****
                              'hide 'wait))
  
  (defun idlwave-shell-retall (&optional arg)
!   "Return from the entire calling stack."
    (interactive "P")
!   (idlwave-shell-send-command "retall" nil (idlwave-shell-hide-p 'misc)))
  
  (defun idlwave-shell-closeall (&optional arg)
    "Close all open files."
    (interactive "P")
!   (idlwave-shell-send-command "close,/all" nil (idlwave-shell-hide-p 'misc)))
  
  (defun idlwave-shell-quit (&optional arg)
    "Exit the idl process after confirmation.
--- 1899,1919 ----
                              'hide 'wait))
  
  (defun idlwave-shell-retall (&optional arg)
!   "Return from the entire calling stack.
! Also get rid of widget events in the queue."
    (interactive "P")
!   (save-selected-window
!     ;;if (widget_info(/MANAGED))[0] gt 0 then for 
i=0,n_elements(widget_info(/MANAGED))-1 do 
widget_control,(widget_info(/MANAGED))[i],/clear_events & 
!     (idlwave-shell-send-command "retall" nil 
!                               (if (idlwave-shell-hide-p 'misc) 'mostly) 
!                               nil t)
!     (idlwave-shell-display-line nil)))
  
  (defun idlwave-shell-closeall (&optional arg)
    "Close all open files."
    (interactive "P")
!   (idlwave-shell-send-command "close,/all" nil 
!                             (idlwave-shell-hide-p 'misc) nil t))
  
  (defun idlwave-shell-quit (&optional arg)
    "Exit the idl process after confirmation.
***************
*** 1655,1661 ****
  
  (defun idlwave-shell-reset (&optional hidden)
    "Reset IDL.  Return to main level and destroy the leftover variables.
! This issues the following commands:
  RETALL
  WIDGET_CONTROL,/RESET
  CLOSE, /ALL
--- 1928,1934 ----
  
  (defun idlwave-shell-reset (&optional hidden)
    "Reset IDL.  Return to main level and destroy the leftover variables.
! This issues the following commands:  
  RETALL
  WIDGET_CONTROL,/RESET
  CLOSE, /ALL
***************
*** 1691,1697 ****
    (let ((text idlwave-shell-command-output)
        (start 0)
        sep sep-re file type spec specs name cs key keys class entry)
! ;    (message "GOT: %s" text) ;??????????????????????
      ;; Initialize variables
      (setq idlwave-compiled-routines nil
          idlwave-unresolved-routines nil)
--- 1964,1970 ----
    (let ((text idlwave-shell-command-output)
        (start 0)
        sep sep-re file type spec specs name cs key keys class entry)
!     ;;    (message "GOT: %s" text) ;??????????????????????
      ;; Initialize variables
      (setq idlwave-compiled-routines nil
          idlwave-unresolved-routines nil)
***************
*** 1704,1715 ****
              text (substring text (match-end 0)))
        ;; Set dummy values and kill the text
        (setq sep "@" sep-re "@ *" text "")
!       (message "Routine Info warning: No match for BEGIN line in 
\n>>>>\n%s\n<<<<\n"
!              idlwave-shell-command-output))
      (if (string-match "^>>>END OF IDLWAVE ROUTINE INFO.*" text)
        (setq text (substring text 0 (match-beginning 0)))
!       (message "Routine Info warning: No match for END line in 
\n>>>>\n%s\n<<<<\n"
!              idlwave-shell-command-output))
      (if (string-match "\\S-" text)
        ;; Obviously, the pro worked.  Make a note that we have it now.
        (setq idlwave-idlwave_routine_info-compiled t))
--- 1977,1992 ----
              text (substring text (match-end 0)))
        ;; Set dummy values and kill the text
        (setq sep "@" sep-re "@ *" text "")
!       (if idlwave-idlwave_routine_info-compiled
!         (message 
!          "Routine Info warning: No match for BEGIN line in \n>>>\n%s\n<<<\n" 
!          idlwave-shell-command-output)))
      (if (string-match "^>>>END OF IDLWAVE ROUTINE INFO.*" text)
        (setq text (substring text 0 (match-beginning 0)))
!       (if idlwave-idlwave_routine_info-compiled
!         (message 
!          "Routine Info warning: No match for END line in \n>>>\n%s\n<<<\n" 
!          idlwave-shell-command-output)))
      (if (string-match "\\S-" text)
        ;; Obviously, the pro worked.  Make a note that we have it now.
        (setq idlwave-idlwave_routine_info-compiled t))
***************
*** 1726,1780 ****
            key (nth 4 specs)
            keys (if (and (stringp key)
                          (not (string-match "\\` *\\'" key)))
!                    (mapcar 'list
                             (delete "" (idlwave-split-string key " +")))))
        (setq name (idlwave-sintern-routine-or-method name class t)
            class (idlwave-sintern-class class t)
            file (if (equal file "") nil file)
!           keys (mapcar (lambda (x)
                           (list (idlwave-sintern-keyword (car x) t))) keys))
!       ;; Make sure we use the same string object for the same file
!       (setq file (idlwave-sintern-file file t))
!       ;; FIXME: What should I do with routines from the temp file???
!       ;;        Maybe just leave it in - there is a chance that the
!       ;;        routine is still in there.
!       ;;      (if (equal file idlwave-shell-temp-pro-file)
!       ;;        (setq file nil))
! 
        ;; In the following ignore routines already defined in buffers,
        ;; assuming that if the buffer stuff differs, it is a "new"
!       ;; version.
        ;; We could do the same for the library to avoid duplicates -
        ;; but I think frequently a user might have several versions of
!       ;; the same function in different programs, and in this case the
!       ;; compiled one will be the best guess of all version.
        ;; Therefore, we leave duplicates of library routines in.
- 
        (cond ((string= name "$MAIN$"))    ; ignore this one
            ((and (string= type "PRO")
                  ;; FIXME: is it OK to make the buffer routines dominate?
                  (or t (null file)
!                     (not (idlwave-rinfo-assq name 'pro class
                                               idlwave-buffer-routines)))
                  ;; FIXME: is it OK to make the library routines dominate?
!                 ;;(not (idlwave-rinfo-assq name 'pro class
                  ;;                       idlwave-library-routines))
                  )
!            (setq entry (list name 'pro class (cons 'compiled file) cs keys))
!            (if file
                 (push entry idlwave-compiled-routines)
               (push entry idlwave-unresolved-routines)))
! 
            ((and (string= type "FUN")
                  ;; FIXME: is it OK to make the buffer routines dominate?
                  (or t (not file)
!                     (not (idlwave-rinfo-assq name 'fun class
                                               idlwave-buffer-routines)))
                  ;; FIXME: is it OK to make the library routines dominate?
!                 ;; (not (idlwave-rinfo-assq name 'fun class
                  ;;                       idlwave-library-routines))
                  )
!            (setq entry (list name 'fun class (cons 'compiled file) cs keys))
             (if file
                 (push entry idlwave-compiled-routines)
               (push entry idlwave-unresolved-routines))))))
--- 2003,2063 ----
            key (nth 4 specs)
            keys (if (and (stringp key)
                          (not (string-match "\\` *\\'" key)))
!                    (mapcar 'list 
                             (delete "" (idlwave-split-string key " +")))))
        (setq name (idlwave-sintern-routine-or-method name class t)
            class (idlwave-sintern-class class t)
            file (if (equal file "") nil file)
!           keys (mapcar (lambda (x) 
                           (list (idlwave-sintern-keyword (car x) t))) keys))
!       
        ;; In the following ignore routines already defined in buffers,
        ;; assuming that if the buffer stuff differs, it is a "new"
!       ;; version, not yet compiled, and should take precedence.
        ;; We could do the same for the library to avoid duplicates -
        ;; but I think frequently a user might have several versions of
!       ;; the same function in different programs, and in this case the 
!       ;; compiled one will be the best guess of all versions.
        ;; Therefore, we leave duplicates of library routines in.
        (cond ((string= name "$MAIN$"))    ; ignore this one
            ((and (string= type "PRO")
                  ;; FIXME: is it OK to make the buffer routines dominate?
                  (or t (null file)
!                     (not (idlwave-rinfo-assq name 'pro class 
                                               idlwave-buffer-routines)))
                  ;; FIXME: is it OK to make the library routines dominate?
!                 ;;(not (idlwave-rinfo-assq name 'pro class 
                  ;;                       idlwave-library-routines))
                  )
!            (setq entry (list name 'pro class 
!                              (cons 'compiled 
!                                    (if file
!                                        (list
!                                         (file-name-nondirectory file)
!                                         (idlwave-sintern-dir 
!                                          (file-name-directory file)))))
!                              cs (cons nil keys)))
!            (if file 
                 (push entry idlwave-compiled-routines)
               (push entry idlwave-unresolved-routines)))
!           
            ((and (string= type "FUN")
                  ;; FIXME: is it OK to make the buffer routines dominate?
                  (or t (not file)
!                     (not (idlwave-rinfo-assq name 'fun class 
                                               idlwave-buffer-routines)))
                  ;; FIXME: is it OK to make the library routines dominate?
!                 ;; (not (idlwave-rinfo-assq name 'fun class 
                  ;;                       idlwave-library-routines))
                  )
!            (setq entry (list name 'fun class 
!                              (cons 'compiled
!                                    (if file
!                                        (list
!                                         (file-name-nondirectory file)
!                                         (idlwave-sintern-dir 
!                                          (file-name-directory file)))))
!                              cs (cons nil keys)))
             (if file
                 (push entry idlwave-compiled-routines)
               (push entry idlwave-unresolved-routines))))))
***************
*** 1789,1795 ****
      (set-buffer (idlwave-shell-buffer))
      (if (string-match ",___cur[\n\r]\\(\\S-*\\) *[\n\r]"
                      idlwave-shell-command-output)
!       (let ((dir (substring idlwave-shell-command-output
                              (match-beginning 1) (match-end 1))))
  ;       (message "Setting Emacs working dir to %s" dir)
          (setq idlwave-shell-default-directory dir)
--- 2072,2078 ----
      (set-buffer (idlwave-shell-buffer))
      (if (string-match ",___cur[\n\r]\\(\\S-*\\) *[\n\r]"
                      idlwave-shell-command-output)
!       (let ((dir (substring idlwave-shell-command-output 
                              (match-beginning 1) (match-end 1))))
  ;       (message "Setting Emacs working dir to %s" dir)
          (setq idlwave-shell-default-directory dir)
***************
*** 1803,1812 ****
        expression)
      (save-excursion
        (goto-char apos)
!       (setq expression (buffer-substring
                        (catch 'exit
                          (while t
!                           (if (not (re-search-backward
                                      "[^][.A-Za-z0-9_() ]" bos t))
                                (throw 'exit bos)) ;ran into bos
                            (if (not (idlwave-is-pointer-dereference bol))
--- 2086,2095 ----
        expression)
      (save-excursion
        (goto-char apos)
!       (setq expression (buffer-substring 
                        (catch 'exit
                          (while t
!                           (if (not (re-search-backward 
                                      "[^][.A-Za-z0-9_() ]" bos t))
                                (throw 'exit bos)) ;ran into bos
                            (if (not (idlwave-is-pointer-dereference bol))
***************
*** 1820,1842 ****
         'hide 'wait)
        ;; If we don't know anything about the class, update shell routines
        (if (and idlwave-shell-get-object-class
!              (not (assoc-string idlwave-shell-get-object-class
!                                 (idlwave-class-alist) t)))
          (idlwave-shell-maybe-update-routine-info))
        idlwave-shell-get-object-class)))
  
  (defun idlwave-shell-parse-object-class ()
    "Parse the output of the obj_class command."
!   (let ((match "print,obj_class([^\n\r]+[\n\r ]+"))
      (if (and
         (not (string-match (concat match match "\\s-*^[\n\r]+"
                                    "% Syntax error")
                            idlwave-shell-command-output))
         (string-match (concat match "\\([A-Za-z_0-9]+\\)")
                       idlwave-shell-command-output))
!       (setq idlwave-shell-get-object-class
              (match-string 1 idlwave-shell-command-output)))))
  
  
  (defun idlwave-shell-complete (&optional arg)
    "Do completion in the idlwave-shell buffer.
--- 2103,2127 ----
         'hide 'wait)
        ;; If we don't know anything about the class, update shell routines
        (if (and idlwave-shell-get-object-class
!              (not (assoc-ignore-case idlwave-shell-get-object-class
!                                      (idlwave-class-alist))))
          (idlwave-shell-maybe-update-routine-info))
        idlwave-shell-get-object-class)))
  
  (defun idlwave-shell-parse-object-class ()
    "Parse the output of the obj_class command."
!   (let ((match "print,obj_class([^\n\r]+[\n\r ]"))
      (if (and
         (not (string-match (concat match match "\\s-*^[\n\r]+"
                                    "% Syntax error")
                            idlwave-shell-command-output))
         (string-match (concat match "\\([A-Za-z_0-9]+\\)")
                       idlwave-shell-command-output))
!       (setq idlwave-shell-get-object-class 
              (match-string 1 idlwave-shell-command-output)))))
  
+ (defvar idlwave-sint-sysvars nil)
+ (idlwave-new-sintern-type 'execcomm)
  
  (defun idlwave-shell-complete (&optional arg)
    "Do completion in the idlwave-shell buffer.
***************
*** 1844,1879 ****
  in strings.  Otherwise, calls `idlwave-complete' to complete modules and
  keywords."
    (interactive "P")
!   (let (cmd)
      (cond
!      ((setq cmd (idlwave-shell-executive-command))
        ;; We are in a command line with an executive command
!       (if (member (upcase cmd)
!                 '(".R" ".RU" ".RUN" ".RN" ".RNE" ".RNEW"
!                   ".COM" ".COMP" ".COMPI" ".COMPIL" ".COMPILE"))
!         ;; This command expects file names
!         (idlwave-shell-complete-filename)))
  
       ((idlwave-shell-batch-command)
        (idlwave-shell-complete-filename))
  
       ((and (idlwave-shell-filename-string)
           (save-excursion
             (beginning-of-line)
             (let ((case-fold-search t))
               (not (looking-at ".*obj_new")))))
        (idlwave-shell-complete-filename))
! 
       (t
        ;; Default completion of modules and keywords
        (idlwave-complete arg)))))
  
  (defun idlwave-shell-complete-filename (&optional arg)
    "Complete a file name at point if after a file name.
  We assume that we are after a file name when completing one of the
  args of an executive .run, .rnew or .compile."
    ;; CWD might have changed, resync, to set default directory
!   (idlwave-shell-resync-dirs)
    (let ((comint-file-name-chars idlwave-shell-file-name-chars))
      (comint-dynamic-complete-as-filename)))
  
--- 2129,2187 ----
  in strings.  Otherwise, calls `idlwave-complete' to complete modules and
  keywords."
    (interactive "P")
!   (let (exec-cmd)
      (cond
!      ((and 
!        (setq exec-cmd (idlwave-shell-executive-command))
!        (cdr exec-cmd)
!        (member (upcase (cdr exec-cmd))
!              '(".R" ".RU" ".RUN" ".RN" ".RNE" ".RNEW"
!                ".COM" ".COMP" ".COMPI" ".COMPIL" ".COMPILE")))
        ;; We are in a command line with an executive command
!       (idlwave-shell-complete-filename))
! 
!      ((car-safe exec-cmd)
!       (setq idlwave-completion-help-info 
!           '(idlwave-shell-complete-execcomm-help))
!       (idlwave-complete-in-buffer 'execcomm 'execcomm
!                                 idlwave-executive-commands-alist nil
!                                 "Select an executive command"
!                                 "system variable"))
  
       ((idlwave-shell-batch-command)
        (idlwave-shell-complete-filename))
  
+      ((idlwave-shell-shell-command)
+       (idlwave-shell-complete-filename))
+ 
       ((and (idlwave-shell-filename-string)
           (save-excursion
             (beginning-of-line)
             (let ((case-fold-search t))
               (not (looking-at ".*obj_new")))))
        (idlwave-shell-complete-filename))
!      
       (t
        ;; Default completion of modules and keywords
        (idlwave-complete arg)))))
  
+ ;; Get rid of opaque dynamic variable passing of link?
+ (defun idlwave-shell-complete-execcomm-help (mode word)
+   (let ((word (or (nth 1 idlwave-completion-help-info) word))
+       (entry (assoc-ignore-case word idlwave-executive-commands-alist)))
+     (cond
+      ((eq mode 'test)
+       (and (stringp word) entry (cdr entry)))
+      ((eq mode 'set)
+       (if entry (setq link (cdr entry)))) ;; setting dynamic variable!!!
+      (t (error "This should not happen")))))
+ 
  (defun idlwave-shell-complete-filename (&optional arg)
    "Complete a file name at point if after a file name.
  We assume that we are after a file name when completing one of the
  args of an executive .run, .rnew or .compile."
    ;; CWD might have changed, resync, to set default directory
!   (idlwave-shell-resync-dirs) 
    (let ((comint-file-name-chars idlwave-shell-file-name-chars))
      (comint-dynamic-complete-as-filename)))
  
***************
*** 1881,1888 ****
    "Return the name of the current executive command, if any."
    (save-excursion
      (idlwave-beginning-of-statement)
!     (if (looking-at "[ \t]*\\([.][^ \t\n\r]+\\)")
!       (match-string 1))))
  
  (defun idlwave-shell-filename-string ()
    "Return t if in a string and after what could be a file name."
--- 2189,2197 ----
    "Return the name of the current executive command, if any."
    (save-excursion
      (idlwave-beginning-of-statement)
!     (cons (looking-at "[ \t]*\\.")
!         (if (looking-at "[ \t]*[.]\\([^ \t\n\r]+\\)[ \t]")
!             (match-string 1)))))
  
  (defun idlwave-shell-filename-string ()
    "Return t if in a string and after what could be a file name."
***************
*** 1902,1914 ****
        (skip-chars-backward " \t" limit)
        (and (eq (preceding-char) ?@) (not (idlwave-in-quote))))))
  
! ;;;
! ;;; This section contains code for debugging IDL programs. 
--------------------
! ;;;
  
  (defun idlwave-shell-redisplay (&optional hide)
    "Tries to resync the display with where execution has stopped.
! Issues a \"help,/trace\" command followed by a call to
  `idlwave-shell-display-line'.  Also updates the breakpoint
  overlays."
    (interactive)
--- 2211,2227 ----
        (skip-chars-backward " \t" limit)
        (and (eq (preceding-char) ?@) (not (idlwave-in-quote))))))
  
! (defun idlwave-shell-shell-command ()
!   "Returns t if we're in a shell command statement like $ls"
!   (save-excursion
!     (idlwave-beginning-of-statement)
!     (looking-at "\\$")))
! 
! ;; Debugging Commands ------------------------------------------------------
  
  (defun idlwave-shell-redisplay (&optional hide)
    "Tries to resync the display with where execution has stopped.
! Issues a \"help,/trace\" command followed by a call to 
  `idlwave-shell-display-line'.  Also updates the breakpoint
  overlays."
    (interactive)
***************
*** 1921,1927 ****
    (idlwave-shell-bp-query))
  
  (defun idlwave-shell-display-level-in-calling-stack (&optional hide)
!   (idlwave-shell-send-command
     "help,/trace"
     `(progn
        ;; scanning for the state will reset the stack level - restore it
--- 2234,2240 ----
    (idlwave-shell-bp-query))
  
  (defun idlwave-shell-display-level-in-calling-stack (&optional hide)
!   (idlwave-shell-send-command 
     "help,/trace"
     `(progn
        ;; scanning for the state will reset the stack level - restore it
***************
*** 1952,1962 ****
        (setq idlwave-shell-calling-stack-index nmin
            message (format "%d is the current calling stack level - can't go 
further down"
                            (- nmin)))))
!     (setq idlwave-shell-calling-stack-routine
          (nth 2 (nth idlwave-shell-calling-stack-index stack)))
!     (idlwave-shell-display-line
!      (nth idlwave-shell-calling-stack-index stack))
!     (message (or message
                 (format "In routine %s (stack level %d)"
                         idlwave-shell-calling-stack-routine
                         (- idlwave-shell-calling-stack-index))))))
--- 2265,2278 ----
        (setq idlwave-shell-calling-stack-index nmin
            message (format "%d is the current calling stack level - can't go 
further down"
                            (- nmin)))))
!     (setq idlwave-shell-calling-stack-routine 
          (nth 2 (nth idlwave-shell-calling-stack-index stack)))
! 
!     ;; only edebug if in that mode already
!     (idlwave-shell-display-line 
!      (nth idlwave-shell-calling-stack-index stack) nil
!      (unless idlwave-shell-electric-debug-mode 'no-debug)) 
!     (message (or message 
                 (format "In routine %s (stack level %d)"
                         idlwave-shell-calling-stack-routine
                         (- idlwave-shell-calling-stack-index))))))
***************
*** 1987,1993 ****
  (defun idlwave-shell-pc-frame ()
    "Returns the frame for IDL execution."
    (and idlwave-shell-halt-frame
!        (list (nth 0 idlwave-shell-halt-frame)
             (nth 1 idlwave-shell-halt-frame)
             (nth 2 idlwave-shell-halt-frame))))
  
--- 2303,2309 ----
  (defun idlwave-shell-pc-frame ()
    "Returns the frame for IDL execution."
    (and idlwave-shell-halt-frame
!        (list (nth 0 idlwave-shell-halt-frame) 
             (nth 1 idlwave-shell-halt-frame)
             (nth 2 idlwave-shell-halt-frame))))
  
***************
*** 1995,2013 ****
    "Check that frame is for an existing file."
    (file-readable-p (car frame)))
  
! (defun idlwave-shell-display-line (frame &optional col)
    "Display FRAME file in other window with overlay arrow.
  
! FRAME is a list of file name, line number, and subroutine name.
! If FRAME is nil then remove overlay."
    (if (not frame)
        ;; Remove stop-line overlay from old position
!       (progn
          (setq overlay-arrow-string nil)
        (setq idlwave-shell-mode-line-info nil)
        (setq idlwave-shell-is-stopped nil)
          (if idlwave-shell-stop-line-overlay
!             (delete-overlay idlwave-shell-stop-line-overlay)))
      (if (not (idlwave-shell-valid-frame frame))
        ;; FIXME: errors are dangerous in shell filters.  But I think I
        ;; have never encountered this one.
--- 2311,2336 ----
    "Check that frame is for an existing file."
    (file-readable-p (car frame)))
  
! (defvar idlwave-shell-suppress-electric-debug nil)
! (defun idlwave-shell-display-line (frame &optional col no-debug)
    "Display FRAME file in other window with overlay arrow.
  
! FRAME is a list of file name, line number, and subroutine name.  If
! FRAME is nil then remove overlay.  If COL is set, move point to that
! column in the line.  If NO-DEBUG is non-nil, do *not* toggle the electric
! debug mode."
    (if (not frame)
        ;; Remove stop-line overlay from old position
!       (progn 
          (setq overlay-arrow-string nil)
        (setq idlwave-shell-mode-line-info nil)
        (setq idlwave-shell-is-stopped nil)
          (if idlwave-shell-stop-line-overlay
!             (delete-overlay idlwave-shell-stop-line-overlay))
!       ;; Turn off electric debug everywhere, if it's on
!       (if (and (not no-debug)
!                idlwave-shell-automatic-electric-debug)
!           (idlwave-shell-electric-debug-all-off)))
      (if (not (idlwave-shell-valid-frame frame))
        ;; FIXME: errors are dangerous in shell filters.  But I think I
        ;; have never encountered this one.
***************
*** 2015,2029 ****
  ;;;
  ;;; buffer : the buffer to display a line in.
  ;;; select-shell: current buffer is the shell.
! ;;;
        (setq idlwave-shell-mode-line-info
            (if (nth 2 frame)
!               (format "[%d:%s]"
                        (- idlwave-shell-calling-stack-index)
                        (nth 2 frame))))
        (let* ((buffer (idlwave-find-file-noselect (car frame) 'shell))
               (select-shell (equal (buffer-name) (idlwave-shell-buffer)))
!              window pos)
  
        ;; First make sure the shell window is visible
        (idlwave-display-buffer (idlwave-shell-buffer)
--- 2338,2352 ----
  ;;;
  ;;; buffer : the buffer to display a line in.
  ;;; select-shell: current buffer is the shell.
! ;;; 
        (setq idlwave-shell-mode-line-info
            (if (nth 2 frame)
!               (format "[%d:%s]" 
                        (- idlwave-shell-calling-stack-index)
                        (nth 2 frame))))
        (let* ((buffer (idlwave-find-file-noselect (car frame) 'shell))
               (select-shell (equal (buffer-name) (idlwave-shell-buffer)))
!              window pos electric)
  
        ;; First make sure the shell window is visible
        (idlwave-display-buffer (idlwave-shell-buffer)
***************
*** 2039,2046 ****
--- 2362,2371 ----
            (save-restriction
              (widen)
              (goto-line (nth 1 frame))
+           (forward-line 0)
              (setq pos (point))
            (setq idlwave-shell-is-stopped t)
+           
              (if idlwave-shell-stop-line-overlay
                  ;; Move overlay
                (move-overlay idlwave-shell-stop-line-overlay
***************
*** 2051,2057 ****
                  (setq overlay-arrow-string idlwave-shell-overlay-arrow))
                (or overlay-arrow-position  ; create the marker if necessary
                    (setq overlay-arrow-position (make-marker)))
!               (set-marker overlay-arrow-position (point) buffer)))
  
          ;; If the point is outside the restriction, widen the buffer.
            (if (or (< pos (point-min)) (> pos (point-max)))
--- 2376,2382 ----
                  (setq overlay-arrow-string idlwave-shell-overlay-arrow))
                (or overlay-arrow-position  ; create the marker if necessary
                    (setq overlay-arrow-position (make-marker)))
!             (set-marker overlay-arrow-position (point) buffer)))
  
          ;; If the point is outside the restriction, widen the buffer.
            (if (or (< pos (point-min)) (> pos (point-max)))
***************
*** 2061,2075 ****
  
          ;; If we have the column of the error, move the cursor there.
            (if col (move-to-column col))
!           (setq pos (point)))
! 
        ;; Make sure pos is really displayed in the window.
!         (set-window-point window pos)
! 
!       ;; If we came from the shell, go back there.  Otherwise select
        ;; the window where the error is displayed.
!         (if (and (equal (buffer-name) (idlwave-shell-buffer))
!                (not select-shell))
              (select-window window))))))
  
  
--- 2386,2414 ----
  
          ;; If we have the column of the error, move the cursor there.
            (if col (move-to-column col))
!           (setq pos (point))
!         
!         ;; Enter electric debug mode, if not prohibited and not in
!         ;; it already
!         (when (and (or 
!                     (eq idlwave-shell-automatic-electric-debug t)
!                     (and 
!                      (eq idlwave-shell-automatic-electric-debug 'breakpoint)
!                      (not (eq idlwave-shell-current-state 'error))))
!                    (not no-debug)
!                    (not idlwave-shell-suppress-electric-debug)
!                    (not idlwave-shell-electric-debug-mode))
!           (idlwave-shell-electric-debug-mode)
!           (setq electric t)))
!       
        ;; Make sure pos is really displayed in the window.
!       (set-window-point window pos)
!       
!       ;; If we came from the shell, go back there.  Otherwise select 
        ;; the window where the error is displayed.
!         (if (or (and idlwave-shell-electric-zap-to-file electric)
!               (and (equal (buffer-name) (idlwave-shell-buffer)) 
!                    (not select-shell)))
              (select-window window))))))
  
  
***************
*** 2078,2119 ****
    (interactive "p")
    (or (not arg) (< arg 1)
        (setq arg 1))
!   (idlwave-shell-send-command
     (concat ".s " (if (integerp arg) (int-to-string arg) arg))
!    nil (idlwave-shell-hide-p 'debug)))
  
  (defun idlwave-shell-stepover (arg)
    "Stepover one source line.
! If given prefix argument ARG, step ARG source lines.
  Uses IDL's stepover executive command which does not enter called functions."
    (interactive "p")
    (or (not arg) (< arg 1)
        (setq arg 1))
!   (idlwave-shell-send-command
     (concat ".so " (if (integerp arg) (int-to-string arg) arg))
!    nil (idlwave-shell-hide-p 'debug)))
  
! (defun idlwave-shell-break-here (&optional count cmd condition)
!   "Set breakpoint at current line.
  
  If Count is nil then an ordinary breakpoint is set.  We treat a count
  of 1 as a temporary breakpoint using the ONCE keyword.  Counts greater
  than 1 use the IDL AFTER=count keyword to break only after reaching
  the statement count times.
  
! Optional argument CMD is a list or function to evaluate upon reaching
  the breakpoint."
! 
    (interactive "P")
    (when (listp count)
!     (if (equal (car count) 4)
        (setq condition (read-string "Break Condition: ")))
      (setq count nil))
    (idlwave-shell-set-bp
     ;; Create breakpoint
     (idlwave-shell-bp (idlwave-shell-current-frame)
!                    (list count cmd condition)
!                    (idlwave-shell-current-module))))
  
  (defun idlwave-shell-set-bp-check (bp)
    "Check for failure to set breakpoint.
--- 2417,2459 ----
    (interactive "p")
    (or (not arg) (< arg 1)
        (setq arg 1))
!   (idlwave-shell-send-command 
     (concat ".s " (if (integerp arg) (int-to-string arg) arg))
!    nil (if (idlwave-shell-hide-p 'debug) 'mostly) nil t))
  
  (defun idlwave-shell-stepover (arg)
    "Stepover one source line.
! If given prefix argument ARG, step ARG source lines. 
  Uses IDL's stepover executive command which does not enter called functions."
    (interactive "p")
    (or (not arg) (< arg 1)
        (setq arg 1))
!   (idlwave-shell-send-command 
     (concat ".so " (if (integerp arg) (int-to-string arg) arg))
!    nil (if (idlwave-shell-hide-p 'debug) 'mostly) nil t))
  
! (defun idlwave-shell-break-here (&optional count cmd condition no-show)
!   "Set breakpoint at current line.  
  
  If Count is nil then an ordinary breakpoint is set.  We treat a count
  of 1 as a temporary breakpoint using the ONCE keyword.  Counts greater
  than 1 use the IDL AFTER=count keyword to break only after reaching
  the statement count times.
  
! Optional argument CMD is a list or function to evaluate upon reaching 
  the breakpoint."
!   
    (interactive "P")
    (when (listp count)
!     (if (equal (car count) 4) 
        (setq condition (read-string "Break Condition: ")))
      (setq count nil))
    (idlwave-shell-set-bp
     ;; Create breakpoint
     (idlwave-shell-bp (idlwave-shell-current-frame)
!                    (list count cmd condition nil)
!                    (idlwave-shell-current-module))
!    no-show))
  
  (defun idlwave-shell-set-bp-check (bp)
    "Check for failure to set breakpoint.
***************
*** 2128,2134 ****
        (progn
          (if (progn
                (beep)
!               (y-or-n-p
                 (concat "Okay to recompile file "
                         (idlwave-shell-bp-get bp 'file) " ")))
              ;; Recompile
--- 2468,2474 ----
        (progn
          (if (progn
                (beep)
!               (y-or-n-p 
                 (concat "Okay to recompile file "
                         (idlwave-shell-bp-get bp 'file) " ")))
              ;; Recompile
***************
*** 2136,2143 ****
                ;; Clean up before retrying
                (idlwave-shell-command-failure)
                (idlwave-shell-send-command
!                (concat ".run " (idlwave-shell-bp-get bp 'file)) nil
!              (idlwave-shell-hide-p 'run))
                ;; Try setting breakpoint again
                (idlwave-shell-set-bp bp))
            (beep)
--- 2476,2483 ----
                ;; Clean up before retrying
                (idlwave-shell-command-failure)
                (idlwave-shell-send-command
!                (concat ".run " (idlwave-shell-bp-get bp 'file)) nil 
!              (if (idlwave-shell-hide-p 'run) 'mostly) nil t)
                ;; Try setting breakpoint again
                (idlwave-shell-set-bp bp))
            (beep)
***************
*** 2157,2185 ****
    ;; Clear pending commands
    (setq idlwave-shell-pending-commands nil))
  
! (defun idlwave-shell-cont ()
    "Continue executing."
    (interactive)
!   (idlwave-shell-send-command ".c" '(idlwave-shell-redisplay 'hide)
!                             (idlwave-shell-hide-p 'debug)))
  
  (defun idlwave-shell-go ()
    "Run .GO.  This starts the main program of the last compiled file."
    (interactive)
    (idlwave-shell-send-command ".go" '(idlwave-shell-redisplay 'hide)
!                             (idlwave-shell-hide-p 'debug)))
  
  (defun idlwave-shell-return ()
    "Run .RETURN (continue to next return, but stay in subprogram)."
    (interactive)
    (idlwave-shell-send-command ".return" '(idlwave-shell-redisplay 'hide)
!                             (idlwave-shell-hide-p 'debug)))
  
  (defun idlwave-shell-skip ()
    "Run .SKIP (skip one line, then step)."
    (interactive)
    (idlwave-shell-send-command ".skip" '(idlwave-shell-redisplay 'hide)
!                             (idlwave-shell-hide-p 'debug)))
  
  (defun idlwave-shell-clear-bp (bp)
    "Clear breakpoint BP.
--- 2497,2530 ----
    ;; Clear pending commands
    (setq idlwave-shell-pending-commands nil))
  
! (defun idlwave-shell-cont (&optional no-show)
    "Continue executing."
    (interactive)
!   (idlwave-shell-send-command ".c" (unless no-show 
!                                    '(idlwave-shell-redisplay 'hide))
!                             (if (idlwave-shell-hide-p 'debug) 'mostly) 
!                             nil t))
  
  (defun idlwave-shell-go ()
    "Run .GO.  This starts the main program of the last compiled file."
    (interactive)
    (idlwave-shell-send-command ".go" '(idlwave-shell-redisplay 'hide)
!                             (if (idlwave-shell-hide-p 'debug) 'mostly)
!                             nil t))
  
  (defun idlwave-shell-return ()
    "Run .RETURN (continue to next return, but stay in subprogram)."
    (interactive)
    (idlwave-shell-send-command ".return" '(idlwave-shell-redisplay 'hide)
!                             (if (idlwave-shell-hide-p 'debug) 'mostly)
!                             nil t))
  
  (defun idlwave-shell-skip ()
    "Run .SKIP (skip one line, then step)."
    (interactive)
    (idlwave-shell-send-command ".skip" '(idlwave-shell-redisplay 'hide)
!                             (if (idlwave-shell-hide-p 'debug) 'mostly)
!                             nil t))
  
  (defun idlwave-shell-clear-bp (bp)
    "Clear breakpoint BP.
***************
*** 2188,2196 ****
      (if index
          (progn
            (idlwave-shell-send-command
!            (concat "breakpoint,/clear,"
!                  (if (integerp index) (int-to-string index) index))
!          nil (idlwave-shell-hide-p 'breakpoint))
          (idlwave-shell-bp-query)))))
  
  (defun idlwave-shell-current-frame ()
--- 2533,2540 ----
      (if index
          (progn
            (idlwave-shell-send-command
!            (concat "breakpoint,/clear," (int-to-string index))
!          nil (idlwave-shell-hide-p 'breakpoint) nil t)
          (idlwave-shell-bp-query)))))
  
  (defun idlwave-shell-current-frame ()
***************
*** 2225,2267 ****
  This command can be called from the shell buffer if IDL is currently stopped
  at a breakpoint."
    (interactive)
!   (let ((bp (idlwave-shell-find-bp (idlwave-shell-current-frame))))
!     (if bp (idlwave-shell-clear-bp bp)
!       ;; Try moving to beginning of statement
!       (save-excursion
!         (idlwave-shell-goto-frame)
!         (idlwave-beginning-of-statement)
!         (setq bp (idlwave-shell-find-bp (idlwave-shell-current-frame)))
!         (if bp (idlwave-shell-clear-bp bp)
!           (beep)
!           (message "Cannot identify breakpoint for this line"))))))
  
! (defun idlwave-shell-disable-all-bp (&optional enable)
!   "Disable all breakpoints we know about.
! If ENABLE is non-nil, enable them instead."
!   (let  ((bpl idlwave-shell-bp-alist))
!     (while bpl
!       (idlwave-shell-send-command
         (concat "breakpoint,"
!              (if enable "/enable," "/disable," )
!              (idlwave-shell-bp-get (car bpl)))
!        nil (idlwave-shell-hide-p 'breakpoint))
!       (setq bpl (cdr bpl)))))
  
  (defun idlwave-shell-to-here ()
    "Set a breakpoint with count 1 then continue."
    (interactive)
!   (idlwave-shell-disable-all-bp)
!   (idlwave-shell-break-here 1)
!   (idlwave-shell-cont)
!   (idlwave-shell-disable-all-bp 'enable))
  
! (defun idlwave-shell-break-in (&optional module)
    "Look for a module name near point and set a break point for it.
  The command looks for an identifier near point and sets a breakpoint
! for the first line of the corresponding module."
    (interactive)
-   ;; get the identifier
    (let (module)
      (save-excursion
        (skip-chars-backward "a-zA-Z0-9_$")
--- 2569,2630 ----
  This command can be called from the shell buffer if IDL is currently stopped
  at a breakpoint."
    (interactive)
!   (let ((bp (idlwave-shell-find-current-bp)))
!     (if bp (idlwave-shell-clear-bp bp))))
  
! 
! (defun idlwave-shell-toggle-enable-current-bp (&optional bp force
!                                                        no-update)
!   "Disable or enable current bp."
!   (interactive)
!   (let* ((bp (or bp (idlwave-shell-find-current-bp)))
!        (disabled (idlwave-shell-bp-get bp 'disabled)))
!     (cond ((eq force 'disable) (setq disabled nil))
!         ((eq force 'enable) (setq disabled t)))
!     (when bp
!       (setf (nth 3 (cdr (cdr bp))) (not disabled))
!       (idlwave-shell-send-command 
         (concat "breakpoint,"
!              (if disabled "/enable," "/disable,")
!              (int-to-string (idlwave-shell-bp-get bp)))
!        nil (idlwave-shell-hide-p 'breakpoint) nil t)
!       (unless no-update (idlwave-shell-bp-query)))))
  
+ (defun idlwave-shell-enable-all-bp (&optional enable no-update bpl)
+   "Disable all breakpoints we know about which need disabling.
+ If ENABLE is non-nil, enable them instead."
+   (let  ((bpl (or bpl idlwave-shell-bp-alist)) disabled modified)
+     (while bpl
+       (setq disabled (idlwave-shell-bp-get (car bpl) 'disabled))
+       (when (idlwave-xor (not disabled) (eq enable 'enable))
+       (idlwave-shell-toggle-enable-current-bp 
+        (car bpl) (if (eq enable 'enable) 'enable 'disable) no-update)
+       (push (car bpl) modified))
+       (setq bpl (cdr bpl)))
+     (unless no-update (idlwave-shell-bp-query))
+     modified))
+   
  (defun idlwave-shell-to-here ()
    "Set a breakpoint with count 1 then continue."
    (interactive)
!   (let ((disabled (idlwave-shell-enable-all-bp 'disable 'no-update)))
!     (idlwave-shell-break-here 1 nil nil 'no-show)
!     (idlwave-shell-cont 'no-show)
!     (idlwave-shell-enable-all-bp 'enable 'no-update disabled))
!   (idlwave-shell-redisplay)) ; sync up everything at the end
  
! (defun idlwave-shell-break-this-module (&optional arg)
!   (interactive "P")
!   (save-excursion
!     (idlwave-beginning-of-subprogram)
!     (idlwave-shell-break-here arg)))
! 
! (defun idlwave-shell-break-in ()
    "Look for a module name near point and set a break point for it.
  The command looks for an identifier near point and sets a breakpoint
! for the first line of the corresponding module.  If MODULE is `t', set
! in the current routine."
    (interactive)
    (let (module)
      (save-excursion
        (skip-chars-backward "a-zA-Z0-9_$")
***************
*** 2278,2284 ****
  (defun idlwave-shell-set-bp-in-module (module)
    "Set breakpoint in module.  Assumes that `idlwave-shell-sources-alist'
  contains an entry for that module."
!   (let ((source-file (car-safe
                      (cdr-safe
                       (assoc (upcase module)
                              idlwave-shell-sources-alist))))
--- 2641,2647 ----
  (defun idlwave-shell-set-bp-in-module (module)
    "Set breakpoint in module.  Assumes that `idlwave-shell-sources-alist'
  contains an entry for that module."
!   (let ((source-file (car-safe 
                      (cdr-safe
                       (assoc (upcase module)
                              idlwave-shell-sources-alist))))
***************
*** 2297,2303 ****
        (save-excursion
          (goto-char (point-min))
          (let ((case-fold-search t))
!           (if (re-search-forward
                 (concat "^[ \t]*\\(pro\\|function\\)[ \t]+"
                         (downcase module)
                         "[ \t\n,]") nil t)
--- 2660,2666 ----
        (save-excursion
          (goto-char (point-min))
          (let ((case-fold-search t))
!           (if (re-search-forward 
                 (concat "^[ \t]*\\(pro\\|function\\)[ \t]+"
                         (downcase module)
                         "[ \t\n,]") nil t)
***************
*** 2339,2345 ****
    "Attempt to run until this procedure exits.
  Runs to the last statement and then steps 1 statement.  Use the .out command."
    (interactive)
!   (idlwave-shell-send-command ".o" nil (idlwave-shell-hide-p 'debug)))
  
  (defun idlwave-shell-help-expression (arg)
    "Print help on current expression.  See `idlwave-shell-print'."
--- 2702,2741 ----
    "Attempt to run until this procedure exits.
  Runs to the last statement and then steps 1 statement.  Use the .out command."
    (interactive)
!   (idlwave-shell-send-command ".o" nil 
!                             (if (idlwave-shell-hide-p 'debug) 'mostly)
!                             nil t))
! 
! (defun idlwave-shell-goto-previous-bp ()
!   "Move to the previous breakpoint in the buffer."
!   (interactive)
!   (idlwave-shell-move-to-bp -1))
! (defun idlwave-shell-goto-next-bp ()
!   "Move to the next breakpoint in the buffer."
!   (interactive)
!   (idlwave-shell-move-to-bp 1))
! 
! (defun idlwave-shell-move-to-bp (dir)
!   "Move to the next or previous breakpoint, depending on direction DIR."
!   (let* ((frame (idlwave-shell-current-frame))
!        (file (car frame))
!        (orig-bp-line (nth 1 frame))
!        (bp-alist idlwave-shell-bp-alist)
!        (orig-func (if (> dir 0) '> '<))
!        (closer-func (if (> dir 0) '< '>))
!        bp got-bp bp-line cur-line)
!     (while (setq bp (pop bp-alist))
!       (when (string= file (car (car bp)))
!       (setq got-bp 1)
!       (setq cur-line (nth 1 (car bp)))
!       (if (and
!            (funcall orig-func cur-line orig-bp-line)
!            (or (not bp-line) (funcall closer-func cur-line bp-line)))
!           (setq bp-line cur-line))))
!     (unless bp-line (error "No further breakpoints."))
!     (goto-line bp-line)))
! 
! ;; Examine Commands ------------------------------------------------------
  
  (defun idlwave-shell-help-expression (arg)
    "Print help on current expression.  See `idlwave-shell-print'."
***************
*** 2353,2364 ****
       (interactive "e")
       (let ((transient-mark-mode t)
           (zmacs-regions t)
!          (tracker (if (featurep 'xemacs) 'mouse-track
                      'mouse-drag-region)))
         (funcall tracker event)
!        (idlwave-shell-print (if (idlwave-region-active-p) '(16) nil)
                            ,help ,ev))))
  
  (defun idlwave-shell-mouse-print (event)
    "Print value of variable at the mouse position, with `help'"
    (interactive "e")
--- 2749,2778 ----
       (interactive "e")
       (let ((transient-mark-mode t)
           (zmacs-regions t)
!          (tracker (if (featurep 'xemacs) 
!                       (if (fboundp 'default-mouse-track-event-is-with-button)
!                           'idlwave-xemacs-hack-mouse-track
!                         'mouse-track)
                      'mouse-drag-region)))
         (funcall tracker event)
!        (idlwave-shell-print (if (idlwave-region-active-p) '(4) nil)
                            ,help ,ev))))
  
+ ;;; Begin terrible hack section -- XEmacs tests for button2 explicitly
+ ;;; on drag events, calling drag-n-drop code if detected.  Ughhh...
+ (defun idlwave-default-mouse-track-event-is-with-button (event n)
+   t)
+ 
+ (defun idlwave-xemacs-hack-mouse-track (event)
+   (let ((oldfunc (symbol-function 'default-mouse-track-event-is-with-button)))
+     (unwind-protect
+       (progn
+         (fset 'default-mouse-track-event-is-with-button 
+               'idlwave-default-mouse-track-event-is-with-button)
+         (mouse-track event))
+       (fset 'default-mouse-track-event-is-with-button oldfunc))))
+ ;;; End terrible hack section
+ 
  (defun idlwave-shell-mouse-print (event)
    "Print value of variable at the mouse position, with `help'"
    (interactive "e")
***************
*** 2380,2401 ****
       (interactive)
       (idlwave-shell-print nil ,help)))
  
- (defun idlwave-shell-define-key-both (key hook)
-   "Define a key in both the shell and buffer mode maps."
-   (define-key idlwave-mode-map key hook)
-   (define-key idlwave-shell-mode-map key hook))
- 
  (defvar idlwave-shell-examine-label nil
!   "Label to include with examine text if separate.")
  
! (defun idlwave-shell-print (arg &optional help ev)
!   "Print current expression.
  
  With HELP non-nil, show help on expression.  If HELP is a string,
  the expression will be put in place of ___, e.g.:
  
     print,size(___,/DIMENSIONS)
  
  Otherwise, print is called on the expression.
  
  An expression is an identifier plus 1 pair of matched parentheses
--- 2794,2814 ----
       (interactive)
       (idlwave-shell-print nil ,help)))
  
  (defvar idlwave-shell-examine-label nil
!   "Label to include with examine text if in a separate buffer.")
! (defvar idlwave-shell-examine-completion-list nil)
  
! (defun idlwave-shell-print (arg &optional help ev complete-help-type)
!   "Print current expression.  
  
  With HELP non-nil, show help on expression.  If HELP is a string,
  the expression will be put in place of ___, e.g.:
  
     print,size(___,/DIMENSIONS)
  
+ HELP can also be a cons cell ( NAME . STRING ) in which case NAME will
+ be used to label the help print-out.
+ 
  Otherwise, print is called on the expression.
  
  An expression is an identifier plus 1 pair of matched parentheses
***************
*** 2406,2435 ****
  return the inner-most containing expression, otherwise, return the
  preceding expression.
  
! With prefix arg ARG prompt for an expression.
  
! With double prefix arg, use the current region.
  
  If EV is a valid event passed, pop-up a list from
! idlw-shell-examine-alist from which to select the help command text."
    (interactive "P")
    (save-excursion
      (let* ((process (get-buffer-process (current-buffer)))
           (process-mark (if process (process-mark process)))
!          (stack-label
            (if (and (integerp idlwave-shell-calling-stack-index)
                     (> idlwave-shell-calling-stack-index 0))
!               (format "  [-%d:%s]"
!                       idlwave-shell-calling-stack-index
                        idlwave-shell-calling-stack-routine)))
           expr beg end cmd examine-hook)
        (cond
!        ((and (equal arg '(16))
             (< (- (region-end) (region-beginning)) 2000))
        (setq beg (region-beginning)
              end (region-end)))
-        (arg
-       (setq expr (read-string "Expression: ")))
         (t
        (idlwave-with-special-syntax
         ;; Move to beginning of current or previous expression
--- 2819,2851 ----
  return the inner-most containing expression, otherwise, return the
  preceding expression.
  
! With prefix arg, or if transient mode set and the region is defined,
! use the current region as the expression.
  
! With double prefix arg ARG prompt for an expression.
  
  If EV is a valid event passed, pop-up a list from
! idlw-shell-examine-alist from which to select the help command text.
! If instead COMPLETE-HELP-TYPE is non-nil, choose from
! idlw-shell-examine-alist via mini-buffer shortcut key."
    (interactive "P")
    (save-excursion
      (let* ((process (get-buffer-process (current-buffer)))
           (process-mark (if process (process-mark process)))
!          (stack-label 
            (if (and (integerp idlwave-shell-calling-stack-index)
                     (> idlwave-shell-calling-stack-index 0))
!               (format "  [-%d:%s]" 
!                       idlwave-shell-calling-stack-index 
                        idlwave-shell-calling-stack-routine)))
           expr beg end cmd examine-hook)
        (cond
!        ((equal arg '(16))
!       (setq expr (read-string "Expression: ")))
!        ((and (or arg (idlwave-region-active-p))
             (< (- (region-end) (region-beginning)) 2000))
        (setq beg (region-beginning)
              end (region-end)))
         (t
        (idlwave-with-special-syntax
         ;; Move to beginning of current or previous expression
***************
*** 2450,2456 ****
           ;; an array
           (forward-sexp))
         (setq end (point)))))
! 
        ;; Get expression, but first move the begin mark if a
        ;; process-mark is inside the region, to keep the overlay from
        ;; wandering in the Shell.
--- 2866,2872 ----
           ;; an array
           (forward-sexp))
         (setq end (point)))))
!       
        ;; Get expression, but first move the begin mark if a
        ;; process-mark is inside the region, to keep the overlay from
        ;; wandering in the Shell.
***************
*** 2461,2477 ****
  
        ;; Show the overlay(s) and attach any necessary hooks and filters
        (when (and beg end idlwave-shell-expression-overlay)
!       (move-overlay idlwave-shell-expression-overlay beg end
                      (current-buffer))
!       (add-hook 'pre-command-hook
                  'idlwave-shell-delete-expression-overlay))
!       (setq examine-hook
            (if idlwave-shell-separate-examine-output
                'idlwave-shell-examine-display
              'idlwave-shell-examine-highlight))
        (add-hook 'pre-command-hook
                'idlwave-shell-delete-output-overlay)
! 
        ;; Remove empty or comment-only lines
        (while (string-match "\n[ \t]*\\(;.*\\)?\r*\n" expr)
        (setq expr (replace-match "\n" t t expr)))
--- 2877,2893 ----
  
        ;; Show the overlay(s) and attach any necessary hooks and filters
        (when (and beg end idlwave-shell-expression-overlay)
!       (move-overlay idlwave-shell-expression-overlay beg end 
                      (current-buffer))
!       (add-hook 'pre-command-hook 
                  'idlwave-shell-delete-expression-overlay))
!       (setq examine-hook 
            (if idlwave-shell-separate-examine-output
                'idlwave-shell-examine-display
              'idlwave-shell-examine-highlight))
        (add-hook 'pre-command-hook
                'idlwave-shell-delete-output-overlay)
!       
        ;; Remove empty or comment-only lines
        (while (string-match "\n[ \t]*\\(;.*\\)?\r*\n" expr)
        (setq expr (replace-match "\n" t t expr)))
***************
*** 2481,2529 ****
        ;; Remove final newline
        (if (string-match "\n[ \t\r]*\\'" expr)
          (setq expr (replace-match "" t t expr)))
!       ;; Pop-up the examine selection list, if appropriate
!       (if (and ev idlwave-shell-examine-alist)
!         (let* ((help-cons
!                 (assoc
!                  (idlwave-popup-select
!                   ev (mapcar 'car idlwave-shell-examine-alist)
!                   "Examine with")
!                  idlwave-shell-examine-alist)))
!           (setq help (cdr help-cons))
!           (if idlwave-shell-separate-examine-output
!               (setq idlwave-shell-examine-label
!                     (concat
!                      (format "==>%s<==\n%s:" expr (car help-cons))
!                      stack-label "\n"))))
!       (setq idlwave-shell-examine-label
!             (concat
!              (format "==>%s<==\n%s:" expr
!                      (cond ((null help) "print")
!                            ((stringp help) help)
!                            (t (symbol-name help))))
!              stack-label "\n")))
! 
!       ;; Send the command
!       (if stack-label
!         (setq cmd (idlwave-retrieve-expression-from-level
!                    expr
!                    idlwave-shell-calling-stack-index
!                    idlwave-shell-calling-stack-routine
!                    help))
!       (setq cmd (idlwave-shell-help-statement help expr)))
!       ;(idlwave-shell-recenter-shell-window)
!       (idlwave-shell-send-command
!        cmd
!        examine-hook
!        (if idlwave-shell-separate-examine-output 'hide)))))
  
  (defvar idlwave-shell-examine-window-alist nil
    "Variable to hold the win/height pairs for all *Examine* windows.")
  
- (defvar idlwave-shell-examine-map (make-sparse-keymap))
- (define-key idlwave-shell-examine-map "q" 'idlwave-shell-examine-display-quit)
- (define-key idlwave-shell-examine-map "c" 
'idlwave-shell-examine-display-clear)
- 
  (defun idlwave-shell-examine-display ()
    "View the examine command output in a separate buffer."
    (let (win cur-beg cur-end)
--- 2897,2957 ----
        ;; Remove final newline
        (if (string-match "\n[ \t\r]*\\'" expr)
          (setq expr (replace-match "" t t expr)))
!       
!       (catch 'exit
!       ;; Pop-up or complete on the examine selection list, if appropriate
!       (if (or
!            complete-help-type
!            (and ev idlwave-shell-examine-alist)
!            (consp help))
!           (let ((help-cons 
!                  (if (consp help) help
!                    (assoc 
!                     ;; A cons from either a pop-up or mini-buffer completion
!                     (if complete-help-type
!                         (idlwave-one-key-select 'idlwave-shell-examine-alist
!                                                 "Examine with: " 1.5)
! ;;                      (idlwave-completing-read
! ;;                       "Examine with: " 
! ;;                       idlwave-shell-examine-alist nil nil nil
! ;;                       'idlwave-shell-examine-completion-list
! ;;                       "Print")
!                       (idlwave-popup-select 
!                        ev 
!                        (mapcar 'car idlwave-shell-examine-alist) 
!                        "Examine with"))
!                     idlwave-shell-examine-alist))))
!             (setq help (cdr help-cons))
!             (if (null help) (throw 'exit nil))
!             (if idlwave-shell-separate-examine-output
!                 (setq idlwave-shell-examine-label 
!                       (concat 
!                        (format "==>%s<==\n%s:" expr (car help-cons))
!                        stack-label "\n"))))
!         ;; The regular help label (no popups, cons cells, etc.)
!         (setq idlwave-shell-examine-label
!               (concat
!                (format "==>%s<==\n%s:" expr 
!                        (cond ((null help) "print")
!                              ((stringp help) help)
!                              (t (symbol-name help))))
!                stack-label "\n")))
! 
!       ;; Send the command
!       (if stack-label
!           (setq expr (idlwave-retrieve-expression-from-level
!                       expr
!                       idlwave-shell-calling-stack-index)))
!       (setq cmd (idlwave-shell-help-statement help expr))
!       ;;(idlwave-shell-recenter-shell-window)
!       (idlwave-shell-send-command 
!        cmd 
!        examine-hook 
!        (if idlwave-shell-separate-examine-output 'hide))))))
  
  (defvar idlwave-shell-examine-window-alist nil
    "Variable to hold the win/height pairs for all *Examine* windows.")
  
  (defun idlwave-shell-examine-display ()
    "View the examine command output in a separate buffer."
    (let (win cur-beg cur-end)
***************
*** 2541,2549 ****
          (let* ((end (or
                       (re-search-backward idlwave-shell-prompt-pattern nil t)
                       (point-max)))
!                (beg (progn
                        (goto-char
!                        (or (progn (if (re-search-backward
                                         idlwave-shell-prompt-pattern nil t)
                                        (match-end 0)))
                             (point-min)))
--- 2969,2977 ----
          (let* ((end (or
                       (re-search-backward idlwave-shell-prompt-pattern nil t)
                       (point-max)))
!                (beg (progn 
                        (goto-char
!                        (or (progn (if (re-search-backward 
                                         idlwave-shell-prompt-pattern nil t)
                                        (match-end 0)))
                             (point-min)))
***************
*** 2560,2580 ****
        (setq buffer-read-only t)
        (move-overlay idlwave-shell-output-overlay cur-beg cur-end
                      (current-buffer))
! 
        ;; Look for the examine buffer in all windows.  If one is
        ;; found in a frame all by itself, use that, otherwise, switch
        ;; to or create an examine window in this frame, and resize if
        ;; it's a newly created window
        (let* ((winlist (get-buffer-window-list "*Examine*" nil 'visible)))
!         (setq win (idlwave-display-buffer
!                    "*Examine*"
                     nil
                     (let ((list winlist) thiswin)
                       (catch 'exit
                         (save-selected-window
                           (while (setq thiswin (pop list))
                             (select-window thiswin)
!                            (if (one-window-p)
                                 (throw 'exit (window-frame thiswin)))))))))
          (set-window-start win (point-min)) ; Ensure the point is visible.
          (save-selected-window
--- 2988,3008 ----
        (setq buffer-read-only t)
        (move-overlay idlwave-shell-output-overlay cur-beg cur-end
                      (current-buffer))
!       
        ;; Look for the examine buffer in all windows.  If one is
        ;; found in a frame all by itself, use that, otherwise, switch
        ;; to or create an examine window in this frame, and resize if
        ;; it's a newly created window
        (let* ((winlist (get-buffer-window-list "*Examine*" nil 'visible)))
!         (setq win (idlwave-display-buffer 
!                    "*Examine*" 
                     nil
                     (let ((list winlist) thiswin)
                       (catch 'exit
                         (save-selected-window
                           (while (setq thiswin (pop list))
                             (select-window thiswin)
!                            (if (one-window-p) 
                                 (throw 'exit (window-frame thiswin)))))))))
          (set-window-start win (point-min)) ; Ensure the point is visible.
          (save-selected-window
***************
*** 2595,2601 ****
                ;; And add the new value.
                (if (setq elt (assoc win idlwave-shell-examine-window-alist))
                    (setcdr elt (window-height))
!                 (add-to-list 'idlwave-shell-examine-window-alist
                               (cons win (window-height)))))))))
        ;; Recenter for maximum output, after widened
        (save-selected-window
--- 3023,3029 ----
                ;; And add the new value.
                (if (setq elt (assoc win idlwave-shell-examine-window-alist))
                    (setcdr elt (window-height))
!                 (add-to-list 'idlwave-shell-examine-window-alist 
                               (cons win (window-height)))))))))
        ;; Recenter for maximum output, after widened
        (save-selected-window
***************
*** 2604,2609 ****
--- 3032,3041 ----
        (skip-chars-backward "\n")
        (recenter -1)))))
  
+ (defvar idlwave-shell-examine-map (make-sparse-keymap))
+ (define-key idlwave-shell-examine-map "q" 'idlwave-shell-examine-display-quit)
+ (define-key idlwave-shell-examine-map "c" 
'idlwave-shell-examine-display-clear)
+ 
  (defun idlwave-shell-examine-display-quit ()
    (interactive)
    (let ((win (selected-window)))
***************
*** 2613,2619 ****
  
  (defun idlwave-shell-examine-display-clear ()
    (interactive)
!   (save-excursion
      (let ((buf (get-buffer "*Examine*")))
        (when (bufferp buf)
        (set-buffer buf)
--- 3045,3051 ----
  
  (defun idlwave-shell-examine-display-clear ()
    (interactive)
!   (save-excursion 
      (let ((buf (get-buffer "*Examine*")))
        (when (bufferp buf)
        (set-buffer buf)
***************
*** 2621,2653 ****
        (erase-buffer)
        (setq buffer-read-only t)))))
  
! (defun idlwave-retrieve-expression-from-level (expr level routine help)
    "Return IDL command to print the expression EXPR from stack level LEVEL.
  
! It does not seem possible to evaluate an expression on a differnt
! level than the current.  Therefore, this function retrieves *copies* of
! the variables involved in the expression from the desired level in the
! calling stack.  The copies are given some unlikely names on the
! *current* level, and the expression is then evaluated on the *current*
! level.
! 
! Since this function depends upon the undocumented IDL routine routine_names,
! there is no guarantee that this will work with future versions of IDL."
!   (let ((prefix "___")         ;; No real variables should starts with this.
!       (fetch (- 0 level))
        (start 0)
!         var tvar fetch-vars pre post)
  
!      ;; FIXME: In the following we try to find the variables in expression
      ;; This is quite empirical - I don't know in what situations this will
      ;; break.  We will look for identifiers and exclude cases where we
      ;; know it is not a variable.  To distinguish array references from
      ;; function calls, we require that arrays use [] instead of ()
! 
      (while (string-match
!           
"\\(\\`\\|[^a-zA-Z0-9$_]\\)\\([a-zA-Z][a-zA-Z0-9$_]*\\)\\([^a-zA-Z0-9$_]\\|\\'\\)"
 expr start)
        (setq var (match-string 2 expr)
-           tvar (concat prefix var)
            start (match-beginning 2)
            pre (substring expr 0 (match-beginning 2))
            post (substring expr (match-end 2)))
--- 3053,3082 ----
        (erase-buffer)
        (setq buffer-read-only t)))))
  
! (defun idlwave-retrieve-expression-from-level (expr level)
    "Return IDL command to print the expression EXPR from stack level LEVEL.
  
! It does not seem possible to evaluate an expression on a different
! level than the current.  Therefore, this function retrieves variables
! by reference from other levels, and then includes that variable in
! place of the chosen one.
! 
! Since this function depends upon the undocumented IDL routine
! routine_names, there is no guarantee that this will work with future
! versions of IDL."
!   (let ((fetch (- 0 level))
        (start 0)
!         var rnvar pre post)
  
!     ;; FIXME: In the following we try to find the variables in expression
      ;; This is quite empirical - I don't know in what situations this will
      ;; break.  We will look for identifiers and exclude cases where we
      ;; know it is not a variable.  To distinguish array references from
      ;; function calls, we require that arrays use [] instead of ()
!     
      (while (string-match
!           "\\(\\`\\|[^a-zA-Z0-9$_][ \t]*\\)\\([a-zA-Z][a-zA-Z0-9$_]*\\)\\([ 
\t]*[^a-zA-Z0-9$_]\\|\\'\\)" expr start)
        (setq var (match-string 2 expr)
            start (match-beginning 2)
            pre (substring expr 0 (match-beginning 2))
            post (substring expr (match-end 2)))
***************
*** 2659,2680 ****
         ((string-match "\\`(" post))              ;; a function
         ((string-match "->[ \t]*\\'" pre))        ;; a method
         ((string-match "\\.\\'" pre))             ;; structure member
!        (t ;; seems to be a variable - arrange to get it and replace
!       ;; its name in the expression with the temproary name.
!       (push (cons var tvar) fetch-vars)
!       (setq expr (concat pre tvar post))))
!       (if (= start 0) (setq start 1)))
!     ;; Make a command line that first copies the relevant variables
!     ;; and then prints the expression.
!     (concat
!      (mapconcat
!       (lambda (x)
!       (format "%s = routine_names('%s',fetch=%d)" (cdr x) (car x) fetch))
!       (nreverse fetch-vars)
!       " & ")
!      "\n"
!      (idlwave-shell-help-statement help expr)
!      (format " ; [-%d:%s]" level routine))))
  
  (defun idlwave-shell-help-statement (help expr)
    "Construct a help statement for printing expression EXPR.
--- 3088,3103 ----
         ((string-match "\\`(" post))              ;; a function
         ((string-match "->[ \t]*\\'" pre))        ;; a method
         ((string-match "\\.\\'" pre))             ;; structure member
!        ((and (string-match "\\([\"\']\\)[^\1]*$" pre)
!            (string-match (concat "^[^" (match-string 1 pre) "]*" 
!                                  (match-string 1 pre)) post)))
!        (t ;; seems to be a variable - replace its name in the
!         ;; expression with the fetch.
!       (setq rnvar (format "(routine_names('%s',fetch=%d))" var fetch)
!             expr  (concat pre rnvar post)
!             start (+ start (length rnvar))))))
!     expr))
! 
  
  (defun idlwave-shell-help-statement (help expr)
    "Construct a help statement for printing expression EXPR.
***************
*** 2684,2696 ****
  size(___,/DIMENSIONS)"
    (cond
     ((null help) (concat "print, " expr))
!    ((stringp help)
      (if (string-match "\\(^\\|[^_]\\)\\(___\\)\\([^_]\\|$\\)" help)
        (concat (substring help 0 (match-beginning 2))
                expr
                (substring help (match-end 2)))))
     (t (concat "help, " expr))))
! 
  
  (defun idlwave-shell-examine-highlight ()
    "Highlight the most recent IDL output."
--- 3107,3119 ----
  size(___,/DIMENSIONS)"
    (cond
     ((null help) (concat "print, " expr))
!    ((stringp help) 
      (if (string-match "\\(^\\|[^_]\\)\\(___\\)\\([^_]\\|$\\)" help)
        (concat (substring help 0 (match-beginning 2))
                expr
                (substring help (match-end 2)))))
     (t (concat "help, " expr))))
!    
  
  (defun idlwave-shell-examine-highlight ()
    "Highlight the most recent IDL output."
***************
*** 2698,2704 ****
         (process (get-buffer-process buffer))
         (process-mark (if process (process-mark process)))
         output-begin output-end)
!     (save-excursion
        (set-buffer buffer)
        (goto-char process-mark)
        (beginning-of-line)
--- 3121,3127 ----
         (process (get-buffer-process buffer))
         (process-mark (if process (process-mark process)))
         output-begin output-end)
!     (save-excursion 
        (set-buffer buffer)
        (goto-char process-mark)
        (beginning-of-line)
***************
*** 2706,2731 ****
        (re-search-backward idlwave-shell-prompt-pattern nil t)
        (beginning-of-line 2)
        (setq output-begin (point)))
! 
      ;; First make sure the shell window is visible
      (idlwave-display-buffer (idlwave-shell-buffer)
                            nil (idlwave-shell-shell-frame))
      (if (and idlwave-shell-output-overlay process-mark)
!       (move-overlay idlwave-shell-output-overlay
                      output-begin output-end buffer))))
  
  (defun idlwave-shell-delete-output-overlay ()
!   (if (eq this-command 'idlwave-shell-mouse-nop)
!       nil
      (condition-case nil
        (if idlwave-shell-output-overlay
            (delete-overlay idlwave-shell-output-overlay))
        (error nil))
      (remove-hook 'pre-command-hook 'idlwave-shell-delete-output-overlay)))
! 
  (defun idlwave-shell-delete-expression-overlay ()
!   (if (eq this-command 'idlwave-shell-mouse-nop)
!       nil
      (condition-case nil
        (if idlwave-shell-expression-overlay
            (delete-overlay idlwave-shell-expression-overlay))
--- 3129,3154 ----
        (re-search-backward idlwave-shell-prompt-pattern nil t)
        (beginning-of-line 2)
        (setq output-begin (point)))
!           
      ;; First make sure the shell window is visible
      (idlwave-display-buffer (idlwave-shell-buffer)
                            nil (idlwave-shell-shell-frame))
      (if (and idlwave-shell-output-overlay process-mark)
!       (move-overlay idlwave-shell-output-overlay 
                      output-begin output-end buffer))))
  
  (defun idlwave-shell-delete-output-overlay ()
!   (unless (or (eq this-command 'idlwave-shell-mouse-nop)
!             (eq this-command 'handle-switch-frame))
      (condition-case nil
        (if idlwave-shell-output-overlay
            (delete-overlay idlwave-shell-output-overlay))
        (error nil))
      (remove-hook 'pre-command-hook 'idlwave-shell-delete-output-overlay)))
!   
  (defun idlwave-shell-delete-expression-overlay ()
!   (unless (or (eq this-command 'idlwave-shell-mouse-nop)
!             (eq this-command 'handle-switch-frame))
      (condition-case nil
        (if idlwave-shell-expression-overlay
            (delete-overlay idlwave-shell-expression-overlay))
***************
*** 2736,2742 ****
    "Alist of breakpoints.
  A breakpoint is a cons cell \(\(file line\) . \(\(index module\) data\)\)
  
! The car is the frame for the breakpoint:
  file - full path file name.
  line - line number of breakpoint - integer.
  
--- 3159,3165 ----
    "Alist of breakpoints.
  A breakpoint is a cons cell \(\(file line\) . \(\(index module\) data\)\)
  
! The car is the `frame' for the breakpoint:
  file - full path file name.
  line - line number of breakpoint - integer.
  
***************
*** 2746,2758 ****
  
  Remaining elements of the cdr:
  data - Data associated with the breakpoint by idlwave-shell currently
! contains two items:
  
  count - number of times to execute breakpoint. When count reaches 0
! the breakpoint is cleared and removed from the alist.
! command - command to execute when breakpoint is reached, either a
! lisp function to be called with `funcall' with no arguments or a
! list to be evaluated with `eval'.")
  
  (defun idlwave-shell-run-region (beg end &optional n)
    "Compile and run the region using the IDL process.
--- 3169,3186 ----
  
  Remaining elements of the cdr:
  data - Data associated with the breakpoint by idlwave-shell currently
! contains four items:
  
  count - number of times to execute breakpoint. When count reaches 0
!   the breakpoint is cleared and removed from the alist.
! 
! command - command to execute when breakpoint is reached, either a 
!   lisp function to be called with `funcall' with no arguments or a
!   list to be evaluated with `eval'.
! 
! condition - any condition to apply to the breakpoint.
! 
! disabled - whether the bp is disabled")
  
  (defun idlwave-shell-run-region (beg end &optional n)
    "Compile and run the region using the IDL process.
***************
*** 2779,2787 ****
            (insert "\nend\n"))
        (save-buffer 0)))
    (idlwave-shell-send-command (concat ".run " idlwave-shell-temp-pro-file)
!                             nil (idlwave-shell-hide-p 'run))
    (if n
!       (idlwave-display-buffer (idlwave-shell-buffer)
                              nil (idlwave-shell-shell-frame))))
  
  (defun idlwave-shell-evaluate-region (beg end &optional n)
--- 3207,3217 ----
            (insert "\nend\n"))
        (save-buffer 0)))
    (idlwave-shell-send-command (concat ".run " idlwave-shell-temp-pro-file)
!                             nil 
!                             (if (idlwave-shell-hide-p 'run) 'mostly)
!                             nil t)
    (if n
!       (idlwave-display-buffer (idlwave-shell-buffer) 
                              nil (idlwave-shell-shell-frame))))
  
  (defun idlwave-shell-evaluate-region (beg end &optional n)
***************
*** 2792,2798 ****
    (interactive "r\nP")
    (idlwave-shell-send-command (buffer-substring beg end))
    (if n
!       (idlwave-display-buffer (idlwave-shell-buffer)
                              nil (idlwave-shell-shell-frame))))
  
  (defun idlwave-shell-delete-temp-files ()
--- 3222,3228 ----
    (interactive "r\nP")
    (idlwave-shell-send-command (buffer-substring beg end))
    (if n
!       (idlwave-display-buffer (idlwave-shell-buffer) 
                              nil (idlwave-shell-shell-frame))))
  
  (defun idlwave-shell-delete-temp-files ()
***************
*** 2816,2856 ****
        (display-buffer buf not-this-window-p frame)
      ;; For Emacs, we need to force the frame ourselves.
      (let ((this-frame (selected-frame)))
!       (if (frame-live-p frame)
!           (select-frame frame))
!       (if (eq this-frame (selected-frame))
!           ;; same frame:  use display buffer, to make sure the current
!           ;; window stays.
!           (display-buffer buf)
!         ;; different frame
!         (if (one-window-p)
!             ;; only window:  switch
!             (progn
!               (switch-to-buffer buf)
!               (selected-window))   ; must return the window.
!         ;; several windows - use display-buffer
!           (display-buffer buf not-this-window-p))))))
  ;  (if (not (frame-live-p frame)) (setq frame nil))
  ;  (display-buffer buf not-this-window-p frame))
  
  (defvar idlwave-shell-bp-buffer " *idlwave-shell-bp*"
    "Scratch buffer for parsing IDL breakpoint lists and other stuff.")
  
! (defun idlwave-shell-bp-query ()
    "Reconcile idlwave-shell's breakpoint list with IDL's.
  Queries IDL using the string in `idlwave-shell-bp-query'."
    (interactive)
    (idlwave-shell-send-command idlwave-shell-bp-query
!                             'idlwave-shell-filter-bp
                              'hide))
  
  (defun idlwave-shell-bp-get (bp &optional item)
!   "Get a value for a breakpoint.
! BP has the form of elements in idlwave-shell-bp-alist.
! Optional second arg ITEM is the particular value to retrieve.
! ITEM can be 'file, 'line, 'index, 'module, 'count, 'cmd, or 'data.
! 'data returns a list of 'count and 'cmd.
! Defaults to 'index."
    (cond
     ;; Frame
     ((eq item 'line) (nth 1 (car bp)))
--- 3246,3288 ----
        (display-buffer buf not-this-window-p frame)
      ;; For Emacs, we need to force the frame ourselves.
      (let ((this-frame (selected-frame)))
!       (save-excursion ;; make sure we end up in the same buffer
!       (if (frame-live-p frame)
!           (select-frame frame))
!       (if (eq this-frame (selected-frame))
!           ;; same frame:  use display buffer, to make sure the current
!           ;; window stays.
!           (display-buffer buf)
!         ;; different frame
!         (if (one-window-p)
!             ;; only window:  switch
!             (progn
!               (switch-to-buffer buf)
!               (selected-window))   ; must return the window.
!           ;; several windows - use display-buffer
!           (display-buffer buf not-this-window-p)))))))
  ;  (if (not (frame-live-p frame)) (setq frame nil))
  ;  (display-buffer buf not-this-window-p frame))
  
  (defvar idlwave-shell-bp-buffer " *idlwave-shell-bp*"
    "Scratch buffer for parsing IDL breakpoint lists and other stuff.")
  
! (defun idlwave-shell-bp-query (&optional no-show)
    "Reconcile idlwave-shell's breakpoint list with IDL's.
  Queries IDL using the string in `idlwave-shell-bp-query'."
    (interactive)
    (idlwave-shell-send-command idlwave-shell-bp-query
!                             `(progn
!                               (idlwave-shell-filter-bp (quote ,no-show)))
                              'hide))
  
  (defun idlwave-shell-bp-get (bp &optional item)
!   "Get a value for a breakpoint.  
! BP has the form of elements in idlwave-shell-bp-alist.  Optional
! second arg ITEM is the particular value to retrieve.  ITEM can be
! 'file, 'line, 'index, 'module, 'count, 'cmd, 'condition, 'disabled or
! 'data.  'data returns a list of 'count, 'cmd and 'condition.  Defaults
! to 'index."
    (cond
     ;; Frame
     ((eq item 'line) (nth 1 (car bp)))
***************
*** 2860,2874 ****
     ((eq item 'count) (nth 0 (cdr (cdr bp))))
     ((eq item 'cmd) (nth 1 (cdr (cdr bp))))
     ((eq item 'condition) (nth 2 (cdr (cdr bp))))
     ;; IDL breakpoint info
     ((eq item 'module) (nth 1 (car (cdr bp))))
     ;;    index - default
     (t (nth 0 (car (cdr bp))))))
  
! (defun idlwave-shell-filter-bp ()
!   "Get the breakpoints from `idlwave-shell-command-output'.
! Create `idlwave-shell-bp-alist' updating breakpoint count and command data
! from previous breakpoint list."
    (save-excursion
      (set-buffer (get-buffer-create idlwave-shell-bp-buffer))
      (erase-buffer)
--- 3292,3308 ----
     ((eq item 'count) (nth 0 (cdr (cdr bp))))
     ((eq item 'cmd) (nth 1 (cdr (cdr bp))))
     ((eq item 'condition) (nth 2 (cdr (cdr bp))))
+    ((eq item 'disabled) (nth 3 (cdr (cdr bp))))
     ;; IDL breakpoint info
     ((eq item 'module) (nth 1 (car (cdr bp))))
     ;;    index - default
     (t (nth 0 (car (cdr bp))))))
  
! (defun idlwave-shell-filter-bp (&optional no-show)
!   "Get the breakpoints from `idlwave-shell-command-output'.  Create
! `idlwave-shell-bp-alist' updating breakpoint count and command data
! from previous breakpoint list.  If NO-SHOW is set, don't update the
! breakpoint overlays."
    (save-excursion
      (set-buffer (get-buffer-create idlwave-shell-bp-buffer))
      (erase-buffer)
***************
*** 2878,2931 ****
          ;; Searching the breakpoints
          ;; In IDL 5.5, the breakpoint reporting format changed.
          (bp-re54 "^[ \t]*\\([0-9]+\\)[ \t]+\\(\\S-+\\)?[ \t]+\\([0-9]+\\)[ 
\t]+\\(\\S-+\\)")
!         (bp-re55 
"^\\s-*\\([0-9]+\\)\\s-+\\([0-9]+\\)\\s-+\\(Uncompiled\\|Func=\\|Pro=\\)\\([a-zA-Z][a-zA-Z0-9$_:]*\\)\\(,[^\n]*\n\\)?\\s-+\\(\\S-+\\)")
          file line index module
          bp-re indmap)
        (setq idlwave-shell-bp-alist (list nil))
        ;; Search for either header type, and set the correct regexp
!       (when (or
             (if (re-search-forward "^\\s-*Index.*\n\\s-*-" nil t)
!                (setq bp-re bp-re54    ; versions <= 5.4
!                      indmap '(1 2 3 4)))
!            (if (re-search-forward
                  "^\\s-*Index\\s-*Line\\s-*Attributes\\s-*File" nil t)
                 (setq bp-re bp-re55    ; versions >= 5.5
!                      indmap '(1 4 2 6))))
!       ;; There seems to be a breakpoint listing here.
!       ;; Parse breakpoint lines.
!       ;; Breakpoints have the form
!         ;;    for IDL<=v5.4:
!       ;;  Index Module Line File
!       ;;  All separated by whitespace.
!       ;;  Module may be missing if the file is not compiled.
!         ;;    for IDL>=v5.5:
!       ;;  Index Line Attributes File
!       ;;    (attributes replaces module, "Uncompiled" included)
        (while (re-search-forward bp-re nil t)
!         (setq index (match-string (nth 0 indmap))
                module (match-string (nth 1 indmap))
                line (string-to-int (match-string (nth 2 indmap)))
                file (idlwave-shell-file-name (match-string (nth 3 indmap))))
          ;; Add the breakpoint info to the list
          (nconc idlwave-shell-bp-alist
                 (list (cons (list file line)
                             (list
                              (list index module)
!                             ;; idlwave-shell data: count, command
!                             nil nil))))))
        (setq idlwave-shell-bp-alist (cdr idlwave-shell-bp-alist))
!       ;; Update count, commands of breakpoints
!       (mapcar 'idlwave-shell-update-bp old-bp-alist)))
    ;; Update the breakpoint overlays
!   (idlwave-shell-update-bp-overlays)
    ;; Return the new list
    idlwave-shell-bp-alist)
  
! (defun idlwave-shell-update-bp (bp)
    "Update BP data in breakpoint list.
  If BP frame is in `idlwave-shell-bp-alist' updates the breakpoint data."
    (let ((match (assoc (car bp) idlwave-shell-bp-alist)))
!     (if match (setcdr (cdr match) (cdr (cdr bp))))))
  
  (defun idlwave-shell-set-bp-data (bp data)
    "Set the data of BP to DATA."
--- 3312,3382 ----
          ;; Searching the breakpoints
          ;; In IDL 5.5, the breakpoint reporting format changed.
          (bp-re54 "^[ \t]*\\([0-9]+\\)[ \t]+\\(\\S-+\\)?[ \t]+\\([0-9]+\\)[ 
\t]+\\(\\S-+\\)")
!         (bp-re55 
!          (concat 
!           "^\\s-*\\([0-9]+\\)"    ; 1 index
!           "\\s-+\\([0-9]+\\)"     ; 2 line number
!           "\\s-+\\(Uncompiled\\|" ; 3-6 either uncompiled or routine name
!           "\\(\\(Func=\\|Pro=\\)\\(\\$?[a-zA-Z][a-zA-Z0-9$_:]*\\$?\\)\\)\\)"
!           "\\(\\s-*,\\s-*After=[0-9]+/\\([0-9]+\\)?\\)?" ; 7-8 After part
!           "\\(\\s-*,\\s-*\\(BreakOnce\\)\\)?"            ; 9-10 BreakOnce
!           "\\(\\s-*,\\s-*\\(Condition='\\(.*\\)'\\)\n?\\)?" ; 11-13 Condition
!           "\\(\\s-*,\\s-*\\(Disabled\\)\n?\\)?"          ; 14-15 Disabled
!           "\\s-+\\(\\S-+\\)"))                           ; 16 File name
          file line index module
+         count condition disabled
          bp-re indmap)
        (setq idlwave-shell-bp-alist (list nil))
        ;; Search for either header type, and set the correct regexp
!       (when (or 
             (if (re-search-forward "^\\s-*Index.*\n\\s-*-" nil t)
!                (setq bp-re bp-re54    ; versions <= 5.4 
!                      indmap '(1 2 3 4))) ;index module line file
!            (if (re-search-forward 
                  "^\\s-*Index\\s-*Line\\s-*Attributes\\s-*File" nil t)
                 (setq bp-re bp-re55    ; versions >= 5.5
!                      indmap '(1 6 2 16)))) ; index module line file
!       ;; There seems to be a breakpoint listing here, parse breakpoint lines.
        (while (re-search-forward bp-re nil t)
!         (setq index (string-to-int (match-string (nth 0 indmap)))
                module (match-string (nth 1 indmap))
                line (string-to-int (match-string (nth 2 indmap)))
                file (idlwave-shell-file-name (match-string (nth 3 indmap))))
+         (if (eq bp-re bp-re55)
+             (setq count (if (match-string 10) 1 
+                           (if (match-string 8)
+                               (string-to-int (match-string 8))))
+                   condition (match-string 13)
+                   disabled (not (null (match-string 15)))))
+                   
          ;; Add the breakpoint info to the list
          (nconc idlwave-shell-bp-alist
                 (list (cons (list file line)
                             (list
                              (list index module)
!                             ;; bp data: count, command, condition, disabled
!                             count nil condition disabled))))))
        (setq idlwave-shell-bp-alist (cdr idlwave-shell-bp-alist))
!       ;; Update breakpoint data
!       (if (eq bp-re bp-re54) 
!         (mapcar 'idlwave-shell-update-bp old-bp-alist)
!       (mapcar 'idlwave-shell-update-bp-command-only old-bp-alist))))
    ;; Update the breakpoint overlays
!   (unless no-show (idlwave-shell-update-bp-overlays))
    ;; Return the new list
    idlwave-shell-bp-alist)
  
! (defun idlwave-shell-update-bp-command-only (bp)
!   (idlwave-shell-update-bp bp t))
! 
! (defun idlwave-shell-update-bp (bp &optional command-only)
    "Update BP data in breakpoint list.
  If BP frame is in `idlwave-shell-bp-alist' updates the breakpoint data."
    (let ((match (assoc (car bp) idlwave-shell-bp-alist)))
!     (if match 
!       (if command-only 
!           (setf (nth 1 (cdr (cdr match))) (nth 1 (cdr (cdr match))))
!         (setcdr (cdr match) (cdr (cdr bp)))))))
  
  (defun idlwave-shell-set-bp-data (bp data)
    "Set the data of BP to DATA."
***************
*** 2948,2989 ****
    (let*
        ((bp-file (idlwave-shell-bp-get bp 'file))
         (bp-module (idlwave-shell-bp-get bp 'module))
!        (internal-file-list (cdr (assoc bp-module 
idlwave-shell-sources-alist))))
      (if (and internal-file-list
             (equal bp-file (nth 0 internal-file-list)))
          (nth 1 internal-file-list)
        bp-file)))
  
! (defun idlwave-shell-set-bp (bp)
!   "Try to set a breakpoint BP.
! 
  The breakpoint will be placed at the beginning of the statement on the
  line specified by BP or at the next IDL statement if that line is not
! a statement.
! Determines IDL's internal representation for the breakpoint which may
! have occurred at a different line then used with the breakpoint
! command."
! 
    ;; Get and save the old breakpoints
!   (idlwave-shell-send-command
     idlwave-shell-bp-query
!    '(progn
!       (idlwave-shell-filter-bp)
!       (setq idlwave-shell-old-bp idlwave-shell-bp-alist))
     'hide)
    ;; Get sources for IDL compiled procedures followed by setting
    ;; breakpoint.
    (idlwave-shell-send-command
     idlwave-shell-sources-query
     `(progn
!       (idlwave-shell-sources-filter)
!       (idlwave-shell-set-bp2 (quote ,bp)))
     'hide))
  
! (defun idlwave-shell-set-bp2 (bp)
    "Use results of breakpoint and sources query to set bp.
  Use the count argument with IDLs breakpoint command.
! We treat a count of 1 as a temporary breakpoint.
  Counts greater than 1 use the IDL AFTER=count keyword to break
  only after reaching the statement count times."
    (let*
--- 3399,3438 ----
    (let*
        ((bp-file (idlwave-shell-bp-get bp 'file))
         (bp-module (idlwave-shell-bp-get bp 'module))
!        (internal-file-list 
!       (cdr (assoc bp-module idlwave-shell-sources-alist))))
      (if (and internal-file-list
             (equal bp-file (nth 0 internal-file-list)))
          (nth 1 internal-file-list)
        bp-file)))
  
! (defun idlwave-shell-set-bp (bp &optional no-show)
!   "Try to set a breakpoint BP.  
  The breakpoint will be placed at the beginning of the statement on the
  line specified by BP or at the next IDL statement if that line is not
! a statement.  Determines IDL's internal representation for the
! breakpoint, which may have occured at a different line than
! specified.  If NO-SHOW is non-nil, don't do any updating."
    ;; Get and save the old breakpoints
!   (idlwave-shell-send-command 
     idlwave-shell-bp-query
!    `(progn
!      (idlwave-shell-filter-bp (quote ,no-show))
!      (setq idlwave-shell-old-bp idlwave-shell-bp-alist))
     'hide)
    ;; Get sources for IDL compiled procedures followed by setting
    ;; breakpoint.
    (idlwave-shell-send-command
     idlwave-shell-sources-query
     `(progn
!      (idlwave-shell-sources-filter)
!      (idlwave-shell-set-bp2 (quote ,bp) (quote ,no-show)))
     'hide))
  
! (defun idlwave-shell-set-bp2 (bp &optional no-show)
    "Use results of breakpoint and sources query to set bp.
  Use the count argument with IDLs breakpoint command.
! We treat a count of 1 as a temporary breakpoint. 
  Counts greater than 1 use the IDL AFTER=count keyword to break
  only after reaching the statement count times."
    (let*
***************
*** 2995,3022 ****
                ((> arg 1)
                 (format ",after=%d" arg))))
         (condition (idlwave-shell-bp-get bp 'condition))
!        (key (concat key
                    (if condition (concat ",CONDITION=\"" condition "\""))))
         (line (idlwave-shell-bp-get bp 'line)))
      (idlwave-shell-send-command
!      (concat "breakpoint,'"
             (idlwave-shell-sources-bp bp) "',"
             (if (integerp line) (setq line (int-to-string line)))
             key)
       ;; Check for failure and look for breakpoint in IDL's list
       `(progn
!        (if (idlwave-shell-set-bp-check (quote ,bp))
!            (idlwave-shell-set-bp3 (quote ,bp))))
       ;; hide output?
       (idlwave-shell-hide-p 'breakpoint)
!      'preempt)))
  
! (defun idlwave-shell-set-bp3 (bp)
    "Find the breakpoint in IDL's internal list of breakpoints."
    (idlwave-shell-send-command idlwave-shell-bp-query
                              `(progn
!                                 (idlwave-shell-filter-bp)
!                                 (idlwave-shell-new-bp (quote ,bp)))
                              'hide
                              'preempt))
  
--- 3444,3473 ----
                ((> arg 1)
                 (format ",after=%d" arg))))
         (condition (idlwave-shell-bp-get bp 'condition))
!        (key (concat key 
                    (if condition (concat ",CONDITION=\"" condition "\""))))
         (line (idlwave-shell-bp-get bp 'line)))
      (idlwave-shell-send-command
!      (concat "breakpoint,'" 
             (idlwave-shell-sources-bp bp) "',"
             (if (integerp line) (setq line (int-to-string line)))
             key)
       ;; Check for failure and look for breakpoint in IDL's list
       `(progn
!       (if (idlwave-shell-set-bp-check (quote ,bp))
!            (idlwave-shell-set-bp3 (quote ,bp) (quote ,no-show))))
       ;; hide output?
       (idlwave-shell-hide-p 'breakpoint)
!      'preempt t)))
  
! (defun idlwave-shell-set-bp3 (bp &optional no-show)
    "Find the breakpoint in IDL's internal list of breakpoints."
    (idlwave-shell-send-command idlwave-shell-bp-query
                              `(progn
!                                (idlwave-shell-filter-bp (quote ,no-show))
!                                (idlwave-shell-new-bp (quote ,bp))
!                                (unless (quote ,no-show)
!                                  (idlwave-shell-update-bp-overlays)))
                              'hide
                              'preempt))
  
***************
*** 3025,3030 ****
--- 3476,3495 ----
  Returns nil if frame not found."
    (assoc frame idlwave-shell-bp-alist))
  
+ (defun idlwave-shell-find-current-bp ()
+   "Find breakpoint here, or at halt location."
+   (let ((bp (idlwave-shell-find-bp (idlwave-shell-current-frame))))
+     (when (not bp)
+       ;; Try moving to beginning of halted-at statement
+       (save-excursion
+       (idlwave-shell-goto-frame)
+       (idlwave-beginning-of-statement)
+       (setq bp (idlwave-shell-find-bp (idlwave-shell-current-frame))))
+       (unless bp
+       (beep)
+       (message "Cannot identify breakpoint for this line")))
+     bp))
+ 
  (defun idlwave-shell-new-bp (bp)
    "Find the new breakpoint in IDL's list and update with DATA.
  The actual line number for a breakpoint in IDL may be different than
***************
*** 3052,3122 ****
        (message "Failed to identify breakpoint in IDL"))))
  
  (defvar idlwave-shell-bp-overlays nil
!   "List of overlays marking breakpoints")
  
  (defun idlwave-shell-update-bp-overlays ()
    "Update the overlays which mark breakpoints in the source code.
  Existing overlays are recycled, in order to minimize consumption."
    (when idlwave-shell-mark-breakpoints
!     (let ((bp-list idlwave-shell-bp-alist)
!         (ov-list idlwave-shell-bp-overlays)
!         ov bp)
        ;; Delete the old overlays from their buffers
!       (while (setq ov (pop ov-list))
!       (delete-overlay ov))
!       (setq ov-list idlwave-shell-bp-overlays
!           idlwave-shell-bp-overlays nil)
        (while (setq bp (pop bp-list))
        (save-excursion
          (idlwave-shell-goto-frame (car bp))
          (let* ((end (progn (end-of-line 1) (point)))
                 (beg (progn (beginning-of-line 1) (point)))
!                (ov (or (pop ov-list)
!                        (idlwave-shell-make-new-bp-overlay))))
            (move-overlay ov beg end)
!           (push ov idlwave-shell-bp-overlays)))))))
  
  (defvar idlwave-shell-bp-glyph)
! (defun idlwave-shell-make-new-bp-overlay ()
!   "Make a new overlay for highlighting breakpoints.
! This stuff is stringly dependant upon the version of Emacs."
!   (let ((ov (make-overlay 1 1)))
      (if (featurep 'xemacs)
        ;; This is XEmacs
        (progn
!         (cond
           ((eq (console-type) 'tty)
!           ;; tty's cannot display glyphs
!           (set-extent-property ov 'face idlwave-shell-breakpoint-face))
!          ((and (memq idlwave-shell-mark-breakpoints '(t glyph))
!                idlwave-shell-bp-glyph)
!           ;; use the glyph
!           (set-extent-property ov 'begin-glyph idlwave-shell-bp-glyph))
           (idlwave-shell-mark-breakpoints
!           ;; use the face
!           (set-extent-property ov 'face idlwave-shell-breakpoint-face))
!          (t
!           ;; no marking
!           nil))
          (set-extent-priority ov -1))  ; make stop line face prevail
        ;; This is Emacs
        (cond
         (window-system
!       (if (and (memq idlwave-shell-mark-breakpoints '(t glyph))
!                idlwave-shell-bp-glyph)   ; this var knows if glyph's possible
!           ;; use a glyph
!           (let ((string "@"))
!             (put-text-property 0 1
!                                'display idlwave-shell-bp-glyph
!                                string)
              (overlay-put ov 'before-string string))
!         (overlay-put ov 'face idlwave-shell-breakpoint-face)))
         (idlwave-shell-mark-breakpoints
!       ;; use a face
!       (overlay-put ov 'face idlwave-shell-breakpoint-face))
!        (t
!       ;; No marking
!       nil)))
      ov))
  
  (defun idlwave-shell-edit-default-command-line (arg)
--- 3517,3675 ----
        (message "Failed to identify breakpoint in IDL"))))
  
  (defvar idlwave-shell-bp-overlays nil
!   "Alist of overlays marking breakpoints")
  
  (defun idlwave-shell-update-bp-overlays ()
    "Update the overlays which mark breakpoints in the source code.
  Existing overlays are recycled, in order to minimize consumption."
+   ;(message "Updating Overlays")
    (when idlwave-shell-mark-breakpoints
!     (let ((ov-alist (copy-alist idlwave-shell-bp-overlays))
!         (bp-list idlwave-shell-bp-alist)
!         (use-glyph (and (memq idlwave-shell-mark-breakpoints '(t glyph))
!                         idlwave-shell-bp-glyph))
!         ov ov-list bp buf old-buffers win)
! 
        ;; Delete the old overlays from their buffers
!       (if ov-alist 
!         (while (setq ov-list (pop ov-alist))
!           (while (setq ov (pop (cdr ov-list)))
!             (add-to-list 'old-buffers (overlay-buffer ov))
!             (delete-overlay ov))))
!       
!       (setq ov-alist idlwave-shell-bp-overlays
!           idlwave-shell-bp-overlays 
!           (if idlwave-shell-bp-glyph
!               (mapcar 'list (mapcar 'car idlwave-shell-bp-glyph))
!             (list (list 'bp))))
        (while (setq bp (pop bp-list))
        (save-excursion
          (idlwave-shell-goto-frame (car bp))
          (let* ((end (progn (end-of-line 1) (point)))
                 (beg (progn (beginning-of-line 1) (point)))
!                (condition (idlwave-shell-bp-get bp 'condition))
!                (count (idlwave-shell-bp-get bp 'count))
!                (disabled (idlwave-shell-bp-get bp 'disabled))
!                (type (if idlwave-shell-bp-glyph
!                          (cond
!                           (condition 'bp-cond )
!                           (count
!                            (cond
!                             ((<= count 0) 'bp)
!                             ((<= count 4)
!                              (intern
!                               (concat "bp-" (number-to-string count))))
!                             (t 'bp-n)))
!                           (t 'bp))
!                        'bp))
!                (help-list 
!                 (delq nil
!                       (list
!                        (if count
!                            (concat "n=" (int-to-string count)))
!                        (if condition
!                            (concat "condition: " condition))
!                        (if disabled "disabled"))))
!                (help-text (if help-list 
!                               (mapconcat 'identity help-list ",")))
!                (full-type (if disabled
!                               (intern (concat (symbol-name type)
!                                               "-disabled"))
!                             type))
!                (ov-existing (assq full-type ov-alist))
!                (ov (or (and (cdr ov-existing)
!                             (pop (cdr ov-existing)))
!                        (idlwave-shell-make-new-bp-overlay 
!                         type disabled help-text)))
!                match)
            (move-overlay ov beg end)
!           (if (setq match (assq full-type idlwave-shell-bp-overlays))
!               (push ov (cdr match))
!             (nconc idlwave-shell-bp-overlays
!                    (list (list full-type ov)))))
!         ;; Take care of margins if using a glyph
!         (when use-glyph
!           (if old-buffers 
!               (setq old-buffers (delq (current-buffer) old-buffers)))
!           (if (fboundp 'set-specifier) ;; XEmacs
!               (set-specifier left-margin-width (cons (current-buffer) 2))
!             (setq left-margin-width 2))
!           (if (setq win (get-buffer-window (current-buffer) t))
!               (set-window-buffer win (current-buffer))))))
!       (if use-glyph
!         (while (setq buf (pop old-buffers))
!           (with-current-buffer buf
!             (if (fboundp 'set-specifier) ;; XEmacs
!                 (set-specifier left-margin-width (cons (current-buffer) 0))
!               (setq left-margin-width 0))
!             (if (setq win (get-buffer-window buf t))
!                 (set-window-buffer win buf))))))))
! 
  
  (defvar idlwave-shell-bp-glyph)
! (defun idlwave-shell-make-new-bp-overlay (&optional type disabled help)
!   "Make a new overlay for highlighting breakpoints.  
! 
! This stuff is strongly dependant upon the version of Emacs.  If TYPE
! is passed, make an overlay of that type ('bp or 'bp-cond, currently
! only for glyphs).  If HELP is set, use it to make a tooltip with that
! text popup."
!   (let ((ov (make-overlay 1 1))
!       (use-glyph (and (memq idlwave-shell-mark-breakpoints '(t glyph))
!                       idlwave-shell-bp-glyph))
!       (type (or type 'bp))
!       (face (if disabled 
!                 idlwave-shell-disabled-breakpoint-face
!               idlwave-shell-breakpoint-face)))
      (if (featurep 'xemacs)
        ;; This is XEmacs
        (progn
!         (cond 
!          ;; tty's cannot display glyphs
           ((eq (console-type) 'tty)
!           (set-extent-property ov 'face face))
!           
!          ;; use the glyph
!          (use-glyph
!           (let ((glyph (cdr (assq type idlwave-shell-bp-glyph))))
!             (if disabled (setq glyph (car glyph)) (setq glyph (nth 1 glyph)))
!             (set-extent-property ov 'begin-glyph glyph)
!             (set-extent-property ov 'begin-glyph-layout 'outside-margin)))
! 
!          ;; use the face
           (idlwave-shell-mark-breakpoints
!           (set-extent-property ov 'face face))
! 
!          ;; no marking
!          (t nil))
          (set-extent-priority ov -1))  ; make stop line face prevail
        ;; This is Emacs
        (cond
         (window-system
!       (if use-glyph
!           (let ((image-props (cdr (assq type idlwave-shell-bp-glyph)))
!                 string)
!             
!             (if disabled (setq image-props
!                                (append image-props 
!                                        (list :conversion 'disabled))))
!             (setq string 
!                  (propertize "@" 
!                              'display 
!                              (list (list 'margin 'left-margin)
!                                    image-props)
!                              'mouse-face 'highlight
!                              'help-echo help))
              (overlay-put ov 'before-string string))
!         ;; just the face
!         (overlay-put ov 'face face)))
! 
!        ;; use a face
         (idlwave-shell-mark-breakpoints
!       (overlay-put ov 'face face))
! 
!        ;; No marking
!        (t nil)))
      ov))
  
  (defun idlwave-shell-edit-default-command-line (arg)
***************
*** 3127,3148 ****
  
  (defun idlwave-shell-execute-default-command-line (arg)
    "Execute a command line.  On first use, ask for the command.
! Also with prefix arg, ask for the command.  You can also uase the command
  `idlwave-shell-edit-default-command-line' to edit the line."
    (interactive "P")
!   (if (or (not idlwave-shell-command-line-to-execute)
!         arg)
!       (setq idlwave-shell-command-line-to-execute
!           (read-string "IDL> " idlwave-shell-command-line-to-execute)))
    (idlwave-shell-reset 'hidden)
!   (idlwave-shell-send-command idlwave-shell-command-line-to-execute
!                             '(idlwave-shell-redisplay 'hide)))
  
  (defun idlwave-shell-save-and-run ()
    "Save file and run it in IDL.
  Runs `save-buffer' and sends a '.RUN' command for the associated file to IDL.
  When called from the shell buffer, re-run the file which was last handled by
! one of the save-and-.. commands."
    (interactive)
    (idlwave-shell-save-and-action 'run))
  
--- 3680,3706 ----
  
  (defun idlwave-shell-execute-default-command-line (arg)
    "Execute a command line.  On first use, ask for the command.
! Also with prefix arg, ask for the command.  You can also use the command
  `idlwave-shell-edit-default-command-line' to edit the line."
    (interactive "P")
!   (cond 
!    ((equal arg '(16))
!     (setq idlwave-shell-command-line-to-execute nil))
!    ((equal arg '(4))
!     (setq idlwave-shell-command-line-to-execute 
!         (read-string "IDL> " idlwave-shell-command-line-to-execute))))
    (idlwave-shell-reset 'hidden)
!   (idlwave-shell-send-command 
!    (or idlwave-shell-command-line-to-execute
!        (with-current-buffer (idlwave-shell-buffer)
!        (ring-ref comint-input-ring 0)))
!    '(idlwave-shell-redisplay 'hide)))
  
  (defun idlwave-shell-save-and-run ()
    "Save file and run it in IDL.
  Runs `save-buffer' and sends a '.RUN' command for the associated file to IDL.
  When called from the shell buffer, re-run the file which was last handled by
! one of the save-and-.. commands."  
    (interactive)
    (idlwave-shell-save-and-action 'run))
  
***************
*** 3158,3164 ****
    "Save file and batch it in IDL.
  Runs `save-buffer' and sends a '@file' command for the associated file to IDL.
  When called from the shell buffer, re-batch the file which was last handled by
! one of the save-and-.. commands."
    (interactive)
    (idlwave-shell-save-and-action 'batch))
  
--- 3716,3722 ----
    "Save file and batch it in IDL.
  Runs `save-buffer' and sends a '@file' command for the associated file to IDL.
  When called from the shell buffer, re-batch the file which was last handled by
! one of the save-and-.. commands."  
    (interactive)
    (idlwave-shell-save-and-action 'batch))
  
***************
*** 3170,3175 ****
--- 3728,3735 ----
    ;; Remove the stop overlay.
    (if idlwave-shell-stop-line-overlay
        (delete-overlay idlwave-shell-stop-line-overlay))
+   (if idlwave-shell-is-stopped
+       (idlwave-shell-electric-debug-all-off))
    (setq idlwave-shell-is-stopped nil)
    (setq overlay-arrow-string nil)
    (let (buf)
***************
*** 3194,3202 ****
                       (t (error "Unknown action %s" action)))
                 idlwave-shell-last-save-and-action-file)
         'idlwave-shell-maybe-update-routine-info
!        (idlwave-shell-hide-p 'run))
        (idlwave-shell-bp-query))
!     (let ((msg (format "No such file %s"
                       idlwave-shell-last-save-and-action-file)))
        (setq idlwave-shell-last-save-and-action-file nil)
        (error msg))))
--- 3754,3762 ----
                       (t (error "Unknown action %s" action)))
                 idlwave-shell-last-save-and-action-file)
         'idlwave-shell-maybe-update-routine-info
!        (if (idlwave-shell-hide-p 'run) 'mostly) nil t)
        (idlwave-shell-bp-query))
!     (let ((msg (format "No such file %s" 
                       idlwave-shell-last-save-and-action-file)))
        (setq idlwave-shell-last-save-and-action-file nil)
        (error msg))))
***************
*** 3208,3214 ****
               (memq 'compile-buffer idlwave-auto-routine-info-updates))
           idlwave-query-shell-for-routine-info
           idlwave-routines)
!       (idlwave-shell-update-routine-info t nil 'wait)))
  
  (defvar idlwave-shell-sources-query "help,/source,/full"
    "IDL command to obtain source files for compiled procedures.")
--- 3768,3774 ----
               (memq 'compile-buffer idlwave-auto-routine-info-updates))
           idlwave-query-shell-for-routine-info
           idlwave-routines)
!       (idlwave-shell-update-routine-info t nil wait)))
  
  (defvar idlwave-shell-sources-query "help,/source,/full"
    "IDL command to obtain source files for compiled procedures.")
***************
*** 3222,3235 ****
  (defun idlwave-shell-sources-query ()
    "Determine source files for IDL compiled procedures.
  Queries IDL using the string in `idlwave-shell-sources-query'."
!   (interactive)
    (idlwave-shell-send-command idlwave-shell-sources-query
                              'idlwave-shell-sources-filter
                              'hide))
  
  (defun idlwave-shell-sources-filter ()
    "Get source files from `idlwave-shell-sources-query' output.
! Create `idlwave-shell-sources-alist' consisting of
  list elements of the form:
   (module name . (source-file-truename idlwave-internal-filename))."
    (save-excursion
--- 3782,3795 ----
  (defun idlwave-shell-sources-query ()
    "Determine source files for IDL compiled procedures.
  Queries IDL using the string in `idlwave-shell-sources-query'."
! '  (interactive)
    (idlwave-shell-send-command idlwave-shell-sources-query
                              'idlwave-shell-sources-filter
                              'hide))
  
  (defun idlwave-shell-sources-filter ()
    "Get source files from `idlwave-shell-sources-query' output.
! Create `idlwave-shell-sources-alist' consisting of 
  list elements of the form:
   (module name . (source-file-truename idlwave-internal-filename))."
    (save-excursion
***************
*** 3306,3319 ****
      (save-excursion
        (set-buffer idlwave-shell-error-buffer)
        (goto-char idlwave-shell-error-last)
!       (if (or (re-search-forward idlwave-shell-syntax-error nil t)
!               (re-search-forward idlwave-shell-other-error nil t))
            (progn
              (setq frame
                    (list
                     (save-match-data
                       (idlwave-shell-file-name
!                       (buffer-substring (match-beginning 1) (match-end 1))))
                     (string-to-int
                      (buffer-substring (match-beginning 2)
                                        (match-end 2)))))
--- 3866,3881 ----
      (save-excursion
        (set-buffer idlwave-shell-error-buffer)
        (goto-char idlwave-shell-error-last)
!       (if (or
!          (re-search-forward idlwave-shell-syntax-error nil t)
!          (re-search-forward idlwave-shell-other-error nil t))
            (progn
              (setq frame
                    (list
                     (save-match-data
                       (idlwave-shell-file-name
!                       (buffer-substring (match-beginning 1 ) 
!                                       (match-end 1))))
                     (string-to-int
                      (buffer-substring (match-beginning 2)
                                        (match-end 2)))))
***************
*** 3326,3332 ****
        (setq idlwave-shell-error-last (point)))
      (if frame
          (progn
!           (idlwave-shell-display-line frame col))
        (beep)
        (message "No more errors."))))
  
--- 3888,3894 ----
        (setq idlwave-shell-error-last (point)))
      (if frame
          (progn
!           (idlwave-shell-display-line frame col 'no-debug))
        (beep)
        (message "No more errors."))))
  
***************
*** 3340,3351 ****
        (file-truename name def-dir)
        (expand-file-name name def-dir))))
  
! ;; Keybindings --------------------------------------------------------------
  
  (defvar idlwave-shell-mode-map (copy-keymap comint-mode-map)
    "Keymap for idlwave-mode.")
  (defvar idlwave-shell-mode-prefix-map (make-sparse-keymap))
  (fset 'idlwave-shell-mode-prefix-map idlwave-shell-mode-prefix-map)
  
  ;(define-key idlwave-shell-mode-map "\M-?" 'comint-dynamic-list-completions)
  ;(define-key idlwave-shell-mode-map "\t" 'comint-dynamic-complete)
--- 3902,3921 ----
        (file-truename name def-dir)
        (expand-file-name name def-dir))))
  
! ;; Keybindings ------------------------------------------------------------
  
  (defvar idlwave-shell-mode-map (copy-keymap comint-mode-map)
    "Keymap for idlwave-mode.")
+ (defvar idlwave-shell-electric-debug-mode-map (make-sparse-keymap))
  (defvar idlwave-shell-mode-prefix-map (make-sparse-keymap))
  (fset 'idlwave-shell-mode-prefix-map idlwave-shell-mode-prefix-map)
+ (defvar idlwave-mode-prefix-map (make-sparse-keymap))
+ (fset 'idlwave-mode-prefix-map idlwave-mode-prefix-map)
+ 
+ (defun idlwave-shell-define-key-both (key hook)
+   "Define a key in both the shell and buffer mode maps."
+   (define-key idlwave-mode-map key hook)
+   (define-key idlwave-shell-mode-map key hook))
  
  ;(define-key idlwave-shell-mode-map "\M-?" 'comint-dynamic-list-completions)
  ;(define-key idlwave-shell-mode-map "\t" 'comint-dynamic-complete)
***************
*** 3371,3383 ****
  
  ;; The mouse bindings for PRINT and HELP
  (idlwave-shell-define-key-both
!  (if (featurep 'xemacs)
!      [(shift button2)]
     [(shift down-mouse-2)])
   'idlwave-shell-mouse-print)
  (idlwave-shell-define-key-both
!  (if (featurep 'xemacs)
!      [(control meta button2)]
     [(control meta down-mouse-2)])
    'idlwave-shell-mouse-help)
  (idlwave-shell-define-key-both
--- 3941,3953 ----
  
  ;; The mouse bindings for PRINT and HELP
  (idlwave-shell-define-key-both
!  (if (featurep 'xemacs) 
!      [(shift button2)] 
     [(shift down-mouse-2)])
   'idlwave-shell-mouse-print)
  (idlwave-shell-define-key-both
!  (if (featurep 'xemacs) 
!      [(control meta button2)] 
     [(control meta down-mouse-2)])
    'idlwave-shell-mouse-help)
  (idlwave-shell-define-key-both
***************
*** 3386,3399 ****
     [(control shift down-mouse-2)])
   'idlwave-shell-examine-select)
  ;; Add this one from the idlwave-mode-map
! (define-key idlwave-shell-mode-map
    (if (featurep 'xemacs)
        [(shift button3)]
      [(shift mouse-3)])
    'idlwave-mouse-context-help)
  
  ;; For Emacs, we need to turn off the button release events.
! (defun idlwave-shell-mouse-nop (event)
    (interactive "e"))
  (unless (featurep 'xemacs)
    (idlwave-shell-define-key-both
--- 3956,3969 ----
     [(control shift down-mouse-2)])
   'idlwave-shell-examine-select)
  ;; Add this one from the idlwave-mode-map
! (define-key idlwave-shell-mode-map 
    (if (featurep 'xemacs)
        [(shift button3)]
      [(shift mouse-3)])
    'idlwave-mouse-context-help)
  
  ;; For Emacs, we need to turn off the button release events.
! (defun idlwave-shell-mouse-nop (event) 
    (interactive "e"))
  (unless (featurep 'xemacs)
    (idlwave-shell-define-key-both
***************
*** 3403,3445 ****
    (idlwave-shell-define-key-both
     [(control meta mouse-2)] 'idlwave-shell-mouse-nop))
  
! 
  ;; The following set of bindings is used to bind the debugging keys.
! ;; If `idlwave-shell-activate-prefix-keybindings' is non-nil, the first key
! ;; in the list gets bound the C-c C-d prefix map.
! ;; If `idlwave-shell-debug-modifiers' is non-nil, the second key
! ;; in the list gets bound with the specified modifiers in both
! ;; `idlwave-mode-map' and `idlwave-shell-mode-map'.
! 
! ;; Used keys:   abcdef hi klmnopqrs u wxyz
! ;; Unused keys:       g  j         t v
  (let* ((specs
!       '(([(control ?b)]   ?b   idlwave-shell-break-here)
!         ([(control ?i)]   ?i   idlwave-shell-break-in)
!         ([(control ?d)]   ?d   idlwave-shell-clear-current-bp)
!         ([(control ?a)]   ?a   idlwave-shell-clear-all-bp)
!         ([(control ?s)]   ?s   idlwave-shell-step)
!         ([(control ?n)]   ?n   idlwave-shell-stepover)
!         ([(control ?k)]   ?k   idlwave-shell-skip)
!         ([(control ?u)]   ?u   idlwave-shell-up)
!         ([(control ?o)]   ?o   idlwave-shell-out)
!         ([(control ?m)]   ?m   idlwave-shell-return)
!         ([(control ?h)]   ?h   idlwave-shell-to-here)
!         ([(control ?r)]   ?r   idlwave-shell-cont)
          ([(control ?y)]   ?y   idlwave-shell-execute-default-command-line)
!         ([(control ?z)]   ?z   idlwave-shell-reset)
          ([(control ?q)]   ?q   idlwave-shell-quit)
!         ([(control ?p)]   ?p   idlwave-shell-print)
!         ([(??)]           ??   idlwave-shell-help-expression)
!         ([(control ?c)]   ?c   idlwave-shell-save-and-run)
!         ([(        ?@)]   ?@   idlwave-shell-save-and-batch)
          ([(control ?x)]   ?x   idlwave-shell-goto-next-error)
          ([(control ?e)]   ?e   idlwave-shell-run-region)
          ([(control ?w)]   ?w   idlwave-shell-resync-dirs)
!         ([(control ?l)]   ?l   idlwave-shell-redisplay)
          ([(control ?t)]   ?t   idlwave-shell-toggle-toolbar)
          ([(control up)]   up   idlwave-shell-stack-up)
          ([(control down)] down idlwave-shell-stack-down)
          ([(control ?f)]   ?f   idlwave-shell-window)))
         (mod (cond ((and idlwave-shell-debug-modifiers
                        (listp idlwave-shell-debug-modifiers)
--- 3973,4023 ----
    (idlwave-shell-define-key-both
     [(control meta mouse-2)] 'idlwave-shell-mouse-nop))
  
!   
  ;; The following set of bindings is used to bind the debugging keys.
! ;; If `idlwave-shell-activate-prefix-keybindings' is non-nil, the
! ;; first key in the list gets bound the C-c C-d prefix map.  If
! ;; `idlwave-shell-debug-modifiers' is non-nil, the second key in the
! ;; list gets bound with the specified modifiers in both
! ;; `idlwave-mode-map' and `idlwave-shell-mode-map'.  The next list
! ;; item, if non-nil, means to bind this as a single key in the
! ;; electric-debug-mode-map.
! ;; 
! ;; [C-c C-d]-binding   debug-modifier-key command bind-electric-debug buf-only
! ;; Used keys:   abcdef hijklmnopqrstuvwxyz 
! ;; Unused keys:       g             
  (let* ((specs
!       '(([(control ?b)]   ?b   idlwave-shell-break-here t t)
!         ([(control ?i)]   ?i   idlwave-shell-break-in t t)
!         ([(control ?j)]   ?j   idlwave-shell-break-this-module t t)
!         ([(control ?d)]   ?d   idlwave-shell-clear-current-bp t)
!         ([(control ?a)]   ?a   idlwave-shell-clear-all-bp t)
!         ([(control ?\\)]  ?\\  idlwave-shell-toggle-enable-current-bp t)
!         ([(control ?s)]   ?s   idlwave-shell-step t)
!         ([(control ?n)]   ?n   idlwave-shell-stepover t)
!         ([(control ?k)]   ?k   idlwave-shell-skip t)
!         ([(control ?u)]   ?u   idlwave-shell-up t)
!         ([(control ?o)]   ?o   idlwave-shell-out t)
!         ([(control ?m)]   ?m   idlwave-shell-return t)
!         ([(control ?h)]   ?h   idlwave-shell-to-here t t)
!         ([(control ?r)]   ?r   idlwave-shell-cont t)
          ([(control ?y)]   ?y   idlwave-shell-execute-default-command-line)
!         ([(control ?z)]   ?z   idlwave-shell-reset t)
          ([(control ?q)]   ?q   idlwave-shell-quit)
!         ([(control ?p)]   ?p   idlwave-shell-print t)
!         ([(        ??)]   ??   idlwave-shell-help-expression t)
!         ([(control ?v)]   ?v   idlwave-shell-toggle-electric-debug-mode t t)
          ([(control ?x)]   ?x   idlwave-shell-goto-next-error)
+         ([(control ?c)]   ?c   idlwave-shell-save-and-run t)
+         ([(        ?@)]   ?@   idlwave-shell-save-and-batch)
          ([(control ?e)]   ?e   idlwave-shell-run-region)
          ([(control ?w)]   ?w   idlwave-shell-resync-dirs)
!         ([(control ?l)]   ?l   idlwave-shell-redisplay t)
          ([(control ?t)]   ?t   idlwave-shell-toggle-toolbar)
          ([(control up)]   up   idlwave-shell-stack-up)
          ([(control down)] down idlwave-shell-stack-down)
+         ([(        ?[)]   ?[   idlwave-shell-goto-previous-bp t t)
+         ([(        ?])]   ?]   idlwave-shell-goto-next-bp t t)
          ([(control ?f)]   ?f   idlwave-shell-window)))
         (mod (cond ((and idlwave-shell-debug-modifiers
                        (listp idlwave-shell-debug-modifiers)
***************
*** 3449,3527 ****
                   '(alt))))
         (shift (memq 'shift mod))
         (mod-noshift (delete 'shift (copy-sequence mod)))
!        s k1 c2 k2 cmd)
    (while (setq s (pop specs))
      (setq k1  (nth 0 s)
          c2  (nth 1 s)
!         cmd (nth 2 s))
!     (when idlwave-shell-activate-prefix-keybindings
!       (and k1 (define-key idlwave-shell-mode-prefix-map k1 cmd)))
      (when (and mod window-system)
        (if (char-or-string-p c2)
          (setq k2 (vector (append mod-noshift
                                   (list (if shift (upcase c2) c2)))))
        (setq k2 (vector (append mod (list c2)))))
!       (define-key idlwave-mode-map       k2 cmd)
!       (define-key idlwave-shell-mode-map k2 cmd))))
  
! ;; Enter the prefix map at the two places.
! (fset 'idlwave-debug-map       idlwave-shell-mode-prefix-map)
  (fset 'idlwave-shell-debug-map idlwave-shell-mode-prefix-map)
  
! ;; The Menus --------------------------------------------------------------
  
  (defvar idlwave-shell-menu-def
!   '("Debug"
!     ["Save and .RUN" idlwave-shell-save-and-run
!      (or (eq major-mode 'idlwave-mode)
!        idlwave-shell-last-save-and-action-file)]
!     ["Save and .COMPILE" idlwave-shell-save-and-compile
!      (or (eq major-mode 'idlwave-mode)
!        idlwave-shell-last-save-and-action-file)]
!     ["Save and @Batch" idlwave-shell-save-and-batch
!      (or (eq major-mode 'idlwave-mode)
!        idlwave-shell-last-save-and-action-file)]
!     ["Goto Next Error" idlwave-shell-goto-next-error t]
!     "--"
!     ["Execute Default Cmd" idlwave-shell-execute-default-command-line t]
!     ["Edit Default Cmd" idlwave-shell-edit-default-command-line t]
!     "--"
!     ["Set Breakpoint" idlwave-shell-break-here
!      (eq major-mode 'idlwave-mode)]
!     ["Break in Module" idlwave-shell-break-in t]
!     ["Clear Breakpoint" idlwave-shell-clear-current-bp t]
!     ["Clear All Breakpoints" idlwave-shell-clear-all-bp t]
!     ["List  All Breakpoints" idlwave-shell-list-all-bp t]
!     "--"
!     ["Step (into)" idlwave-shell-step t]
!     ["Step (over)" idlwave-shell-stepover t]
!     ["Skip One Statement" idlwave-shell-skip t]
!     ["Continue" idlwave-shell-cont t]
!     ("Continue to"
!      ["End of Block" idlwave-shell-up t]
!      ["End of Subprog" idlwave-shell-return t]
!      ["End of Subprog+1" idlwave-shell-out t]
!      ["Here (Cursor Line)" idlwave-shell-to-here
!       (eq major-mode 'idlwave-mode)])
      "--"
-     ["Print expression" idlwave-shell-print t]
-     ["Help on expression" idlwave-shell-help-expression t]
-     ["Evaluate Region" idlwave-shell-evaluate-region
-      (eq major-mode 'idlwave-mode)]
-     ["Run Region" idlwave-shell-run-region (eq major-mode 'idlwave-mode)]
-     "--"
-     ["Redisplay" idlwave-shell-redisplay t]
-     ["Stack Up" idlwave-shell-stack-up t]
-     ["Stack Down" idlwave-shell-stack-down t]
-     "--"
-     ["Update Working Dir" idlwave-shell-resync-dirs t]
-     ["Reset IDL" idlwave-shell-reset t]
-     "--"
-     ["Toggle Toolbar" idlwave-shell-toggle-toolbar t]
-     ["Exit IDL" idlwave-shell-quit t]))
- 
- (setq idlwave-shell-menu-def
-   '("Debug"
      ("Compile & Run"
       ["Save and .RUN" idlwave-shell-save-and-run
        (or (eq major-mode 'idlwave-mode)
--- 4027,4180 ----
                   '(alt))))
         (shift (memq 'shift mod))
         (mod-noshift (delete 'shift (copy-sequence mod)))
!        s k1 c2 k2 cmd cannotshift)
    (while (setq s (pop specs))
      (setq k1  (nth 0 s)
          c2  (nth 1 s)
!         cmd (nth 2 s)
!         electric (nth 3 s)
!         only-buffer (nth 4 s)
!         cannotshift (and shift (char-valid-p c2) (eq c2 (upcase c2))))
!     
!     ;; The regular prefix keymap.
!     (when (and idlwave-shell-activate-prefix-keybindings k1)
!       (unless only-buffer 
!       (define-key idlwave-shell-mode-prefix-map k1 cmd))
!       (define-key idlwave-mode-prefix-map k1 cmd))
!     ;; The debug modifier map
      (when (and mod window-system)
        (if (char-or-string-p c2)
          (setq k2 (vector (append mod-noshift
                                   (list (if shift (upcase c2) c2)))))
        (setq k2 (vector (append mod (list c2)))))
!       (unless cannotshift
!       (define-key idlwave-mode-map k2 cmd)
!       (unless only-buffer (define-key idlwave-shell-mode-map k2 cmd))))
!     ;; The electric debug single-keystroke map
!     (if (and electric (char-or-string-p c2))
!       (define-key idlwave-shell-electric-debug-mode-map (char-to-string c2) 
!         cmd))))
! 
! ;; A few extras in the electric debug map
! (define-key idlwave-shell-electric-debug-mode-map " " 'idlwave-shell-step)
! (define-key idlwave-shell-electric-debug-mode-map "+" 'idlwave-shell-stack-up)
! (define-key idlwave-shell-electric-debug-mode-map "=" 'idlwave-shell-stack-up)
! (define-key idlwave-shell-electric-debug-mode-map "-" 
!   'idlwave-shell-stack-down)
! (define-key idlwave-shell-electric-debug-mode-map "_" 
!   'idlwave-shell-stack-down)
! (define-key idlwave-shell-electric-debug-mode-map "q" 'idlwave-shell-retall)
! (define-key idlwave-shell-electric-debug-mode-map "t" 
!   '(lambda () (interactive) (idlwave-shell-send-command "help,/TRACE")))
! (define-key idlwave-shell-electric-debug-mode-map [(control ??)]
!   'idlwave-shell-electric-debug-help)
! (define-key idlwave-shell-electric-debug-mode-map "x" 
!   '(lambda (arg) (interactive "P") 
!      (idlwave-shell-print arg nil nil t)))
  
! 
! ; Enter the prefix map in two places.
! (fset 'idlwave-debug-map       idlwave-mode-prefix-map)
  (fset 'idlwave-shell-debug-map idlwave-shell-mode-prefix-map)
  
! ;; The Electric Debug Minor Mode --------------------------------------------
! 
! (defun idlwave-shell-toggle-electric-debug-mode ()
!   "Toggle electric-debug-mode, suppressing re-entry into mode if turned off."
!   (interactive)
!   ;; If turning it off, make sure it stays off throughout the debug
!   ;; session until we return or hit $MAIN$.  Cancel this suppression
!   ;; if it's explicitly turned on.
!   (if idlwave-shell-electric-debug-mode
!       (setq idlwave-shell-suppress-electric-debug t)
!     (setq idlwave-shell-suppress-electric-debug nil))
!   (idlwave-shell-electric-debug-mode))
! 
! (easy-mmode-define-minor-mode idlwave-shell-electric-debug-mode
!   "Toggle Electric Debug mode.
! With no argument, this command toggles the mode. 
! Non-null prefix argument turns on the mode.
! Null prefix argument turns off the mode.
! 
! When Electric Debug mode is enabled, the many debugging commands are
! available as single key sequences."
! nil
! " *Debugging*"
! idlwave-shell-electric-debug-mode-map)
! 
! (add-hook 
!  'idlwave-shell-electric-debug-mode-on-hook
!  (lambda ()
!    (set (make-local-variable 'idlwave-shell-electric-debug-read-only)
!       buffer-read-only)
!    (setq buffer-read-only t)
!    (add-to-list 'idlwave-shell-electric-debug-buffers (current-buffer))
!    (if idlwave-shell-stop-line-overlay
!        (overlay-put idlwave-shell-stop-line-overlay 'face 
!                   idlwave-shell-electric-stop-line-face))
!    (if (facep 'fringe)
!        (set-face-foreground 'fringe idlwave-shell-electric-stop-color
!                           (selected-frame)))))
! 
! (add-hook 
!  'idlwave-shell-electric-debug-mode-off-hook
!  (lambda ()
!    ;; Return to previous read-only state
!    (setq buffer-read-only (if (boundp 'idlwave-shell-electric-debug-read-only)
!                             idlwave-shell-electric-debug-read-only))
!    (setq idlwave-shell-electric-debug-buffers
!        (delq (current-buffer) idlwave-shell-electric-debug-buffers))
!    (if idlwave-shell-stop-line-overlay
!        (overlay-put idlwave-shell-stop-line-overlay 'face 
!                   idlwave-shell-stop-line-face)
!      (if (facep 'fringe)
!        (set-face-foreground 'fringe (face-foreground 'default))))))
! 
! ;; easy-mmode defines electric-debug-mode for us, so we need to advise it.
! (defadvice idlwave-shell-electric-debug-mode (after print-enter activate)
!   "Print out an entrance message"
!   (when idlwave-shell-electric-debug-mode
!     (message
!      "Electric Debugging mode entered.  Press [C-?] for help, [q] to quit"))
!   (force-mode-line-update))
  
+ ;; Turn it off in all relevant buffers
+ (defvar idlwave-shell-electric-debug-buffers nil)
+ (defun idlwave-shell-electric-debug-all-off ()
+   (setq idlwave-shell-suppress-electric-debug nil)
+   (let ((buffers idlwave-shell-electric-debug-buffers)
+       buf)
+     (save-excursion
+       (while (setq buf (pop buffers))
+       (when (buffer-live-p buf)
+         (set-buffer buf)
+         (when (and (eq major-mode 'idlwave-mode)
+                    buffer-file-name
+                    idlwave-shell-electric-debug-mode)
+           (idlwave-shell-electric-debug-mode))))))
+   (setq idlwave-shell-electric-debug-buffers nil))
+ 
+ ;; Show the help text
+ (defun idlwave-shell-electric-debug-help ()
+   (interactive)
+   (with-output-to-temp-buffer "*IDLWAVE Electric Debug Help*" 
+     (princ idlwave-shell-electric-debug-help))
+   (let* ((current-window (selected-window))
+        (window (get-buffer-window "*IDLWAVE Electric Debug Help*"))
+        (window-lines (window-height window)))
+     (select-window window)
+     (enlarge-window (1+ (- (count-lines 1 (point-max)) window-lines)))
+     (select-window current-window)))
+ 
+ 
+ ;; The Menus --------------------------------------------------------------
  (defvar idlwave-shell-menu-def
!   `("Debug"
!     ["Electric Debug Mode"
!      idlwave-shell-electric-debug-mode
!      :style toggle :selected idlwave-shell-electric-debug-mode 
!      :included (eq major-mode 'idlwave-mode) :keys "C-c C-d C-v"]
      "--"
      ("Compile & Run"
       ["Save and .RUN" idlwave-shell-save-and-run
        (or (eq major-mode 'idlwave-mode)
***************
*** 3532,3550 ****
       ["Save and @Batch" idlwave-shell-save-and-batch
        (or (eq major-mode 'idlwave-mode)
          idlwave-shell-last-save-and-action-file)]
       ["Goto Next Error" idlwave-shell-goto-next-error t]
       "--"
!      ["Run Region" idlwave-shell-run-region (eq major-mode 'idlwave-mode)]
       "--"
       ["Execute Default Cmd" idlwave-shell-execute-default-command-line t]
       ["Edit Default Cmd" idlwave-shell-edit-default-command-line t])
      ("Breakpoints"
!      ["Set Breakpoint" idlwave-shell-break-here
!       (eq major-mode 'idlwave-mode)]
!      ["Break in Module" idlwave-shell-break-in t]
       ["Clear Breakpoint" idlwave-shell-clear-current-bp t]
       ["Clear All Breakpoints" idlwave-shell-clear-all-bp t]
!      ["List  All Breakpoints" idlwave-shell-list-all-bp t])
      ("Continue/Step"
       ["Step (into)" idlwave-shell-step t]
       ["Step (over)" idlwave-shell-stepover t]
--- 4185,4225 ----
       ["Save and @Batch" idlwave-shell-save-and-batch
        (or (eq major-mode 'idlwave-mode)
          idlwave-shell-last-save-and-action-file)]
+      "--"
       ["Goto Next Error" idlwave-shell-goto-next-error t]
       "--"
!      ["Compile and Run Region" idlwave-shell-run-region 
!       (eq major-mode 'idlwave-mode)]
!      ["Evaluate Region" idlwave-shell-evaluate-region 
!       (eq major-mode 'idlwave-mode)]
       "--"
       ["Execute Default Cmd" idlwave-shell-execute-default-command-line t]
       ["Edit Default Cmd" idlwave-shell-edit-default-command-line t])
      ("Breakpoints"
!      ["Set Breakpoint" idlwave-shell-break-here 
!       :keys "C-c C-d C-c" :active (eq major-mode 'idlwave-mode)]
!      ("Set Special Breakpoint"
!       ["Set After Count Breakpoint"
!        (progn
!       (let ((count (string-to-int (read-string "Break after count: "))))
!             (if (integerp count) (idlwave-shell-break-here count))))
!        :active (eq major-mode 'idlwave-mode)]
!       ["Set Condition Breakpoint"
!        (idlwave-shell-break-here '(4))
!        :active (eq major-mode 'idlwave-mode)])
!      ["Break in Module" idlwave-shell-break-in 
!       :keys "C-c C-d C-i" :active (eq major-mode 'idlwave-mode)]
!      ["Break in this Module" idlwave-shell-break-this-module
!       :keys "C-c C-d C-j" :active (eq major-mode 'idlwave-mode)]
       ["Clear Breakpoint" idlwave-shell-clear-current-bp t]
       ["Clear All Breakpoints" idlwave-shell-clear-all-bp t]
!      ["Disable/Enable Breakpoint" idlwave-shell-toggle-enable-current-bp t]
!      ["Goto Previous Breakpoint" idlwave-shell-goto-previous-bp 
!       :keys "C-c C-d [" :active (eq major-mode 'idlwave-mode)]
!      ["Goto Next Breakpoint" idlwave-shell-goto-next-bp 
!       :keys "C-c C-d ]" :active (eq major-mode 'idlwave-mode)]
!      ["List All Breakpoints" idlwave-shell-list-all-bp t]
!      ["Resync Breakpoints" idlwave-shell-bp-query t])
      ("Continue/Step"
       ["Step (into)" idlwave-shell-step t]
       ["Step (over)" idlwave-shell-stepover t]
***************
*** 3554,3569 ****
       ["... to End of Subprog" idlwave-shell-return t]
       ["... to End of Subprog+1" idlwave-shell-out t]
       ["... to Here (Cursor Line)" idlwave-shell-to-here
!       (eq major-mode 'idlwave-mode)])
!     ("Print Expression"
       ["Print expression" idlwave-shell-print t]
       ["Help on expression" idlwave-shell-help-expression t]
!      ["Evaluate Region" idlwave-shell-evaluate-region
!       (eq major-mode 'idlwave-mode)]
!      "--"
!      ["Redisplay" idlwave-shell-redisplay t]
       ["Stack Up" idlwave-shell-stack-up t]
!      ["Stack Down" idlwave-shell-stack-down t])
      ("Input Mode"
       ["Send one char" idlwave-shell-send-char t]
       ["Temporary Character Mode" idlwave-shell-char-mode-loop t]
--- 4229,4288 ----
       ["... to End of Subprog" idlwave-shell-return t]
       ["... to End of Subprog+1" idlwave-shell-out t]
       ["... to Here (Cursor Line)" idlwave-shell-to-here
!       :keys "C-c C-d C-h" :active (eq major-mode 'idlwave-mode)])
!     ("Examine Expressions"
       ["Print expression" idlwave-shell-print t]
       ["Help on expression" idlwave-shell-help-expression t]
!      ("Examine nearby expression with"
!       ,@(mapcar (lambda(x)
!                 `[ ,(car x) (idlwave-shell-print nil ',x) t ])
!               idlwave-shell-examine-alist))
!      ("Examine region with"
!       ,@(mapcar (lambda(x)
!                 `[ ,(car x) (idlwave-shell-print '(4) ',x) t ])
!               idlwave-shell-examine-alist)))
!     ("Call Stack"
       ["Stack Up" idlwave-shell-stack-up t]
!      ["Stack Down" idlwave-shell-stack-down t]
!      "--"
!      ["Redisplay and Sync" idlwave-shell-redisplay t])
!     ("Show Commands"
!      ["Everything" (if (eq idlwave-shell-show-commands 'everything)
!                      (progn 
!                        (setq idlwave-shell-show-commands
!                              (get 'idlwave-shell-show-commands 'last-val))
!                        (put 'idlwave-shell-show-commands 'last-val nil))
!                    (put 'idlwave-shell-show-commands 'last-val 
!                         idlwave-shell-show-commands)
!                    (setq idlwave-shell-show-commands 'everything))
!       :style toggle :selected (and (not (listp idlwave-shell-show-commands))
!                                  (eq idlwave-shell-show-commands 
!                                      'everything))]
!      "--"
!      ["Compiling Commands" (idlwave-shell-add-or-remove-show 'run)
!       :style toggle 
!       :selected (not (idlwave-shell-hide-p 
!                     'run
!                     (get 'idlwave-shell-show-commands 'last-val)))
!       :active (not (eq idlwave-shell-show-commands 'everything))]
!      ["Breakpoint Commands" (idlwave-shell-add-or-remove-show 'breakpoint)
!       :style toggle 
!       :selected (not (idlwave-shell-hide-p 
!                     'breakpoint
!                     (get 'idlwave-shell-show-commands 'last-val)))
!       :active (not (eq idlwave-shell-show-commands 'everything))]
!      ["Debug Commands" (idlwave-shell-add-or-remove-show 'debug)
!       :style toggle 
!       :selected (not (idlwave-shell-hide-p 
!                     'debug
!                     (get 'idlwave-shell-show-commands 'last-val)))
!       :active (not (eq idlwave-shell-show-commands 'everything))]
!      ["Miscellaneous Commands" (idlwave-shell-add-or-remove-show 'misc)
!       :style toggle 
!       :selected (not (idlwave-shell-hide-p 
!                     'misc
!                     (get 'idlwave-shell-show-commands 'last-val)))
!       :active (not (eq idlwave-shell-show-commands 'everything))])
      ("Input Mode"
       ["Send one char" idlwave-shell-send-char t]
       ["Temporary Character Mode" idlwave-shell-char-mode-loop t]
***************
*** 3574,3579 ****
--- 4293,4303 ----
        :style toggle :selected idlwave-shell-use-input-mode-magic])
      "--"
      ["Update Working Dir" idlwave-shell-resync-dirs t]
+     ["Save Path Info" 
+      (idlwave-shell-send-command idlwave-shell-path-query
+                                'idlwave-shell-get-path-info
+                                'hide)
+      t]
      ["Reset IDL" idlwave-shell-reset t]
      "--"
      ["Toggle Toolbar" idlwave-shell-toggle-toolbar t]
***************
*** 3581,3591 ****
  
  (if (or (featurep 'easymenu) (load "easymenu" t))
      (progn
!       (easy-menu-define
!        idlwave-shell-mode-menu idlwave-shell-mode-map "IDL shell menus"
         idlwave-shell-menu-def)
        (easy-menu-define
!        idlwave-mode-debug-menu idlwave-mode-map "IDL debugging menus"
         idlwave-shell-menu-def)
        (save-excursion
        (mapcar (lambda (buf)
--- 4305,4315 ----
  
  (if (or (featurep 'easymenu) (load "easymenu" t))
      (progn
!       (easy-menu-define 
!        idlwave-mode-debug-menu idlwave-mode-map "IDL debugging menus"
         idlwave-shell-menu-def)
        (easy-menu-define
!        idlwave-shell-mode-menu idlwave-shell-mode-map "IDL shell menus"
         idlwave-shell-menu-def)
        (save-excursion
        (mapcar (lambda (buf)
***************
*** 3599,3641 ****
  ;; The Breakpoint Glyph 
-------------------------------------------------------
  
  (defvar idlwave-shell-bp-glyph nil
!   "The glyph to mark breakpoint lines in the source code.")
  
! (let ((image-string "/* XPM */
  static char * file[] = {
  \"14 12 3 1\",
  \"    c None s backgroundColor\",
  \".   c #4B4B4B4B4B4B\",
  \"R   c #FFFF00000000\",
  \"              \",
  \"              \",
! \"    RRRR      \",
! \"   RRRRRR     \",
! \"  RRRRRRRR    \",
! \"  RRRRRRRR    \",
! \"  RRRRRRRR    \",
! \"  RRRRRRRR    \",
! \"   RRRRRR     \",
! \"    RRRR      \",
  \"              \",
! \"              \"};"))
! 
!   (setq idlwave-shell-bp-glyph
!       (cond ((and (featurep 'xemacs)
!                   (featurep 'xpm))
!              (make-glyph image-string))
!             ((and (not (featurep 'xemacs))
!                   (fboundp 'image-type-available-p)
!                   (image-type-available-p 'xpm))
!              (list 'image :type 'xpm :data image-string :ascent 'center))
!             (t nil))))
  
  (provide 'idlw-shell)
  (provide 'idlwave-shell)
  
  ;;; Load the toolbar when wanted by the user.
  
! (autoload 'idlwave-toolbar-toggle "idlw-toolbar"
    "Toggle the IDLWAVE toolbar")
  (autoload 'idlwave-toolbar-add-everywhere "idlw-toolbar"
    "Add IDLWAVE toolbar")
--- 4323,4487 ----
  ;; The Breakpoint Glyph 
-------------------------------------------------------
  
  (defvar idlwave-shell-bp-glyph nil
!   "The glyphs to mark breakpoint lines in the source code.")
  
! (let ((image-alist 
!        '((bp . "/* XPM */
  static char * file[] = {
  \"14 12 3 1\",
  \"    c None s backgroundColor\",
  \".   c #4B4B4B4B4B4B\",
  \"R   c #FFFF00000000\",
  \"              \",
+ \"     ....     \",
+ \"    .RRRR.    \",
+ \"   .RRRRRR.   \",
+ \"  .RRRRRRRR.  \",
+ \"  .RRRRRRRR.  \",
+ \"  .RRRRRRRR.  \",
+ \"  .RRRRRRRR.  \",
+ \"   .RRRRRR.   \",
+ \"    .RRRR.    \",
+ \"     ....     \",
+ \"              \"};")
+        (bp-cond . "/* XPM */
+ static char * file[] = {
+ \"14 12 4 1\",
+ \"    c None s backgroundColor\",
+ \".   c #4B4B4B4B4B4B\",
+ \"R   c #FFFF00000000\",
+ \"B     c #000000000000\",
+ \"              \",
+ \"     ....     \",
+ \"    .RRRR.    \",
+ \"   .RRRRRR.   \",
+ \"  .RRRRRRRR.  \",
+ \"  .RRBBBBRR.  \",
+ \"  .RRRRRRRR.  \",
+ \"  .RRBBBBRR.  \",
+ \"   .RRRRRR.   \",
+ \"    .RRRR.    \",
+ \"     ....     \",
+ \"              \"};")
+        (bp-1 . "/* XPM */
+ static char * file[] = {
+ \"14 12 4 1\",
+ \"    c None s backgroundColor\",
+ \".     c #4B4B4B4B4B4B\",
+ \"X     c #FFFF00000000\",
+ \"o     c #000000000000\",
  \"              \",
! \"     ....     \",
! \"    .XXXX.    \",
! \"   .XXooXX.   \",
! \"  .XXoooXXX.  \",
! \"  .XXXooXXX.  \",
! \"  .XXXooXXX.  \",
! \"  .XXooooXX.  \",
! \"   .XooooX.   \",
! \"    .XXXX.    \",
! \"     ....     \",
! \"              \"};")
!        (bp-2 . "/* XPM */
! static char * file[] = {
! \"14 12 4 1\",
! \"    c None s backgroundColor\",
! \".     c #4B4B4B4B4B4B\",
! \"X     c #FFFF00000000\",
! \"o     c #000000000000\",
  \"              \",
! \"     ....     \",
! \"    .XXXX.    \",
! \"   .XoooXX.   \",
! \"  .XXoXooXX.  \",
! \"  .XXXXooXX.  \",
! \"  .XXXooXXX.  \",
! \"  .XXooXXXX.  \",
! \"   .XooooX.   \",
! \"    .XXXX.    \",
! \"     ....     \",
! \"              \"};")
!        (bp-3 . "/* XPM */
! static char * file[] = {
! \"14 12 4 1\",
! \"    c None s backgroundColor\",
! \".     c #4B4B4B4B4B4B\",
! \"X     c #FFFF00000000\",
! \"o     c #000000000000\",
! \"              \",
! \"     ....     \",
! \"    .XXXX.    \",
! \"   .XoooXX.   \",
! \"  .XXXXooXX.  \",
! \"  .XXXooXXX.  \",
! \"  .XXXXooXX.  \",
! \"  .XXoXooXX.  \",
! \"   .XoooXX.   \",
! \"    .XXXX.    \",
! \"     ....     \",
! \"              \"};")
!        (bp-4 . "/* XPM */
! static char * file[] = {
! \"14 12 4 1\",
! \"    c None s backgroundColor\",
! \".     c #4B4B4B4B4B4B\",
! \"X     c #FFFF00000000\",
! \"o     c #000000000000\",
! \"              \",
! \"     ....     \",
! \"    .XXXX.    \",
! \"   .XoXXoX.   \",
! \"  .XXoXXoXX.  \",
! \"  .XXooooXX.  \",
! \"  .XXXXooXX.  \",
! \"  .XXXXooXX.  \",
! \"   .XXXooX.   \",
! \"    .XXXX.    \",
! \"     ....     \",
! \"              \"};")
!        (bp-n . "/* XPM */
! static char * file[] = {
! \"14 12 4 1\",
! \"    c None s backgroundColor\",
! \".     c #4B4B4B4B4B4B\",
! \"X     c #FFFF00000000\",
! \"o     c #000000000000\",
! \"              \",
! \"     ....     \",
! \"    .XXXX.    \",
! \"   .XXXXXX.   \",
! \"  .XXoXoXXX.  \",
! \"  .XXooXoXX.  \",
! \"  .XXoXXoXX.  \",
! \"  .XXoXXoXX.  \",
! \"   .XoXXoX.   \",
! \"    .XXXX.    \",
! \"     ....     \",
! \"              \"};"))) im-cons im)
!   
!   (while (setq im-cons (pop image-alist))
!     (setq im (cond ((and (featurep 'xemacs)
!                        (featurep 'xpm))
!                   (list
!                    (let ((data (cdr im-cons)))
!                      (string-match "#FFFF00000000" data)
!                      (setq data (replace-match "#8F8F8F8F8F8F" t t data))
!                      (make-glyph data))
!                    (make-glyph (cdr im-cons))))
!                  ((and (not (featurep 'xemacs))
!                        (fboundp 'image-type-available-p)
!                        (image-type-available-p 'xpm))
!                   (list 'image :type 'xpm :data (cdr im-cons) 
!                         :ascent 'center))
!                  (t nil)))
!     (if im (push (cons (car im-cons) im) idlwave-shell-bp-glyph))))
  
  (provide 'idlw-shell)
  (provide 'idlwave-shell)
  
  ;;; Load the toolbar when wanted by the user.
  
! (autoload 'idlwave-toolbar-toggle "idlw-toolbar" 
    "Toggle the IDLWAVE toolbar")
  (autoload 'idlwave-toolbar-add-everywhere "idlw-toolbar"
    "Add IDLWAVE toolbar")
***************
*** 3647,3651 ****
  (if idlwave-shell-use-toolbar
      (add-hook 'idlwave-shell-mode-hook 'idlwave-toolbar-add-everywhere))
  
! ;;; arch-tag: 20c2e8ce-0709-41d8-a5b6-bb039148440a
  ;;; idlw-shell.el ends here
--- 4493,4497 ----
  (if idlwave-shell-use-toolbar
      (add-hook 'idlwave-shell-mode-hook 'idlwave-toolbar-add-everywhere))
  
! ;; arch-tag: 20c2e8ce-0709-41d8-a5b6-bb039148440a
  ;;; idlw-shell.el ends here




reply via email to

[Prev in Thread] Current Thread [Next in Thread]