Function: srecode-insert-fcn

srecode-insert-fcn is a byte-compiled function defined in insert.el.gz.

Signature

(srecode-insert-fcn TEMPLATE DICTIONARY &optional STREAM SKIPRESOLVER)

Documentation

Insert TEMPLATE using DICTIONARY into STREAM.

Optional SKIPRESOLVER means to avoid refreshing the tag list, or resolving any template arguments. It is assumed the caller has set everything up already.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/srecode/insert.el.gz
(defun srecode-insert-fcn (template dictionary &optional stream skipresolver)
  "Insert TEMPLATE using DICTIONARY into STREAM.
Optional SKIPRESOLVER means to avoid refreshing the tag list,
or resolving any template arguments.  It is assumed the caller
has set everything up already."
  ;; Perform the insertion.
  (let ((standard-output (or stream (current-buffer)))
	(end-mark nil))
    ;; Merge any template entries into the input dictionary.
    (when (slot-boundp template 'dictionary)
      (srecode-dictionary-merge dictionary (oref template dictionary)))

    (unless skipresolver
      ;; Make sure the semantic tags are up to date.
      (semantic-fetch-tags)
      ;; Resolve the arguments
      (srecode-resolve-arguments template dictionary))
    ;; Insert
    (if (bufferp standard-output)
	;; If there is a buffer, turn off various hooks.  This will cause
	;; the mod hooks to be buffered up during the insert, but
	;; prevent tools like font-lock from fontifying mid-template.
	;; Especially important during insertion of complex comments that
	;; cause the new font-lock to comment-color stuff after the inserted
	;; comment.
	;;
	;; I'm not sure about the motion hooks.  It seems like a good
	;; idea though.
	;;
	;; Borrowed these concepts out of font-lock.
	;;
	;; I tried `combine-after-change-calls', but it did not have
	;; the effect I wanted.
	(let ((start (point)))
	  (let ((inhibit-modification-hooks t))
	    (srecode--insert-into-buffer template dictionary)
	    )
	  ;; Now call those after change functions.
	  (run-hook-with-args 'after-change-functions
			      start (point) 0)
	  )
      (srecode-insert-method template dictionary))
    ;; Handle specialization of the POINT inserter.
    (when (bufferp standard-output)
      (let ((point (oref-default 'srecode-template-inserter-point point)))
        (when point
          (set-buffer standard-output)
          (setq end-mark (point-marker))
          (goto-char point))))
    (oset-default 'srecode-template-inserter-point point nil)

    ;; Return the end-mark.
    (or end-mark (point)))
  )