Function: idlwave-help-with-source

idlwave-help-with-source is a byte-compiled function defined in idlw-help.el.gz.

Signature

(idlwave-help-with-source NAME TYPE CLASS KEYWORD)

Documentation

Provide help for routines not documented in the IDL manuals.

Works by loading the routine source file into the help buffer. Depending on the value of idlwave-help-source-try-header, it attempts to show the routine definition or the header description. If idlwave-help-do-class-struct-tag is non-nil, keyword is a tag to show help on from the class definition structure. If idlwave-help-do-struct-tag is non-nil, show help from the matching structure tag definition.

This function can be used as idlwave-extra-help-function.

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/idlw-help.el.gz
(defun idlwave-help-with-source (name type class keyword)
  "Provide help for routines not documented in the IDL manuals.
Works by loading the routine source file into the help buffer.
Depending on the value of `idlwave-help-source-try-header', it
attempts to show the routine definition or the header description.
If `idlwave-help-do-class-struct-tag' is non-nil, keyword is a tag
to show help on from the class definition structure.
If `idlwave-help-do-struct-tag' is non-nil, show help from the
matching structure tag definition.

This function can be used as `idlwave-extra-help-function'."
  (let* ((class-struct-tag idlwave-help-do-class-struct-tag)
	 (struct-tag idlwave-help-do-struct-tag)
	 (case-fold-search t)
	 (real-class (if (consp name) (cdr name)))
	 (name (if (consp name) (car name) name))
	 (class-only (and (stringp class) (not (stringp name))))
	 file header-pos def-pos in-buf)
    (if class-only   ;Help with class?  Using "Init" as source.
	(setq name "Init"
	      type 'fun))
    (if (not struct-tag)
	(setq file
	      (idlwave-routine-source-file
	       (nth 3 (idlwave-best-rinfo-assoc
		       name (or type t) class (idlwave-routines))))))
    (setq idlwave-help-def-pos nil
	  idlwave-help-args (list name type class keyword)
	  idlwave-help-in-header nil
	  idlwave-help-do-struct-tag nil
	  idlwave-help-do-class-struct-tag nil)
    (if (or struct-tag (stringp file))
	(progn
	  (setq in-buf ; structure-tag completion is always in current buffer
		(if struct-tag
		    idlwave-current-tags-buffer
                  (find-buffer-visiting file)))
	  ;; see if file is in a visited buffer, insert those contents
	  (if in-buf
	      (progn
		(setq file (buffer-file-name in-buf))
		(erase-buffer)
		(insert-buffer-substring in-buf))
	    (if (file-exists-p file) ;; otherwise just load the file
		(progn
		  (erase-buffer)
		  (insert-file-contents file nil nil nil 'replace))
	      (idlwave-help-error name type class keyword)))
	  (goto-char (point-min))
	  (if (and idlwave-help-fontify-source-code (not in-buf))
	      (idlwave-help-fontify)))
      (idlwave-help-error name type class keyword))
    (setq idlwave-help-mode-line-indicator file)

    ;; Try to find a good place to display
    (setq def-pos
	  ;; Find the class structure tag if that's what we're after
	  (cond
	   ;; Class structure tags: find the class or named structure
	   ;; definition
	   (class-struct-tag
	    (save-excursion
	      (setq class
		    (if (string-match "[a-zA-Z0-9]\\(__\\)" name)
			(substring name 0 (match-beginning 1))
		      idlwave-current-tags-class))
	      (and
	       (idlwave-find-class-definition class nil real-class)
	       (idlwave-find-struct-tag keyword))))

	   ;; Generic structure tags: the structure definition
	   ;; location within the file has been recorded in
	   ;; `struct-tag'
	   (struct-tag
	    (save-excursion
	      (and
	       (integerp struct-tag)
	       (goto-char struct-tag)
	       (idlwave-find-struct-tag keyword))))

	   ;; Just find the routine definition
	   (t
	    (if class-only (point-min)
	      (idlwave-help-find-routine-definition name type class keyword))))
	  idlwave-help-def-pos def-pos)

    (if (and idlwave-help-source-try-header
	     (not (or struct-tag class-struct-tag)))
	;; Check if we can find the header
	(save-excursion
	  (goto-char (or def-pos (point-max)))
	  (setq header-pos (idlwave-help-find-in-doc-header
			    name type class keyword 'exact)
		idlwave-help-in-header header-pos)))

    (if (or header-pos def-pos)
	(progn
	  (if (boundp 'idlwave-help-min-frame-width)
	      (setq idlwave-help-min-frame-width 80))
	  (goto-char (or header-pos def-pos)))
      (idlwave-help-error name type class keyword))

    (point)))