Function: idlwave-shell-send-command
idlwave-shell-send-command is an autoloaded and byte-compiled function
defined in idlw-shell.el.gz.
Signature
(idlwave-shell-send-command &optional CMD PCMD HIDE PREEMPT SHOW-IF-ERROR)
Documentation
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 in idlwave-shell-pending-commands,
CMD, 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 if it contains an error message, independent of what HIDE is set to.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/idlw-shell.el.gz
(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 in `idlwave-shell-pending-commands',
CMD, 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 if 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))
buf proc)
;; Get or make the buffer and its process
(if (or (not (setq buf (get-buffer (idlwave-shell-buffer))))
(not (setq proc (get-buffer-process buf))))
(if (not idlwave-shell-automatic-start)
(error "%s"
(substitute-command-keys
"You need to first start an IDL shell with \\[idlwave-shell]"))
(idlwave-shell-recenter-shell-window)
(setq buf (get-buffer (idlwave-shell-buffer)))
(if (or (not (setq buf (get-buffer (idlwave-shell-buffer))))
(not (setq proc (get-buffer-process buf))))
;; Still nothing
(error "Problem with autostarting IDL shell"))))
(when (or cmd idlwave-shell-pending-commands)
(set-buffer buf)
;; To make this easy, always push CMD onto pending commands
(if cmd
(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))
(if (and idlwave-shell-ready
;; Check for IDL prompt
(prog2
(forward-line 0)
;; (beginning-of-line) ; Changed for Emacs 21
(looking-at idlwave-shell-prompt-pattern)
(goto-char (process-mark proc))))
;; IDL ready for command, execute it
(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))
;; Set post-command
(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))
;; Send command for execution
(set-marker comint-last-input-start (point))
(set-marker comint-last-input-end (point))
(comint-simple-send proc cmd)
(setq idlwave-shell-ready nil)
(if (equal preempt 'wait) ; Get all the output at once
(while (not idlwave-shell-ready)
(when (not (accept-process-output proc 6)) ; long wait
(setq idlwave-shell-pending-commands nil)
(error "Process timed out"))))))
(goto-char save-point))
(set-buffer save-buffer))))