Function: idlwave-shell-print

idlwave-shell-print is an interactive and byte-compiled function defined in idlw-shell.el.gz.

Signature

(idlwave-shell-print ARG &optional HELP EV COMPLETE-HELP-TYPE)

Documentation

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 directly following the identifier - an array or function call. Alternatively, an expression is the contents of any matched parentheses when the open parenthesis is not directly preceded by an identifier. If point is at the beginning or within an expression 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 idlwave-shell-examine-alist from which to select the help command text. If instead COMPLETE-HELP-TYPE is non-nil, choose from idlwave-shell-examine-alist via mini-buffer shortcut key.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/idlw-shell.el.gz
(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
directly following the identifier - an array or function call.
Alternatively, an expression is the contents of any matched
parentheses when the open parenthesis is not directly preceded by an
identifier.  If point is at the beginning or within an expression
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
`idlwave-shell-examine-alist' from which to select the help
command text.  If instead COMPLETE-HELP-TYPE is non-nil, choose
from `idlwave-shell-examine-alist' via mini-buffer shortcut key."
  (interactive "P")

  ;; For speed: assume the helper routine hasn't been lost, e.g. with
  ;; .FULL_RESET_SESSION.  We'll recover if necessary
  (unless idlwave-idlwave_routine_info-compiled
    (idlwave-shell-compile-helper-routines))
  (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)
      (cond
       ((equal arg '(16))
	(setq expr (read-string "Expression: ")))
       ((and (or arg (region-active-p))
	     (< (- (region-end) (region-beginning)) 2000))
	(setq beg (region-beginning)
	      end (region-end)))
       (t
	(with-syntax-table idlwave-find-symbol-syntax-table
	 ;; Move to beginning of current or previous expression
	 (if (looking-at "\\<\\|(")
	     ;; At beginning of expression, don't move backwards unless
	     ;; this is at the end of an identifier.
	     (if (looking-at "\\>")
		 (backward-sexp))
	   (backward-sexp))
	 (if (looking-at "\\>")
	     ;; Move to beginning of identifier - must be an array or
	     ;; function expression.
	     (backward-sexp))
	 ;; Move to end of expression
	 (setq beg (point))
	 (forward-sexp)
	 (while (looking-at "\\>[[(]\\|\\.")
	   ;; 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.
      (when (and beg end)
	(if (and process-mark (> process-mark beg) (< process-mark end))
	    (setq beg (marker-position process-mark)))
	(setq expr (buffer-substring beg end)))

      ;; 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))
      (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)))
      ;; Concatenate continuation lines
      (while (string-match "[ \t]*\\$[ \t]*\\(;.*\\)?\\(\n[ \t]*\\|$\\)" expr)
	(setq expr (replace-match "" t t expr)))
      ;; 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
	 'idlwave-shell-check-compiled-and-display
	 (if idlwave-shell-separate-examine-output 'hide))))))