Function: idlwave-template

idlwave-template is a byte-compiled function defined in idlwave.el.gz.

Signature

(idlwave-template S1 S2 &optional PROMPT NOINDENT)

Documentation

Build a template with optional prompt expression.

Opens a line if point is not followed by a newline modulo intervening whitespace. S1 and S2 are strings. S1 is inserted at point followed by S2. Point is inserted between S1 and S2. The case of S1 and S2 is adjusted according to idlwave-abbrev-change-case. If optional argument PROMPT is a string then it is displayed as a message in the minibuffer. The PROMPT serves as a reminder to the user of an expression to enter.

The lines containing S1 and S2 are reindented using indent-region unless the optional second argument NOINDENT is non-nil.

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/idlwave.el.gz
;; Statement templates

;; Replace these with a general template function, something like
;; expand.el (I think there was also something with a name similar to
;; dmacro.el)

(defun idlwave-template (s1 s2 &optional prompt noindent)
  "Build a template with optional prompt expression.

Opens a line if point is not followed by a newline modulo intervening
whitespace.  S1 and S2 are strings.  S1 is inserted at point followed
by S2.  Point is inserted between S1 and S2.  The case of S1 and S2 is
adjusted according to `idlwave-abbrev-change-case'.  If optional
argument PROMPT is a string then it is displayed as a message in the
minibuffer.  The PROMPT serves as a reminder to the user of an
expression to enter.

The lines containing S1 and S2 are reindented using `indent-region'
unless the optional second argument NOINDENT is non-nil."
  (if (derived-mode-p 'idlwave-shell-mode)
      ;; This is a gross hack to avoid template abbrev expansion
      ;; in the shell.  FIXME: This is a dirty hack.
      (if (and (eq this-command 'self-insert-command)
	       (equal last-abbrev-location (point)))
	  (insert last-abbrev-text)
	(error "No templates in idlwave-shell"))
    (cond ((eq idlwave-abbrev-change-case 'down)
	   (setq s1 (downcase s1) s2 (downcase s2)))
	  (idlwave-abbrev-change-case
	   (setq s1 (upcase s1) s2 (upcase s2))))
    (let ((beg (line-beginning-position))
	  end)
      (if (not (looking-at "\\s-*\n"))
	  (open-line 1))
      (insert s1)
      (save-excursion
	(insert s2)
	(setq end (point)))
      (if (not noindent)
	  (indent-region beg end nil))
      (if (stringp prompt)
	  (message "%s" prompt)))))