/[emacs]/emacs/lisp/progmodes/idlw-shell.el
ViewVC logotype

Diff of /emacs/lisp/progmodes/idlw-shell.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3.19 by lektu, Fri Sep 6 07:16:22 2002 UTC revision 3.20 by jdsmith, Thu Sep 12 16:56:54 2002 UTC
# Line 1  Line 1 
1  ;; idlw-shell.el --- run IDL as an inferior process of Emacs.  ;; idlw-shell.el --- run IDL as an inferior process of Emacs.
2  ;; Copyright (c) 1999, 2000, 2001 Free Software Foundation  ;; Copyright (c) 1999, 2000, 2001,2002 Free Software Foundation
3    
4  ;; Author: Carsten Dominik <dominik@astro.uva.nl>  ;; Author: Carsten Dominik <dominik@astro.uva.nl>
5  ;;         Chris Chase <chase@att.com>  ;;         Chris Chase <chase@att.com>
6  ;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu>  ;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu>
7  ;; Version: 4.14  ;; Version: 4.15
8  ;; Date: $Date$  ;; Date: $Date$
9  ;; Keywords: processes  ;; Keywords: processes
10    
# Line 72  Line 72 
72  ;; KNOWN PROBLEMS  ;; KNOWN PROBLEMS
73  ;; ==============  ;; ==============
74  ;;  ;;
 ;; I don't plan on implementing directory tracking by watching the IDL  
 ;; commands entered at the prompt, since too often an IDL procedure  
 ;; will change the current directory. If you want the idl process  
 ;; buffer to match the IDL current working just execute `M-x  
 ;; idlwave-shell-resync-dirs' (bound to "\C-c\C-d\C-w" by default.)  
 ;;  
75  ;; Under XEmacs the Debug menu in the shell does not display the  ;; Under XEmacs the Debug menu in the shell does not display the
76  ;; keybindings in the prefix map.  There bindings are available anyway - so  ;; keybindings in the prefix map.  There bindings are available anyway - so
77  ;; it is a bug in XEmacs.  ;; it is a bug in XEmacs.
# Line 117  Line 111 
111    
112  ;;; Customizations: idlwave-shell group  ;;; Customizations: idlwave-shell group
113    
114    ;; General/Misc. customizations
115  (defgroup idlwave-shell-general-setup nil  (defgroup idlwave-shell-general-setup nil
116    "General setup of the Shell interaction for IDLWAVE/Shell."    "General setup of the Shell interaction for IDLWAVE/Shell."
117    :prefix "idlwave-shell"    :prefix "idlwave-shell"
# Line 141  process output is made by surrounding th Line 136  process output is made by surrounding th
136    
137  ;; (defcustom idlwave-shell-automatic-start...)  See idlwave.el  ;; (defcustom idlwave-shell-automatic-start...)  See idlwave.el
138    
 (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'."  
   :group 'idlwave-shell-general-setup  
   :type 'string)  
   
 (defcustom idlwave-shell-save-command-history t  
   "Non-nil means preserve command history between sessions.  
 The file `idlwave-shell-command-history-file' is used to save and restore  
 the history."  
   :group 'idlwave-shell-general-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'.  
 The history is only saved if the variable `idlwave-shell-save-command-history'  
 is non-nil."  
   :group 'idlwave-shell-general-setup  
   :type 'file)  
     
139  (defcustom idlwave-shell-use-dedicated-frame nil  (defcustom idlwave-shell-use-dedicated-frame nil
140    "*Non-nil means, IDLWAVE should use a special frame to display shell buffer."    "*Non-nil means, IDLWAVE should use a special frame to display shell buffer."
141    :group 'idlwave-shell-general-setup    :group 'idlwave-shell-general-setup
# Line 198  t          Arrows force the cursor back Line 170  t          Arrows force the cursor back
170            (const :tag "in command line only" cmdline)))            (const :tag "in command line only" cmdline)))
171    
172  ;; FIXME: add comint-input-ring-size?  ;; FIXME: add comint-input-ring-size?
 (defcustom idlwave-shell-comint-settings  
   '((comint-scroll-to-bottom-on-input . t)  
     (comint-scroll-to-bottom-on-output . nil)  
     (comint-scroll-show-maximum-output . t)  
     )  
   "Alist of special settings for the comint variables in the IDLWAVE Shell.  
 Each entry is a cons cell with the name of a variable and a value.  
 The function `idlwave-shell-mode' will make local variables out of each entry.  
 Changes to this variable will only be active when the shell buffer is  
 newly created."  
   :group 'idlwave-shell-general-setup  
   :type '(repeat  
           (cons variable sexp)))  
173    
174  (defcustom idlwave-shell-use-toolbar t  (defcustom idlwave-shell-use-toolbar t
175    "*Non-nil means, use the debugging toolbar in all IDL related buffers.    "*Non-nil means, use the debugging toolbar in all IDL related buffers.
# Line 268  to set this option to nil." Line 227  to set this option to nil."
227    :group 'idlwave-shell-general-setup    :group 'idlwave-shell-general-setup
228    :type 'boolean)    :type 'boolean)
229    
230  (defcustom idlwave-shell-file-name-chars "~/A-Za-z0-9+@:_.$#%={}\\-"  (defcustom idlwave-shell-file-name-chars "~/A-Za-z0-9+:_.$#%={}\\-"
231    "The characters allowed in file names, as a string.    "The characters allowed in file names, as a string.
232  Used for file name completion. Must not contain `'', `,' and `\"'  Used for file name completion. Must not contain `'', `,' and `\"'
233  because these are used as separators by IDL."  because these are used as separators by IDL."
# Line 280  because these are used as separators by Line 239  because these are used as separators by
239    :group 'idlwave-shell-general-setup    :group 'idlwave-shell-general-setup
240    :type 'hook)    :type 'hook)
241    
242  (defvar idlwave-shell-print-expression-function nil  (defcustom idlwave-shell-graphics-window-size '(500 400)
243    "*OBSOLETE VARIABLE, is no longer used.")    "Size of IDL graphics windows popped up by special IDLWAVE command.
244    The command is `C-c C-d C-f' and accepts as a prefix the window nr.
245    A command like `WINDOW,N,xsize=XX,ysize=YY' is sent to IDL."
246      :group 'idlwave-shell-general-setup
247      :type '(list
248              (integer :tag "x size")
249              (integer :tag "y size")))
250    
251    ;; Commands Sent to Shell... etc.
252    (defgroup idlwave-shell-command-setup nil
253      "Setup for command parameters of the Shell interaction for IDLWAVE."
254      :prefix "idlwave-shell"
255      :group 'idlwave)
256    
257    (defcustom idlwave-shell-initial-commands "!more=0"
258      "Initial commands, separated by newlines, to send to IDL.
259    This string is sent to the IDL process by `idlwave-shell-mode' which is
260    invoked by `idlwave-shell'."
261      :group 'idlwave-shell-command-setup
262      :type 'string)
263    
264    (defcustom idlwave-shell-save-command-history t
265      "Non-nil means preserve command history between sessions.
266    The file `idlwave-shell-command-history-file' is used to save and restore
267    the history."
268      :group 'idlwave-shell-command-setup
269      :type 'boolean)
270    
271    (defcustom idlwave-shell-command-history-file "~/.idlwhist"
272      "The file in which the command history of the idlwave shell is saved.
273    In order to change the size of the history, see the variable
274    `comint-input-ring-size'.
275    The history is only saved if the variable `idlwave-shell-save-command-history'
276    is non-nil."
277      :group 'idlwave-shell-command-setup
278      :type 'file)
279      
280    (defcustom idlwave-shell-show-commands
281      '(run misc breakpoint)
282      "*A list of command types to show output from in the shell.  
283    Possibilities are 'run, 'debug, 'breakpoint, and 'misc .  Unlisted
284    types are not displayed in the shell.  The single type 'everything
285    causes all the copious shell traffic to be displayed."
286      :group 'idlwave-shell-command-setup
287      :type '(choice
288              (const everything)
289              (set :tag "Checklist" :greedy t
290                   (const :tag "All .run and .compile commands"  run)
291                   (const :tag "All breakpoint commands"         breakpoint)
292                   (const :tag "All debug and stepping commands" debug)
293                   (const :tag "Return, close, etc. commands"    misc))))
294    
295  (defcustom idlwave-shell-examine-alist  (defcustom idlwave-shell-examine-alist
296    '(("Print"            . "print,___")    '(("Print"            . "print,___")
# Line 299  The keys are used in the selection popup Line 308  The keys are used in the selection popup
308  `idlwave-shell-examine-select', and the corresponding value is sent as  `idlwave-shell-examine-select', and the corresponding value is sent as
309  a command to the shell, with special sequence `___' replaced by the  a command to the shell, with special sequence `___' replaced by the
310  expression being examined."  expression being examined."
311    :group 'idlwave-shell-general-setup    :group 'idlwave-shell-command-setup
312    :type '(repeat    :type '(repeat
313            (cons            (cons
314             (string :tag "Label  ")             (string :tag "Label  ")
315             (string :tag "Command"))))             (string :tag "Command"))))
316    
317    (defvar idlwave-shell-print-expression-function nil
318      "*OBSOLETE VARIABLE, is no longer used.")
319    
320  (defcustom idlwave-shell-separate-examine-output t  (defcustom idlwave-shell-separate-examine-output t
321    "*Non-nil mean, put output of examine commands in their own buffer."    "*Non-nil mean, put output of examine commands in their own buffer."
322    :group 'idlwave-shell-general-setup    :group 'idlwave-shell-command-setup
323    :type 'boolean)    :type 'boolean)
324        
325    (defcustom idlwave-shell-comint-settings
326      '((comint-scroll-to-bottom-on-input . t)
327        (comint-scroll-to-bottom-on-output . t)
328        (comint-scroll-show-maximum-output . nil))
329    
330      "Alist of special settings for the comint variables in the IDLWAVE Shell.
331    Each entry is a cons cell with the name of a variable and a value.
332    The function `idlwave-shell-mode' will make local variables out of each entry.
333    Changes to this variable will only be active when the shell buffer is
334    newly created."
335      :group 'idlwave-shell-command-setup
336      :type '(repeat
337              (cons variable sexp)))
338    
339    (defcustom idlwave-shell-query-for-class t
340      "*Non-nil means query the shell for object class on object completions."
341      :group 'idlwave-shell-command-setup
342      :type 'boolean)
343    
344  (defcustom idlwave-shell-use-input-mode-magic nil  (defcustom idlwave-shell-use-input-mode-magic nil
345    "*Non-nil means, IDLWAVE should check for input mode spells in output.    "*Non-nil means, IDLWAVE should check for input mode spells in output.
346  The spells are strings printed by your IDL program and matched  The spells are strings printed by your IDL program and matched
347  by the regular expressions in `idlwave-shell-input-mode-spells'.  by the regular expressions in `idlwave-shell-input-mode-spells'.
348  When these expressions match, IDLWAVE switches to character input mode and  When these expressions match, IDLWAVE switches to character input mode and
349  back, respectively.  See `idlwave-shell-input-mode-spells' for details."  back, respectively.  See `idlwave-shell-input-mode-spells' for details."
350    :group 'idlwave-shell-general-setup    :group 'idlwave-shell-command-setup
351    :type 'boolean)    :type 'boolean)
352    
353  (defcustom idlwave-shell-input-mode-spells  (defcustom idlwave-shell-input-mode-spells
# Line 372  pro idlwave_char_input,on=on,off=off Line 403  pro idlwave_char_input,on=on,off=off
403          else                          print,'<onechar>'          else                          print,'<onechar>'
404    endif    endif
405  end"  end"
406    :group 'idlwave-shell-general-setup    :group 'idlwave-shell-command-setup
407    :type '(list    :type '(list
408            (regexp :tag "One-char  regexp")            (regexp :tag "One-char  regexp")
409            (regexp :tag "Char-mode regexp")            (regexp :tag "Char-mode regexp")
410            (regexp :tag "Line-mode regexp")))            (regexp :tag "Line-mode regexp")))
411    
 (defcustom idlwave-shell-graphics-window-size '(500 400)  
   "Size of IDL graphics windows popped up by special IDLWAVE command.  
 The command is `C-c C-d C-f' and accepts as a prefix the window nr.  
 A command like `WINDOW,N,xsize=XX,ysize=YY' is sent to IDL."  
   :group 'idlwave-shell-general-setup  
   :type '(list  
           (integer :tag "x size")  
           (integer :tag "y size")))  
   
 ;;; Breakpoint Overlays etc  
412    
413    ;; Breakpoint Overlays etc
414  (defgroup idlwave-shell-highlighting-and-faces nil  (defgroup idlwave-shell-highlighting-and-faces nil
415    "Highlighting and Faces used by the IDLWAVE Shell mode."    "Highlighting and Faces used by the IDLWAVE Shell mode."
416    :prefix "idlwave-shell"    :prefix "idlwave-shell"
# Line 540  idlwave-shell-temp-rinfo-save-file is se Line 562  idlwave-shell-temp-rinfo-save-file is se
562  This is used to speed up the reloading of the routine info procedure  This is used to speed up the reloading of the routine info procedure
563  before use by the shell.")  before use by the shell.")
564    
565  (defvar idlwave-shell-dirstack-query "printd"  (defvar idlwave-shell-dirstack-query "cd,current=___cur & print,___cur"
566    "Command used by `idlwave-shell-resync-dirs' to query IDL for    "Command used by `idlwave-shell-resync-dirs' to query IDL for
567  the directory stack.")  the directory stack.")
568    
 (defvar idlwave-shell-wd-is-synched nil)  
   
569  (defvar idlwave-shell-path-query "__pa=expand_path(!path,/array)&for i=0,n_elements(__pa)-1 do print,'PATH:<'+__pa[i]+'>'&print,'SYSDIR:<'+!dir+'>'"  (defvar idlwave-shell-path-query "__pa=expand_path(!path,/array)&for i=0,n_elements(__pa)-1 do print,'PATH:<'+__pa[i]+'>'&print,'SYSDIR:<'+!dir+'>'"
570    "The command which gets !PATH and !DIR infor from the shell.")    "The command which gets !PATH and !DIR infor from the shell.")
571    
# Line 661  with `*'s." Line 681  with `*'s."
681  (defvar idlwave-shell-ready nil  (defvar idlwave-shell-ready nil
682    "If non-nil can send next command to IDL process.")    "If non-nil can send next command to IDL process.")
683    
684    (defvar idlwave-shell-wait-for-output nil
685      "Whether to wait for output to accumulate.")
686    
687  ;;; The following are the types of messages we attempt to catch to  ;;; The following are the types of messages we attempt to catch to
688  ;;; resync our idea of where IDL execution currently is.  ;;; resync our idea of where IDL execution currently is.
689  ;;;  ;;;
# Line 833  IDL has currently stepped.") Line 856  IDL has currently stepped.")
856    (idlwave-shell-display-line nil)    (idlwave-shell-display-line nil)
857    (setq idlwave-shell-calling-stack-index 0)    (setq idlwave-shell-calling-stack-index 0)
858    
859      (when idlwave-shell-query-for-class
860          (add-to-list (make-local-variable 'idlwave-determine-class-special)
861                       'idlwave-shell-get-object-class)
862          (setq idlwave-store-inquired-class t))
863    
864    ;; Make sure comint-last-input-end does not go to beginning of    ;; Make sure comint-last-input-end does not go to beginning of
865    ;; buffer (in case there were other processes already in this buffer).    ;; buffer (in case there were other processes already in this buffer).
866    (set-marker comint-last-input-end (point))    (set-marker comint-last-input-end (point))
867    (setq idlwave-idlwave_routine_info-compiled nil)    (setq idlwave-idlwave_routine_info-compiled nil)
868    (setq idlwave-shell-ready nil)    (setq idlwave-shell-ready nil)
869      (setq idlwave-shell-wait-for-output nil)
870    (setq idlwave-shell-bp-alist nil)    (setq idlwave-shell-bp-alist nil)
871    (idlwave-shell-update-bp-overlays) ; Throw away old overlays    (idlwave-shell-update-bp-overlays) ; Throw away old overlays
872    (setq idlwave-shell-sources-alist nil)    (setq idlwave-shell-sources-alist nil)
# Line 1016  See also the variable `idlwave-shell-pro Line 1045  See also the variable `idlwave-shell-pro
1045      (idlwave-shell arg)      (idlwave-shell arg)
1046      (select-window window)))      (select-window window)))
1047    
1048    (defun idlwave-shell-hide-p (type)
1049      "Whether to hide this type of command.
1050    Return either nil or 'hide."
1051      (if (listp idlwave-shell-show-commands)
1052          (if (not (memq type idlwave-shell-show-commands)) 'hide)))
1053    
1054  (defun idlwave-shell-send-command (&optional cmd pcmd hide preempt)  (defun idlwave-shell-send-command (&optional cmd pcmd hide preempt)
1055    "Send a command to IDL process.    "Send a command to IDL process.
1056    
1057  \(CMD PCMD HIDE\) are placed at the end of `idlwave-shell-pending-commands'.  \(CMD PCMD HIDE\) are placed at the end of
1058  If IDL is ready the first command, CMD, in  ` idlwave-shell-pending-commands'.  If IDL is ready the first command,
1059  `idlwave-shell-pending-commands' is sent to the IDL process.  If optional  CMD, in `idlwave-shell-pending-commands' is sent to the IDL process.
1060  second argument PCMD is non-nil it will be placed on  If optional second argument PCMD is non-nil it will be placed on
1061  `idlwave-shell-post-command-hook' when CMD is executed.  If the optional  `idlwave-shell-post-command-hook' when CMD is executed.  If the
1062  third argument HIDE is non-nil, then hide output from CMD.  optional third argument HIDE is non-nil, then hide output from CMD.
1063  If optional fourth argument PREEMPT is non-nil CMD is put at front of  If optional fourth argument PREEMPT is non-nil CMD is put at front of
1064  `idlwave-shell-pending-commands'.  `idlwave-shell-pending-commands'.  If PREEMPT is 'wait, wait for all
1065    output to complete and the next prompt to arrive before returning
1066  IDL is considered ready if the prompt is present  \(useful if you need an answer now\). IDL is considered ready if the
1067  and if `idlwave-shell-ready' is non-nil."  prompt is present and if `idlwave-shell-ready' is non-nil."
1068    
1069    ;(setq hide nil)  ;  FIXME: turn this on for debugging only  ;  (setq hide nil)  ;  FIXME: turn this on for debugging only
1070  ;  (message "SENDING %s|||%s" cmd pcmd) ;??????????????????????  ;  (if (null cmd)
1071    (let (buf proc)  ;      (progn
1072    ;       (message "SENDING Pending commands: %s"
1073    ;                (prin1-to-string idlwave-shell-pending-commands)))
1074    ;    (message "SENDING %s|||%s" cmd pcmd))
1075      (if (and (symbolp idlwave-shell-show-commands)
1076               (eq idlwave-shell-show-commands 'everything))
1077          (setq hide nil))
1078      (let ((save-buffer (current-buffer))
1079            buf proc)
1080      ;; Get or make the buffer and its process      ;; Get or make the buffer and its process
1081      (if (or (not (setq buf (get-buffer (idlwave-shell-buffer))))      (if (or (not (setq buf (get-buffer (idlwave-shell-buffer))))
1082              (not (setq proc (get-buffer-process buf))))              (not (setq proc (get-buffer-process buf))))
# Line 1047  and if `idlwave-shell-ready' is non-nil. Line 1090  and if `idlwave-shell-ready' is non-nil.
1090                    (not (setq proc (get-buffer-process buf))))                    (not (setq proc (get-buffer-process buf))))
1091                ;; Still nothing                ;; Still nothing
1092                (error "Problem with autostarting IDL shell"))))                (error "Problem with autostarting IDL shell"))))
1093        (when (or cmd idlwave-shell-pending-commands)
     (save-excursion  
1094        (set-buffer buf)        (set-buffer buf)
       (goto-char (process-mark proc))  
1095        ;; To make this easy, always push CMD onto pending commands        ;; To make this easy, always push CMD onto pending commands
1096        (if cmd        (if cmd
1097            (setq idlwave-shell-pending-commands            (setq idlwave-shell-pending-commands
1098                  (if preempt                  (if preempt
1099                      ;; Put at front.                      ;; Put at front.
1100                      (append (list (list cmd pcmd hide))                      (append (list (list cmd pcmd hide))
1101                              idlwave-shell-pending-commands)                              idlwave-shell-pending-commands)
1102                    ;; Put at end.                    ;; Put at end.
1103                    (append idlwave-shell-pending-commands                    (append idlwave-shell-pending-commands
1104                            (list (list cmd pcmd hide))))))                            (list (list cmd pcmd hide))))))
1105        ;; Check if IDL ready        ;; Check if IDL ready
1106        (if (and idlwave-shell-ready        (let ((save-point (point-marker)))
1107                 ;; Check for IDL prompt          (goto-char (process-mark proc))
1108                 (save-excursion          (if (and idlwave-shell-ready
1109                   (forward-line 0)                   ;; Check for IDL prompt
1110                   ;; (beginning-of-line) ; Changed for Emacs 21                   (prog2
1111                   (looking-at idlwave-shell-prompt-pattern)))                     (forward-line 0)
1112            ;; IDL ready for command                     ;; (beginning-of-line) ; Changed for Emacs 21
1113            (if idlwave-shell-pending-commands                     (looking-at idlwave-shell-prompt-pattern)
1114                ;; execute command                     (goto-char (process-mark proc))))
1115                (let* ((lcmd (car idlwave-shell-pending-commands))              ;; IDL ready for command, execute it
1116                       (cmd (car lcmd))              (let* ((lcmd (car idlwave-shell-pending-commands))
1117                       (pcmd (nth 1 lcmd))                     (cmd (car lcmd))
1118                       (hide (nth 2 lcmd)))                     (pcmd (nth 1 lcmd))
1119                  ;; If this is an executive command, reset the stack pointer                     (hide (nth 2 lcmd)))
1120                  (if (eq (string-to-char cmd) ?.)                ;; If this is an executive command, reset the stack pointer
1121                      (setq idlwave-shell-calling-stack-index 0))                (if (eq (string-to-char cmd) ?.)
1122                  ;; Set post-command                    (setq idlwave-shell-calling-stack-index 0))
1123                  (setq idlwave-shell-post-command-hook pcmd)                ;; Set post-command
1124                  ;; Output hiding                (setq idlwave-shell-post-command-hook pcmd)
1125  ;;; Debug code                          ;; Output hiding
1126  ;;;             (setq idlwave-shell-hide-output nil)                (setq idlwave-shell-hide-output hide)
1127                  (setq idlwave-shell-hide-output hide)                ;; Pop command
1128                  ;; Pop command                (setq idlwave-shell-pending-commands
1129                  (setq idlwave-shell-pending-commands                      (cdr idlwave-shell-pending-commands))
1130                        (cdr idlwave-shell-pending-commands))                ;; Send command for execution
1131                  ;; Send command for execution                (set-marker comint-last-input-start (point))
1132                  (set-marker comint-last-input-start (point))                (set-marker comint-last-input-end (point))
1133                  (set-marker comint-last-input-end (point))                (comint-simple-send proc cmd)
1134                  (comint-simple-send proc cmd)                (setq idlwave-shell-ready nil)
1135                  (setq idlwave-shell-ready nil)))))))                (when (equal preempt 'wait) ; Get all the output at once
1136                    (setq idlwave-shell-wait-for-output t)
1137                    (accept-process-output proc))))
1138            (goto-char save-point))
1139          (set-buffer save-buffer))))
1140    
1141  (defun idlwave-shell-send-char (c &optional no-error)  (defun idlwave-shell-send-char (c &optional no-error)
1142    "Send one character to the shell, without a newline."    "Send one character to the shell, without a newline."
# Line 1172  when the IDL prompt gets displayed again Line 1217  when the IDL prompt gets displayed again
1217             (and (eq idlwave-shell-char-mode-active 'exit)             (and (eq idlwave-shell-char-mode-active 'exit)
1218                  (throw 'exit "Single char loop exited"))))))))                  (throw 'exit "Single char loop exited"))))))))
1219    
1220  (defun idlwave-shell-up-or-history (&optional arg)  (defun idlwave-shell-move-or-history (up &optional arg)
1221    "When in last line of process buffer, do `comint-previous-input'.    "When in last line of process buffer, do `comint-previous-input'.
1222  Otherwise just do `previous-line'."  Otherwise just move the line.  Move down unless UP is non-nil."
1223      (let* ((proc-pos (marker-position
1224                        (process-mark (get-buffer-process (current-buffer)))))
1225             (arg (or arg 1))
1226             (arg (if up arg (- arg))))
1227        (if (eq t idlwave-shell-arrows-do-history) (goto-char proc-pos))
1228        (if (and idlwave-shell-arrows-do-history
1229                 (>= (1+ (save-excursion (end-of-line) (point))) proc-pos))
1230            (progn
1231              (goto-char proc-pos)
1232              (and (not (eolp)) (kill-line nil))
1233              (comint-previous-input arg))
1234          (previous-line arg))))
1235    
1236    (defun idlwave-shell-up-or-history (&optional arg)
1237    "When in last line of process buffer, move to previous input.
1238     Otherwise just go up one line."
1239    (interactive "p")    (interactive "p")
1240    (if (eq t idlwave-shell-arrows-do-history) (goto-char (point-max)))    (idlwave-shell-move-or-history t arg))
   (if (and idlwave-shell-arrows-do-history  
            (>= (1+ (save-excursion (end-of-line) (point)))  
                (marker-position  
                 (process-mark (get-buffer-process (current-buffer))))))  
       (progn  
         (and (not (eolp)) (kill-line nil))  
         (comint-previous-input arg))  
     (previous-line arg)))  
1241    
1242  (defun idlwave-shell-down-or-history (&optional arg)  (defun idlwave-shell-down-or-history (&optional arg)
1243    "When in last line of process buffer, do `comint-next-input'.  "When in last line of process buffer, move to next input.
1244   Otherwise just do `next-line'."   Otherwise just go down one line."
1245    (interactive "p")    (interactive "p")
1246    (if (eq t idlwave-shell-arrows-do-history) (goto-char (point-max)))    (idlwave-shell-move-or-history nil arg))
   (if (and idlwave-shell-arrows-do-history  
            (>= (1+ (save-excursion (end-of-line) (point)))  
                (marker-position  
                 (process-mark (get-buffer-process (current-buffer))))))  
       (progn  
         (and (not (eolp)) (kill-line nil))  
         (comint-next-input arg))  
     (next-line arg)))  
   
 ;; There was a report that a newer version of comint.el changed the  
 ;; name of comint-filter to comint-output-filter.  Unfortunately, we  
 ;; have yet to upgrade.  
1247    
1248    ;; Newer versions of comint.el changed the name of comint-filter to
1249    ;; comint-output-filter.
1250  (defun idlwave-shell-comint-filter (process string) nil)  (defun idlwave-shell-comint-filter (process string) nil)
1251  (if (fboundp 'comint-output-filter)  (if (fboundp 'comint-output-filter)
1252      (fset 'idlwave-shell-comint-filter (symbol-function 'comint-output-filter))      (fset 'idlwave-shell-comint-filter (symbol-function 'comint-output-filter))
# Line 1223  and then calls `idlwave-shell-send-comma Line 1266  and then calls `idlwave-shell-send-comma
1266    ;; We no longer do the cleanup here - this is done by the process sentinel    ;; We no longer do the cleanup here - this is done by the process sentinel
1267    (when (eq (process-status idlwave-shell-process-name) 'run)    (when (eq (process-status idlwave-shell-process-name) 'run)
1268      ;; OK, process is still running, so we can use it.      ;; OK, process is still running, so we can use it.
     (setq idlwave-shell-wd-is-synched nil)  ;; something might have changed cwd  
1269      (let ((data (match-data)) p)      (let ((data (match-data)) p)
1270        (unwind-protect        (unwind-protect
1271            (progn            (progn
# Line 1252  and then calls `idlwave-shell-send-comma Line 1294  and then calls `idlwave-shell-send-comma
1294                     (get-buffer-create idlwave-shell-hidden-output-buffer))                     (get-buffer-create idlwave-shell-hidden-output-buffer))
1295                    (goto-char (point-max))                    (goto-char (point-max))
1296                    (insert string))                    (insert string))
1297                (idlwave-shell-comint-filter proc string))                (idlwave-shell-comint-filter proc string))
1298              ;; Watch for magic - need to accumulate the current line              ;; Watch for magic - need to accumulate the current line
1299              ;; since it may not be sent all at once.              ;; since it may not be sent all at once.
1300              (if (string-match "\n" string)              (if (string-match "\n" string)
# Line 1266  and then calls `idlwave-shell-send-comma Line 1308  and then calls `idlwave-shell-send-comma
1308                                            (match-end 0)))))                                            (match-end 0)))))
1309                (setq idlwave-shell-accumulation                (setq idlwave-shell-accumulation
1310                      (concat idlwave-shell-accumulation string)))                      (concat idlwave-shell-accumulation string)))
1311                
1312                
1313  ;;; Test/Debug code  ;;; Test/Debug code
1314  ;            (save-excursion (set-buffer  ;            (save-excursion (set-buffer
1315  ;                             (get-buffer-create "*idlwave-shell-output*"))  ;                             (get-buffer-create "*idlwave-shell-output*"))
1316  ;                            (goto-char (point-max))  ;                            (goto-char (point-max))
1317  ;                            (insert "\nSTRING===>\n" string "\n<====\n"))  ;                            (insert "\nSTRING===>\n" string "\n<====\n"))
1318                            
1319              ;; Check for prompt in current accumulating line              ;; Check for prompt in current accumulating output
1320              (if (setq idlwave-shell-ready              (if (setq idlwave-shell-ready
1321                        (string-match idlwave-shell-prompt-pattern                        (string-match idlwave-shell-prompt-pattern
1322                                      idlwave-shell-accumulation))                                      idlwave-shell-accumulation))
1323                  (progn                  (progn
1324                    (if idlwave-shell-hide-output                    (if idlwave-shell-hide-output
1325                        (save-excursion                        (save-excursion
1326                          (set-buffer idlwave-shell-hidden-output-buffer)                          (set-buffer idlwave-shell-hidden-output-buffer)
1327  ;                        (goto-char (point-min))                          (goto-char (point-max))
1328  ;                        (re-search-forward idlwave-shell-prompt-pattern nil t)                          (re-search-backward idlwave-shell-prompt-pattern nil t)
                         (goto-char (point-max))  
                         (re-search-backward idlwave-shell-prompt-pattern nil t)  
1329                          (goto-char (match-end 0))                          (goto-char (match-end 0))
1330                          (setq idlwave-shell-command-output                          (setq idlwave-shell-command-output
1331                                (buffer-substring (point-min) (point)))                                (buffer-substring (point-min) (point)))
1332  ;; Test/Debug                          
1333    ;;; Test/Debug
1334  ;                        (save-excursion (set-buffer  ;                        (save-excursion (set-buffer
1335  ;                                         (get-buffer-create "*idlwave-shell-output*"))  ;                                         (get-buffer-create "*idlwave-shell-output*"))
1336  ;                                        (goto-char (point-max))  ;                                        (goto-char (point-max))
1337  ;                                        (insert "\nOUPUT===>\n" idlwave-shell-command-output "\n<===\n"))  ;                                        (insert "\nOUPUT===>\n" idlwave-shell-command-output "\n<===\n"))
1338                            
1339                          (delete-region (point-min) (point)))                          (delete-region (point-min) (point)))
1340                      (setq idlwave-shell-command-output                      (setq idlwave-shell-command-output
1341                            (save-excursion                            (with-current-buffer (process-buffer proc)
1342                              (set-buffer                              (buffer-substring
1343                               (process-buffer proc))                               (save-excursion
1344                              (buffer-substring                                 (goto-char (process-mark proc))
1345                               (progn                                 (beginning-of-line nil)
1346                                 (goto-char (process-mark proc))                                 (point))
1347                                 (beginning-of-line nil)                               comint-last-input-end))))
1348                                 (point))  
                              comint-last-input-end))))  
1349                    ;; Scan for state and do post command - bracket them                    ;; Scan for state and do post command - bracket them
1350                    ;; with idlwave-shell-ready=nil since they                    ;; with idlwave-shell-ready=nil since they
1351                    ;; may call idlwave-shell-send-command.                    ;; may call idlwave-shell-send-command.
# Line 1321  and then calls `idlwave-shell-send-comma Line 1361  and then calls `idlwave-shell-send-comma
1361                      (setq idlwave-shell-accumulation nil                      (setq idlwave-shell-accumulation nil
1362                            idlwave-shell-command-output nil                            idlwave-shell-command-output nil
1363                            idlwave-shell-post-command-hook nil                            idlwave-shell-post-command-hook nil
1364                            idlwave-shell-hide-output nil))                            idlwave-shell-hide-output nil
1365                              idlwave-shell-wait-for-output nil))
1366                    ;; Done with post command. Do pending command if                    ;; Done with post command. Do pending command if
1367                    ;; any.                    ;; any.
1368                    (idlwave-shell-send-command))))                    (idlwave-shell-send-command))
1369                  ;; We didn't get the prompt yet... maybe accept more output
1370                  (when idlwave-shell-wait-for-output
1371    ;;; Test/Debug code
1372    ;               (save-excursion (set-buffer
1373    ;                                (get-buffer-create "*idlwave-shell-output*"))
1374    ;                               (goto-char (point-max))
1375    ;                               (insert "\n<=== WAITING ON OUTPUT ==>\n"))
1376                      (accept-process-output proc nil 100))))
1377          (store-match-data data)))))          (store-match-data data)))))
1378    
1379  (defun idlwave-shell-sentinel (process event)  (defun idlwave-shell-sentinel (process event)
# Line 1367  messages.  We ignore error messages othe Line 1416  messages.  We ignore error messages othe
1416  For breakpoint messages process any attached count or command  For breakpoint messages process any attached count or command
1417  parameters.  parameters.
1418  Update the windows if a message is found."  Update the windows if a message is found."
1419    (let (update)    (cond
1420      (cond     ;; Make sure we have output
1421       ;; Make sure we have output     ((not idlwave-shell-command-output))
1422       ((not idlwave-shell-command-output))    
1423       ;; First Priority: Syntax and other errors
1424       ;; Various types of HALT messages.     ((or
1425       ((string-match idlwave-shell-halt-messages-re       (string-match idlwave-shell-syntax-error idlwave-shell-command-output)
1426                      idlwave-shell-command-output)       (string-match idlwave-shell-other-error idlwave-shell-command-output))
1427        ;; Grab the file and line state info.      (save-excursion
1428        (setq idlwave-shell-calling-stack-index 0)        (set-buffer
1429        (setq idlwave-shell-halt-frame         (get-buffer-create idlwave-shell-error-buffer))
1430              (idlwave-shell-parse-line        (erase-buffer)
1431               (substring idlwave-shell-command-output (match-end 0)))        (insert idlwave-shell-command-output)
1432              update t))        (goto-char (point-min))
1433          (setq idlwave-shell-error-last (point)))
1434       ;; Handle breakpoints separately      (idlwave-shell-goto-next-error))
1435       ((string-match idlwave-shell-break-message    
1436                      idlwave-shell-command-output)     ;; Second Priority: Various types of HALT messages.
1437        (setq idlwave-shell-calling-stack-index 0)     ((string-match idlwave-shell-halt-messages-re
1438        (setq idlwave-shell-halt-frame                    idlwave-shell-command-output)
1439              (idlwave-shell-parse-line      ;; Grab the file and line state info.
1440               (substring idlwave-shell-command-output (match-end 0)))      (setq idlwave-shell-calling-stack-index 0)
1441              update t)      (setq idlwave-shell-halt-frame
1442        ;; We used to to counting hits on breakpoints            (idlwave-shell-parse-line
1443        ;; this is no longer supported since IDL breakpoints             (substring idlwave-shell-command-output (match-end 0))))
1444        ;; have learned counting.      (idlwave-shell-display-line (idlwave-shell-pc-frame)))
1445        ;; Do breakpoint command processing    
1446        (let ((bp (assoc     ;; Last Priority: Breakpoints
1447                   (list     ((string-match idlwave-shell-break-message
1448                    (nth 0 idlwave-shell-halt-frame)                    idlwave-shell-command-output)
1449                    (nth 1 idlwave-shell-halt-frame))      (setq idlwave-shell-calling-stack-index 0)
1450                   idlwave-shell-bp-alist)))      (setq idlwave-shell-halt-frame
1451          (if bp            (idlwave-shell-parse-line
1452              (let ((cmd (idlwave-shell-bp-get bp 'cmd)))             (substring idlwave-shell-command-output (match-end 0))))
1453                (if cmd      ;; We used to count hits on breakpoints
1454                    ;; Execute command      ;; this is no longer supported since IDL breakpoints
1455                    (if (listp cmd)      ;; have learned counting.
1456                        (eval cmd)      ;; Do breakpoint command processing
1457                      (funcall cmd))))      (let ((bp (assoc
1458            ;; A breakpoint that we did not know about - perhaps it was                 (list
1459            ;; set by the user or IDL isn't reporting breakpoints like                  (nth 0 idlwave-shell-halt-frame)
1460            ;; we expect.  Lets update our list.                  (nth 1 idlwave-shell-halt-frame))
1461            (idlwave-shell-bp-query)))))                 idlwave-shell-bp-alist)))
1462          (if bp
1463      ;; Handle compilation errors in addition to the above            (let ((cmd (idlwave-shell-bp-get bp 'cmd)))
1464      (if (and idlwave-shell-command-output              (if cmd
1465               (or (string-match                  ;; Execute command
1466                    idlwave-shell-syntax-error idlwave-shell-command-output)                  (if (listp cmd) (eval cmd) (funcall cmd))))
1467                   (string-match          ;; A breakpoint that we did not know about - perhaps it was
1468                    idlwave-shell-other-error idlwave-shell-command-output)))          ;; set by the user or IDL isn't reporting breakpoints like
1469          (progn          ;; we expect.  Lets update our list.
1470            (save-excursion          (idlwave-shell-bp-query)))
1471              (set-buffer      (idlwave-shell-display-line (idlwave-shell-pc-frame)))))
              (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)))  
       
     ;; Do update  
     (when update  
       (idlwave-shell-display-line (idlwave-shell-pc-frame)))))  
   
1472    
1473  (defvar idlwave-shell-error-buffer " *idlwave-shell-errors*"  (defvar idlwave-shell-error-buffer " *idlwave-shell-errors*"
1474    "Buffer containing syntax errors from IDL compilations.")    "Buffer containing syntax errors from IDL compilations.")
1475    
   
1476  ;; FIXME: the following two variables do not currently allow line breaks  ;; FIXME: the following two variables do not currently allow line breaks
1477  ;; in module and file names.  I am not sure if it will be necessary to  ;; in module and file names.  I am not sure if it will be necessary to
1478  ;; change this.  Currently it seems to work the way it is.  ;; change this.  Currently it seems to work the way it is.
# Line 1498  plus garbage match an existing regular f Line 1535  plus garbage match an existing regular f
1535  unlikely."  unlikely."
1536    
1537    (let (number procedure file)    (let (number procedure file)
1538      (when (string-match idlwave-shell-file-line-message string)      (when (and (not (string-match ":\\s-*\\$MAIN" string))
1539                    (string-match idlwave-shell-file-line-message string))
1540        (setq procedure (match-string 1 string)        (setq procedure (match-string 1 string)
1541              number (match-string 3 string)              number (match-string 3 string)
1542              file (match-string 5 string))              file (match-string 5 string))
# Line 1554  file name." Line 1592  file name."
1592          idlwave-shell-command-line-to-execute nil          idlwave-shell-command-line-to-execute nil
1593          idlwave-shell-bp-alist nil          idlwave-shell-bp-alist nil
1594          idlwave-shell-calling-stack-index 0          idlwave-shell-calling-stack-index 0
1595          idlwave-idlwave_routine_info-compiled nil)          idlwave-idlwave_routine_info-compile nil)
1596    (idlwave-shell-delete-temp-files)    (idlwave-shell-delete-temp-files)
1597    (idlwave-shell-display-line nil)    (idlwave-shell-display-line nil)
1598    (idlwave-shell-update-bp-overlays) ; kill old overlays    (idlwave-shell-update-bp-overlays) ; kill old overlays
# Line 1585  The size is given by `idlwave-shell-grap Line 1623  The size is given by `idlwave-shell-grap
1623    (let ((n (if n (prefix-numeric-value n) 0)))    (let ((n (if n (prefix-numeric-value n) 0)))
1624      (idlwave-shell-send-command      (idlwave-shell-send-command
1625       (apply 'format "window,%d,xs=%d,ys=%d"       (apply 'format "window,%d,xs=%d,ys=%d"
1626              n idlwave-shell-graphics-window-size))))              n idlwave-shell-graphics-window-size)
1627         nil (idlwave-shell-hide-p 'misc))))
1628    
1629  (defun idlwave-shell-resync-dirs ()  (defun idlwave-shell-resync-dirs ()
1630    "Resync the buffer's idea of the current directory stack.    "Resync the buffer's idea of the current directory.
1631  This command queries IDL with the command bound to  This command queries IDL with the command bound to
1632  `idlwave-shell-dirstack-query' (default \"printd\"), reads the  `idlwave-shell-dirstack-query', reads the output for the new
1633  output for the new directory stack."  directory."
1634    (interactive)    (interactive)
1635    (idlwave-shell-send-command idlwave-shell-dirstack-query    (idlwave-shell-send-command idlwave-shell-dirstack-query
1636                                'idlwave-shell-filter-directory                                'idlwave-shell-filter-directory
1637                                'hide))                                'hide 'wait))
1638    
1639  (defun idlwave-shell-retall (&optional arg)  (defun idlwave-shell-retall (&optional arg)
1640    "Return from the entire calling stack."    "Return from the entire calling stack."
1641    (interactive "P")    (interactive "P")
1642    (idlwave-shell-send-command "retall"))    (idlwave-shell-send-command "retall" nil (idlwave-shell-hide-p 'misc)))
1643    
1644  (defun idlwave-shell-closeall (&optional arg)  (defun idlwave-shell-closeall (&optional arg)
1645    "Close all open files."    "Close all open files."
1646    (interactive "P")    (interactive "P")
1647    (idlwave-shell-send-command "close,/all"))    (idlwave-shell-send-command "close,/all" nil (idlwave-shell-hide-p 'misc)))
1648    
1649  (defun idlwave-shell-quit (&optional arg)  (defun idlwave-shell-quit (&optional arg)
1650    "Exit the idl process after confirmation.    "Exit the idl process after confirmation.
# Line 1619  With prefix ARG, exit without confirmati Line 1658  With prefix ARG, exit without confirmati
1658            (error nil)))))            (error nil)))))
1659    
1660  (defun idlwave-shell-reset (&optional hidden)  (defun idlwave-shell-reset (&optional hidden)
1661    "Reset IDL.  Return to main level and destroy the leaftover variables.    "Reset IDL.  Return to main level and destroy the leftover variables.
1662  This issues the following commands:    This issues the following commands:  
1663  RETALL  RETALL
1664  WIDGET_CONTROL,/RESET  WIDGET_CONTROL,/RESET
# Line 1752  HEAP_GC, /VERBOSE" Line 1791  HEAP_GC, /VERBOSE"
1791  Change the default directory for the process buffer to concur."  Change the default directory for the process buffer to concur."
1792    (save-excursion    (save-excursion
1793      (set-buffer (idlwave-shell-buffer))      (set-buffer (idlwave-shell-buffer))
1794      (if (string-match "Current Directory: *\\(\\S-*\\) *$"      (if (string-match ",___cur[\n\r]\\(\\S-*\\) *[\n\r]"
1795                        idlwave-shell-command-output)                        idlwave-shell-command-output)
1796          (let ((dir (substring idlwave-shell-command-output          (let ((dir (substring idlwave-shell-command-output
1797                                (match-beginning 1) (match-end 1))))                                (match-beginning 1) (match-end 1))))
1798            (message "Setting Emacs wd to %s" dir)  ;         (message "Setting Emacs working dir to %s" dir)
1799            (setq idlwave-shell-default-directory dir)            (setq idlwave-shell-default-directory dir)
1800            (setq default-directory (file-name-as-directory dir))))))            (setq default-directory (file-name-as-directory dir))))))
1801    
1802    (defvar idlwave-shell-get-object-class nil)
1803    (defun idlwave-shell-get-object-class (apos)
1804      "Query the shell for the class of the object before point."
1805      (let ((bos (save-excursion (idlwave-start-of-substatement 'pre) (point)))
1806            (bol (save-excursion (forward-line 0) (point)))
1807            expression)
1808        (save-excursion
1809          (goto-char apos)
1810          (setq expression (buffer-substring
1811                            (catch 'exit
1812                              (while t
1813                                (if (not (re-search-backward
1814                                          "[^][.A-Za-z0-9_() ]" bos t))
1815                                    (throw 'exit bos)) ;ran into bos
1816                                (if (not (idlwave-is-pointer-dereference bol))
1817                                    (throw 'exit (1+ (point))))))
1818                            apos)))
1819        (when (not (string= expression ""))
1820          (setq idlwave-shell-get-object-class nil)
1821          (idlwave-shell-send-command
1822           (concat "print,obj_class(" expression ")")
1823           'idlwave-shell-parse-object-class
1824           'hide 'wait)
1825          ;; If we don't know anything about the class, update shell routines
1826          (if (and idlwave-shell-get-object-class
1827                   (not (assoc-ignore-case idlwave-shell-get-object-class
1828                                           (idlwave-class-alist))))
1829              (idlwave-shell-maybe-update-routine-info))
1830          idlwave-shell-get-object-class)))
1831    
1832    (defun idlwave-shell-parse-object-class ()
1833      "Parse the output of the obj_class command."
1834      (let ((match "print,obj_class([^\n\r]+[\n\r ]+"))
1835        (if (and
1836             (not (string-match (concat match match "\\s-*^[\n\r]+"
1837                                        "% Syntax error")
1838                                idlwave-shell-command-output))
1839             (string-match (concat match "\\([A-Za-z_0-9]+\\)")
1840                           idlwave-shell-command-output))
1841            (setq idlwave-shell-get-object-class
1842                  (match-string 1 idlwave-shell-command-output)))))
1843    
1844    
1845  (defun idlwave-shell-complete (&optional arg)  (defun idlwave-shell-complete (&optional arg)
1846    "Do completion in the idlwave-shell buffer.    "Do completion in the idlwave-shell buffer.
1847  Calls `idlwave-shell-complete-filename' after some executive commands or  Calls `idlwave-shell-complete-filename' after some executive commands or
1848  in strings.  Otherwise, calls `idlwave-complete' to complete modules and  in strings.  Otherwise, calls `idlwave-complete' to complete modules and
1849  keywords."  keywords."
 ;;FIXME: batch files?  
1850    (interactive "P")    (interactive "P")
1851    (let (cmd)    (let (cmd)
1852      (cond      (cond
# Line 1776  keywords." Line 1857  keywords."
1857                      ".COM" ".COMP" ".COMPI" ".COMPIL" ".COMPILE"))                      ".COM" ".COMP" ".COMPI" ".COMPIL" ".COMPILE"))
1858            ;; This command expects file names            ;; This command expects file names
1859            (idlwave-shell-complete-filename)))            (idlwave-shell-complete-filename)))
1860    
1861         ((idlwave-shell-batch-command)
1862          (idlwave-shell-complete-filename))
1863    
1864       ((and (idlwave-shell-filename-string)       ((and (idlwave-shell-filename-string)
1865             (save-excursion             (save-excursion
1866               (beginning-of-line)               (beginning-of-line)
1867               (let ((case-fold-search t))               (let ((case-fold-search t))
1868                 (not (looking-at ".*obj_new"))))                 (not (looking-at ".*obj_new")))))
1869             ;; In a string, could be a file name to here        (idlwave-shell-complete-filename))
1870             (idlwave-shell-complete-filename)))      
1871       (t       (t
1872        ;; Default completion of modules and keywords        ;; Default completion of modules and keywords
1873        (idlwave-complete arg)))))        (idlwave-complete arg)))))
# Line 1790  keywords." Line 1875  keywords."
1875  (defun idlwave-shell-complete-filename (&optional arg)  (defun idlwave-shell-complete-filename (&optional arg)
1876    "Complete a file name at point if after a file name.    "Complete a file name at point if after a file name.
1877  We assume that we are after a file name when completing one of the  We assume that we are after a file name when completing one of the
1878  args of an executive .run, .rnew or .compile.  Also, in a string  args of an executive .run, .rnew or .compile."
1879  constant we complete file names.  Otherwise return nil, so that    ;; CWD might have changed, resync, to set default directory
1880  other completion functions can do their work."    (idlwave-shell-resync-dirs)
1881    ;; Comint does something funny with the default directory,    (let ((comint-file-name-chars idlwave-shell-file-name-chars))
1882    ;; so we set it here from out safe own variable      (comint-dynamic-complete-as-filename)))
   (setq default-directory  
         (file-name-as-directory idlwave-shell-default-directory))  
   (if (not idlwave-shell-wd-is-synched)  
       ;; Some IDL stuff has been executed since last update, so we need to  
       ;; do it again.  
       (idlwave-shell-send-command  
        idlwave-shell-dirstack-query  
        `(progn  
           (idlwave-shell-filter-directory)  
           (setq idlwave-shell-wd-is-synched t)  
           (switch-to-buffer (idlwave-shell-buffer))  
           (goto-char ,(point))  ;; This is necesary on Emacs, don't know why  
           ;; after the update, we immediately redo the completion, so the  
           ;; user will hardly notice we did the update.  
           (idlwave-shell-complete-filename))  
        'hide)  
     (let* ((comint-file-name-chars idlwave-shell-file-name-chars)  
            (completion-ignore-case (default-value 'completion-ignore-case)))  
       (comint-dynamic-complete-filename))))  
1883    
1884  (defun idlwave-shell-executive-command ()  (defun idlwave-shell-executive-command ()
1885    "Return the name of the current executive command, if any."    "Return the name of the current executive command, if any."
1886    (save-excursion    (save-excursion
1887      (idlwave-beginning-of-statement)      (idlwave-beginning-of-statement)
1888      (if (looking-at "[ \t]*\\([.][^ \t\n\r]*\\)")      (if (looking-at "[ \t]*\\([.][^ \t\n\r]+\\)")
1889          (match-string 1))))          (match-string 1))))
1890    
1891  (defun idlwave-shell-filename-string ()  (defun idlwave-shell-filename-string ()
# Line 1831  other completion functions can do their Line 1897  other completion functions can do their
1897        ;; Check of the next char is a string delimiter        ;; Check of the next char is a string delimiter
1898        (memq (preceding-char) '(?\' ?\")))))        (memq (preceding-char) '(?\' ?\")))))
1899    
1900    (defun idlwave-shell-batch-command ()
1901      "Returns t if we're in a batch command statement like @foo"
1902      (let ((limit (save-excursion (beginning-of-line) (point))))
1903        (save-excursion
1904          ;; Skip backwards over filename
1905          (skip-chars-backward idlwave-shell-file-name-chars limit)
1906          (skip-chars-backward " \t" limit)
1907          (and (eq (preceding-char) ?@) (not (idlwave-in-quote))))))
1908    
1909  ;;;  ;;;
1910  ;;; This section contains code for debugging IDL programs. --------------------  ;;; This section contains code for debugging IDL programs. --------------------
1911  ;;;  ;;;
# Line 2008  If FRAME is nil then remove overlay." Line 2083  If FRAME is nil then remove overlay."
2083    (or (not arg) (< arg 1)    (or (not arg) (< arg 1)
2084        (setq arg 1))        (setq arg 1))
2085    (idlwave-shell-send-command    (idlwave-shell-send-command
2086     (concat ".s " (if (integerp arg) (int-to-string arg) arg))))     (concat ".s " (if (integerp arg) (int-to-string arg) arg))
2087       nil (idlwave-shell-hide-p 'debug)))
2088    
2089  (defun idlwave-shell-stepover (arg)  (defun idlwave-shell-stepover (arg)
2090    "Stepover one source line.    "Stepover one source line.
# Line 2018  Uses IDL's stepover executive command wh Line 2094  Uses IDL's stepover executive command wh
2094    (or (not arg) (< arg 1)    (or (not arg) (< arg 1)
2095        (setq arg 1))        (setq arg 1))
2096    (idlwave-shell-send-command    (idlwave-shell-send-command
2097     (concat ".so " (if (integerp arg) (int-to-string arg) arg))))     (concat ".so " (if (integerp arg) (int-to-string arg) arg))
2098       nil (idlwave-shell-hide-p 'debug)))
2099    
2100  (defun idlwave-shell-break-here (&optional count cmd)  (defun idlwave-shell-break-here (&optional count cmd condition)
2101    "Set breakpoint at current line.      "Set breakpoint at current line.  
2102    
2103  If Count is nil then an ordinary breakpoint is set.  We treat a count  If Count is nil then an ordinary breakpoint is set.  We treat a count
# Line 2032  Optional argument CMD is a list or funct Line 2109  Optional argument CMD is a list or funct
2109  the breakpoint."  the breakpoint."
2110        
2111    (interactive "P")    (interactive "P")
2112    (if (listp count)    (when (listp count)
2113        (setq count nil))      (if (equal (car count) 4)
2114            (setq condition (read-string "Break Condition: ")))
2115        (setq count nil))
2116    (idlwave-shell-set-bp    (idlwave-shell-set-bp
2117     ;; Create breakpoint     ;; Create breakpoint
2118     (idlwave-shell-bp (idlwave-shell-current-frame)     (idlwave-shell-bp (idlwave-shell-current-frame)
2119                       (list count cmd)                       (list count cmd condition)
2120                       (idlwave-shell-current-module))))                       (idlwave-shell-current-module))))
2121    
2122  (defun idlwave-shell-set-bp-check (bp)  (defun idlwave-shell-set-bp-check (bp)
# Line 2061  the problem with not being able to set t Line 2140  the problem with not being able to set t
2140                ;; Clean up before retrying                ;; Clean up before retrying
2141                (idlwave-shell-command-failure)                (idlwave-shell-command-failure)
2142                (idlwave-shell-send-command                (idlwave-shell-send-command
2143                 (concat ".run " (idlwave-shell-bp-get bp 'file)) nil nil)                 (concat ".run " (idlwave-shell-bp-get bp 'file)) nil
2144                   (idlwave-shell-hide-p 'run))
2145                ;; Try setting breakpoint again                ;; Try setting breakpoint again
2146                (idlwave-shell-set-bp bp))                (idlwave-shell-set-bp bp))
2147            (beep)            (beep)
# Line 2084  breakpoint can not be set." Line 2164  breakpoint can not be set."
2164  (defun idlwave-shell-cont ()  (defun idlwave-shell-cont ()
2165    "Continue executing."    "Continue executing."
2166    (interactive)    (interactive)
2167    (idlwave-shell-send-command ".c" '(idlwave-shell-redisplay 'hide)))    (idlwave-shell-send-command ".c" '(idlwave-shell-redisplay 'hide)
2168                                  (idlwave-shell-hide-p 'debug)))
2169    
2170  (defun idlwave-shell-go ()  (defun idlwave-shell-go ()
2171    "Run .GO.  This starts the main program of the last compiled file."    "Run .GO.  This starts the main program of the last compiled file."
2172    (interactive)    (interactive)
2173    (idlwave-shell-send-command ".go" '(idlwave-shell-redisplay 'hide)))    (idlwave-shell-send-command ".go" '(idlwave-shell-redisplay 'hide)
2174                                  (idlwave-shell-hide-p 'debug)))
2175    
2176  (defun idlwave-shell-return ()  (defun idlwave-shell-return ()
2177    "Run .RETURN (continue to next return, but stay in subprogram)."    "Run .RETURN (continue to next return, but stay in subprogram)."
2178    (interactive)    (interactive)
2179    (idlwave-shell-send-command ".return" '(idlwave-shell-redisplay 'hide)))    (idlwave-shell-send-command ".return" '(idlwave-shell-redisplay 'hide)
2180                                  (idlwave-shell-hide-p 'debug)))
2181    
2182  (defun idlwave-shell-skip ()  (defun idlwave-shell-skip ()
2183    "Run .SKIP (skip one line, then step)."    "Run .SKIP (skip one line, then step)."
2184    (interactive)    (interactive)
2185    (idlwave-shell-send-command ".skip" '(idlwave-shell-redisplay 'hide)))    (idlwave-shell-send-command ".skip" '(idlwave-shell-redisplay 'hide)
2186                                  (idlwave-shell-hide-p 'debug)))
2187    
2188  (defun idlwave-shell-clear-bp (bp)  (defun idlwave-shell-clear-bp (bp)
2189    "Clear breakpoint BP.    "Clear breakpoint BP.
# Line 2109  Clears in IDL and in `idlwave-shell-bp-a Line 2193  Clears in IDL and in `idlwave-shell-bp-a
2193          (progn          (progn
2194            (idlwave-shell-send-command            (idlwave-shell-send-command
2195             (concat "breakpoint,/clear,"             (concat "breakpoint,/clear,"
2196                     (if (integerp index) (int-to-string index) index)))                     (if (integerp index) (int-to-string index) index))
2197               nil (idlwave-shell-hide-p 'breakpoint))
2198            (idlwave-shell-bp-query)))))            (idlwave-shell-bp-query)))))
2199    
2200  (defun idlwave-shell-current-frame ()  (defun idlwave-shell-current-frame ()
# Line 2155  at a breakpoint." Line 2240  at a breakpoint."
2240            (beep)            (beep)
2241            (message "Cannot identify breakpoint for this line"))))))            (message "Cannot identify breakpoint for this line"))))))
2242    
2243    (defun idlwave-shell-disable-all-bp (&optional enable)
2244      "Disable all breakpoints we know about.
2245    If ENABLE is non-nil, enable them instead."
2246      (let  ((bpl idlwave-shell-bp-alist))
2247        (while bpl
2248          (idlwave-shell-send-command
2249           (concat "breakpoint,"
2250                   (if enable "/enable," "/disable," )
2251                   (idlwave-shell-bp-get (car bpl)))
2252           nil (idlwave-shell-hide-p 'breakpoint))
2253          (setq bpl (cdr bpl)))))
2254      
2255  (defun idlwave-shell-to-here ()  (defun idlwave-shell-to-here ()
2256    "Set a breakpoint with count 1 then continue."    "Set a breakpoint with count 1 then continue."
2257    (interactive)    (interactive)
2258      (idlwave-shell-disable-all-bp)
2259    (idlwave-shell-break-here 1)    (idlwave-shell-break-here 1)
2260    (idlwave-shell-cont))    (idlwave-shell-cont)
2261      (idlwave-shell-disable-all-bp 'enable))
2262    
2263  (defun idlwave-shell-break-in (&optional module)  (defun idlwave-shell-break-in (&optional module)
2264    "Look for a module name near point and set a break point for it.    "Look for a module name near point and set a break point for it.
# Line 2244  Sets a breakpoint with count 1 at end of Line 2343  Sets a breakpoint with count 1 at end of
2343    "Attempt to run until this procedure exits.    "Attempt to run until this procedure exits.
2344  Runs to the last statement and then steps 1 statement.  Use the .out command."  Runs to the last statement and then steps 1 statement.  Use the .out command."
2345    (interactive)    (interactive)
2346    (idlwave-shell-send-command (concat ".o")))    (idlwave-shell-send-command ".o" nil (idlwave-shell-hide-p 'debug)))
2347    
2348  (defun idlwave-shell-help-expression (arg)  (defun idlwave-shell-help-expression (arg)
2349    "Print help on current expression.  See `idlwave-shell-print'."    "Print help on current expression.  See `idlwave-shell-print'."
# Line 2336  idlw-shell-examine-alist from which to s Line 2435  idlw-shell-examine-alist from which to s
2435         (arg         (arg
2436          (setq expr (read-string "Expression: ")))          (setq expr (read-string "Expression: ")))
2437         (t         (t
2438          (idlwave-with-special-syntax1          (idlwave-with-special-syntax
2439           ;; Move to beginning of current or previous expression           ;; Move to beginning of current or previous expression
2440           (if (looking-at "\\<\\|(")           (if (looking-at "\\<\\|(")
2441               ;; At beginning of expression, don't move backwards unless               ;; At beginning of expression, don't move backwards unless
# Line 2683  If there is a prefix argument, display I Line 2782  If there is a prefix argument, display I
2782                   (idlwave-look-at "\\<end\\>")))                   (idlwave-look-at "\\<end\\>")))
2783            (insert "\nend\n"))            (insert "\nend\n"))
2784        (save-buffer 0)))        (save-buffer 0)))
2785    (idlwave-shell-send-command (concat ".run " idlwave-shell-temp-pro-file))    (idlwave-shell-send-command (concat ".run " idlwave-shell-temp-pro-file)
2786                                  nil (idlwave-shell-hide-p 'run))
2787    (if n    (if n
2788        (idlwave-display-buffer (idlwave-shell-buffer)        (idlwave-display-buffer (idlwave-shell-buffer)
2789                                nil (idlwave-shell-shell-frame))))                                nil (idlwave-shell-shell-frame))))
# Line 2715  Does not work for a region with multilin Line 2815  Does not work for a region with multilin
2815          (error nil))))          (error nil))))
2816    
2817  (defun idlwave-display-buffer (buf not-this-window-p &optional frame)  (defun idlwave-display-buffer (buf not-this-window-p &optional frame)
2818    (if (not (frame-live-p frame)) (setq frame nil))    (if (featurep 'xemacs)
2819    (display-buffer buf not-this-window-p frame))        ;; The XEmacs version enforces the frame
2820          (display-buffer buf not-this-window-p frame)
2821        ;; For Emacs, we need to force the frame ourselves.
2822        (let ((this-frame (selected-frame)))
2823          (if (frame-live-p frame)
2824              (select-frame frame))
2825          (if (eq this-frame (selected-frame))
2826              ;; same frame:  use display buffer, to make sure the current
2827              ;; window stays.
2828              (display-buffer buf)
2829            ;; different frame
2830            (if (one-window-p)
2831                ;; only window:  switch
2832                (progn
2833                  (switch-to-buffer buf)
2834                  (selected-window))   ; must return the window.
2835              ;; several windows - use display-buffer
2836              (display-buffer buf not-this-window-p))))))
2837    ;  (if (not (frame-live-p frame)) (setq frame nil))
2838    ;  (display-buffer buf not-this-window-p frame))
2839    
2840  (defvar idlwave-shell-bp-buffer " *idlwave-shell-bp*"  (defvar idlwave-shell-bp-buffer " *idlwave-shell-bp*"
2841    "Scratch buffer for parsing IDL breakpoint lists and other stuff.")    "Scratch buffer for parsing IDL breakpoint lists and other stuff.")
# Line 2744  Defaults to 'index." Line 2863  Defaults to 'index."
2863     ((eq item 'data) (cdr (cdr bp)))     ((eq item 'data) (cdr (cdr bp)))
2864     ((eq item 'count) (nth 0 (cdr (cdr bp))))     ((eq item 'count) (nth 0 (cdr (cdr bp))))
2865     ((eq item 'cmd) (nth 1 (cdr (cdr bp))))     ((eq item 'cmd) (nth 1 (cdr (cdr bp))))
2866       ((eq item 'condition) (nth 2 (cdr (cdr bp))))
2867     ;; IDL breakpoint info     ;; IDL breakpoint info
2868     ((eq item 'module) (nth 1 (car (cdr bp))))     ((eq item 'module) (nth 1 (car (cdr bp))))
2869     ;;    index - default     ;;    index - default
# Line 2762  from previous breakpoint list." Line 2882  from previous breakpoint list."
2882            ;; Searching the breakpoints            ;; Searching the breakpoints
2883            ;; In IDL 5.5, the breakpoint reporting format changed.            ;; In IDL 5.5, the breakpoint reporting format changed.
2884            (bp-re54 "^[ \t]*\\([0-9]+\\)[ \t]+\\(\\S-+\\)?[ \t]+\\([0-9]+\\)[ \t]+\\(\\S-+\\)")            (bp-re54 "^[ \t]*\\([0-9]+\\)[ \t]+\\(\\S-+\\)?[ \t]+\\([0-9]+\\)[ \t]+\\(\\S-+\\)")
2885            (bp-re55 "^\\s-*\\([0-9]+\\)\\s-+\\([0-9]+\\)\\s-+\\(Uncompiled\\|Func=\\|Pro=\\)\\(\\S-+\\)?\\s-+\\(\\S-+\\)")            (bp-re55 "^\\s-*\\([0-9]+\\)\\s-+\\([0-9]+\\)\\s-+\\(Uncompiled\\|Func=\\|Pro=\\)\\([a-zA-Z][a-zA-Z0-9$_:]*\\)\\(,[^\n]*\n\\)?\\s-+\\(\\S-+\\)")
2886            file line index module            file line index module
2887            bp-re indmap)            bp-re indmap)
2888        (setq idlwave-shell-bp-alist (list nil))        (setq idlwave-shell-bp-alist (list nil))
# Line 2774  from previous breakpoint list." Line 2894  from previous breakpoint list."
2894               (if (re-search-forward               (if (re-search-forward
2895                    "^\\s-*Index\\s-*Line\\s-*Attributes\\s-*File" nil t)                    "^\\s-*Index\\s-*Line\\s-*Attributes\\s-*File" nil t)
2896                   (setq bp-re bp-re55    ; versions >= 5.5                   (setq bp-re bp-re55    ; versions >= 5.5
2897                         indmap '(1 4 2 5))))                         indmap '(1 4 2 6))))
2898          ;; There seems to be a breakpoint listing here.          ;; There seems to be a breakpoint listing here.
2899          ;; Parse breakpoint lines.          ;; Parse breakpoint lines.
2900          ;; Breakpoints have the form          ;; Breakpoints have the form
# Line 2844  Otherwise return the filename in bp." Line 2964  Otherwise return the filename in bp."
2964  The breakpoint will be placed at the beginning of the statement on the  The breakpoint will be placed at the beginning of the statement on the
2965  line specified by BP or at the next IDL statement if that line is not  line specified by BP or at the next IDL statement if that line is not
2966  a statement.  a statement.
2967  Determines IDL's internal representation for the breakpoint, which may  Determines IDL's internal representation for the breakpoint which may
2968  have occurred at a different line than used with the breakpoint  have occured at a different line then used with the breakpoint
2969  command."  command."
2970        
2971    ;; Get and save the old breakpoints    ;; Get and save the old breakpoints
# Line 2878  only after reaching the statement count Line 2998  only after reaching the statement count
2998                 ",/once")                 ",/once")
2999                ((> arg 1)                ((> arg 1)
3000                 (format ",after=%d" arg))))                 (format ",after=%d" arg))))
3001           (condition (idlwave-shell-bp-get bp 'condition))
3002           (key (concat key
3003                        (if condition (concat ",CONDITION=\"" condition "\""))))
3004         (line (idlwave-shell-bp-get bp 'line)))         (line (idlwave-shell-bp-get bp 'line)))
3005      (idlwave-shell-send-command      (idlwave-shell-send-command
3006       (concat "breakpoint,'"       (concat "breakpoint,'"
# Line 2888  only after reaching the statement count Line 3011  only after reaching the statement count
3011       `(progn       `(progn
3012         (if (idlwave-shell-set-bp-check (quote ,bp))         (if (idlwave-shell-set-bp-check (quote ,bp))
3013             (idlwave-shell-set-bp3 (quote ,bp))))             (idlwave-shell-set-bp3 (quote ,bp))))
3014       ;; do not hide output       ;; hide output?
3015       nil       (idlwave-shell-hide-p 'breakpoint)
3016       'preempt)))       'preempt)))
3017    
3018  (defun idlwave-shell-set-bp3 (bp)  (defun idlwave-shell-set-bp3 (bp)
# Line 3075  handled by this command." Line 3198  handled by this command."
3198                         (t (error "Unknown action %s" action)))                         (t (error "Unknown action %s" action)))
3199                   idlwave-shell-last-save-and-action-file)                   idlwave-shell-last-save-and-action-file)
3200           'idlwave-shell-maybe-update-routine-info           'idlwave-shell-maybe-update-routine-info
3201           nil)           (idlwave-shell-hide-p 'run))
3202          (idlwave-shell-bp-query))          (idlwave-shell-bp-query))
3203      (let ((msg (format "No such file %s"      (let ((msg (format "No such file %s"
3204                         idlwave-shell-last-save-and-action-file)))                         idlwave-shell-last-save-and-action-file)))
3205        (setq idlwave-shell-last-save-and-action-file nil)        (setq idlwave-shell-last-save-and-action-file nil)
3206        (error msg))))        (error msg))))
3207    
3208  (defun idlwave-shell-maybe-update-routine-info ()  (defun idlwave-shell-maybe-update-routine-info (&optional wait)
3209    "Update the routine info if the shell is not stopped at an error."    "Update the routine info if the shell is not stopped at an error."
3210    (if (and (not idlwave-shell-is-stopped)    (if (and (not idlwave-shell-is-stopped)
3211             (or (eq t idlwave-auto-routine-info-updates)             (or (eq t idlwave-auto-routine-info-updates)
3212                 (memq 'compile-buffer idlwave-auto-routine-info-updates))                 (memq 'compile-buffer idlwave-auto-routine-info-updates))
3213             idlwave-query-shell-for-routine-info             idlwave-query-shell-for-routine-info
3214             idlwave-routines)             idlwave-routines)
3215      (idlwave-shell-update-routine-info t)))        (idlwave-shell-update-routine-info t nil 'wait)))
3216    
3217  (defvar idlwave-shell-sources-query "help,/source,/full"  (defvar idlwave-shell-sources-query "help,/source,/full"
3218    "IDL command to obtain source files for compiled procedures.")    "IDL command to obtain source files for compiled procedures.")
# Line 3161  list elements of the form: Line 3284  list elements of the form:
3284                   ))))                   ))))
3285        (cdr al))))        (cdr al))))
3286    
   
3287  (defun idlwave-shell-clear-all-bp ()  (defun idlwave-shell-clear-all-bp ()
3288    "Remove all breakpoints in IDL."    "Remove all breakpoints in IDL."
3289    (interactive)    (interactive)
# Line 3235  Otherwise, just expand the file name." Line 3357  Otherwise, just expand the file name."
3357  (define-key idlwave-shell-mode-map "\M-\t"    'idlwave-shell-complete)  (define-key idlwave-shell-mode-map "\M-\t"    'idlwave-shell-complete)
3358  (define-key idlwave-shell-mode-map "\C-c\C-s" 'idlwave-shell)  (define-key idlwave-shell-mode-map "\C-c\C-s" 'idlwave-shell)
3359  (define-key idlwave-shell-mode-map "\C-c?"    'idlwave-routine-info)  (define-key idlwave-shell-mode-map "\C-c?"    'idlwave-routine-info)
3360    (define-key idlwave-shell-mode-map "\C-g"     'idlwave-keyboard-quit)
3361  (define-key idlwave-shell-mode-map "\M-?"     'idlwave-context-help)  (define-key idlwave-shell-mode-map "\M-?"     'idlwave-context-help)
3362    (define-key idlwave-shell-mode-map [(control meta ?\?)] 'idlwave-online-help)
3363  (define-key idlwave-shell-mode-map "\C-c\C-i" 'idlwave-update-routine-info)  (define-key idlwave-shell-mode-map "\C-c\C-i" 'idlwave-update-routine-info)
3364  (define-key idlwave-shell-mode-map "\C-c\C-y" 'idlwave-shell-char-mode-loop)  (define-key idlwave-shell-mode-map "\C-c\C-y" 'idlwave-shell-char-mode-loop)
3365  (define-key idlwave-shell-mode-map "\C-c\C-x" 'idlwave-shell-send-char)  (define-key idlwave-shell-mode-map "\C-c\C-x" 'idlwave-shell-send-char)
# Line 3526  static char * file[] = { Line 3650  static char * file[] = {
3650    
3651  (if idlwave-shell-use-toolbar  (if idlwave-shell-use-toolbar
3652      (add-hook 'idlwave-shell-mode-hook 'idlwave-toolbar-add-everywhere))      (add-hook 'idlwave-shell-mode-hook 'idlwave-toolbar-add-everywhere))
   
3653  ;;; idlw-shell.el ends here  ;;; idlw-shell.el ends here

Legend:
Removed from v.3.19  
changed lines
  Added in v.3.20

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26