-;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
-;; Free Software Foundation, Inc.
+;; Copyright (C) 2000-2011 Free Software Foundation, Inc.
;;
;; Authors: J.D. Smith <jdsmith@as.arizona.edu>
;; Carsten Dominik <dominik@science.uva.nl>
;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu>
;;
;; Authors: J.D. Smith <jdsmith@as.arizona.edu>
;; Carsten Dominik <dominik@science.uva.nl>
;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu>
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\f
;;; Code:
(defvar idlwave-help-browse-url-available t
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\f
;;; Code:
(defvar idlwave-help-browse-url-available t
(if idlwave-html-help-pre-v6 "#" "#wp"))
(defcustom idlwave-html-system-help-location "help/online_help/"
(if idlwave-html-help-pre-v6 "#" "#wp"))
(defcustom idlwave-html-system-help-location "help/online_help/"
HTML help files live, for IDL 6.2 and later. This location, if found,
HTML help files live, for IDL 6.2 and later. This location, if found,
(if (memq system-type '(ms-dos windows-nt))
nil
"/usr/local/etc/")
"The directory where the idl_html_help/ dir lives. Obsolete for IDL
(if (memq system-type '(ms-dos windows-nt))
nil
"/usr/local/etc/")
"The directory where the idl_html_help/ dir lives. Obsolete for IDL
Defaults to `browse-url-browser-function', which see."
:group 'idlwave-online-help
:type 'function)
(defcustom idlwave-help-browser-generic-program browse-url-generic-program
Defaults to `browse-url-browser-function', which see."
:group 'idlwave-online-help
:type 'function)
(defcustom idlwave-help-browser-generic-program browse-url-generic-program
(defcustom idlwave-help-use-dedicated-frame t
"*Non-nil means, use a separate frame for Online Help if possible."
(defcustom idlwave-help-use-dedicated-frame t
"*Non-nil means, use a separate frame for Online Help if possible."
"Face for highlighting links into IDLWAVE online help."
:group 'idlwave-online-help)
(defvar idlwave-help-activate-links-aggressively nil
"Obsolete variable.")
"Face for highlighting links into IDLWAVE online help."
:group 'idlwave-online-help)
(defvar idlwave-help-activate-links-aggressively nil
"Obsolete variable.")
(defvar idlwave-help-window-configuration nil)
(defvar idlwave-help-special-topic-words nil) ; defined by get_rinfo
(defvar idlwave-help-window-configuration nil)
(defvar idlwave-help-special-topic-words nil) ; defined by get_rinfo
;; Define the key bindings for the Help application
(defvar idlwave-help-mode-map (make-sparse-keymap)
;; Define the key bindings for the Help application
(defvar idlwave-help-mode-map (make-sparse-keymap)
(define-key idlwave-help-mode-map "q" 'idlwave-help-quit)
(define-key idlwave-help-mode-map "w" 'widen)
(define-key idlwave-help-mode-map "q" 'idlwave-help-quit)
(define-key idlwave-help-mode-map "w" 'widen)
(declare-function idlwave-what-module-find-class "idlwave")
(declare-function idlwave-where "idlwave")
(declare-function idlwave-what-module-find-class "idlwave")
(declare-function idlwave-where "idlwave")
"Major mode for displaying IDL Help.
This is a VIEW mode for the ASCII version of IDL Help files,
"Major mode for displaying IDL Help.
This is a VIEW mode for the ASCII version of IDL Help files,
Fontification: [F]ontify the buffer like source code
Jump: [h] to function doclib header
[H] to file doclib header
Fontification: [F]ontify the buffer like source code
Jump: [h] to function doclib header
[H] to file doclib header
(setq buffer-read-only t)
(set (make-local-variable 'idlwave-help-def-pos) nil)
(set (make-local-variable 'idlwave-help-args) nil)
(setq buffer-read-only t)
(set (make-local-variable 'idlwave-help-def-pos) nil)
(set (make-local-variable 'idlwave-help-args) nil)
(defun idlwave-html-help-location ()
"Return the help directory where HTML files are, or nil if that is unknown."
(defun idlwave-html-help-location ()
"Return the help directory where HTML files are, or nil if that is unknown."
idlwave-html-system-help-location (idlwave-sys-dir)))
(help-dir (or (and (stringp idlwave-html-help-location)
(> (length idlwave-html-help-location) 0)
idlwave-html-system-help-location (idlwave-sys-dir)))
(help-dir (or (and (stringp idlwave-html-help-location)
(> (length idlwave-html-help-location) 0)
(progn
(setq help-dir (expand-file-name "idl_html_help" help-dir))
(if (file-directory-p help-dir) help-dir))))))
(progn
(setq help-dir (expand-file-name "idl_html_help" help-dir))
(if (file-directory-p help-dir) help-dir))))))
(message "Cannot locate IDL Assistant, enabling default browser.")
(setq idlwave-help-use-assistant nil)
(unless idlwave-help-browse-url-available
(message "Cannot locate IDL Assistant, enabling default browser.")
(setq idlwave-help-use-assistant nil)
(unless idlwave-help-browse-url-available
(defvar idlwave-experimental)
(defvar idlwave-last-context-help-pos)
(defun idlwave-do-context-help (&optional arg)
(defvar idlwave-experimental)
(defvar idlwave-last-context-help-pos)
(defun idlwave-do-context-help (&optional arg)
It collects and prints the diagnostics messages."
(let ((marker (list (current-buffer) (point)))
(idlwave-help-diagnostics nil))
It collects and prints the diagnostics messages."
(let ((marker (list (current-buffer) (point)))
(idlwave-help-diagnostics nil))
(setq idlwave-last-context-help-pos marker)
(idlwave-do-context-help1 arg)
(if idlwave-help-diagnostics
(setq idlwave-last-context-help-pos marker)
(idlwave-do-context-help1 arg)
(if idlwave-help-diagnostics
(defun idlwave-do-context-help1 (&optional arg)
"The work-horse version of `idlwave-context-help', which see."
(save-excursion
(defun idlwave-do-context-help1 (&optional arg)
"The work-horse version of `idlwave-context-help', which see."
(save-excursion
(setq module (list "init" 'fun (match-string 1 str))
idlwave-current-obj_new-class (match-string 1 str))
)))))
(setq module (list "init" 'fun (match-string 1 str))
idlwave-current-obj_new-class (match-string 1 str))
)))))
;; A special topic -- only system help
((and st-ass (not (memq cw '(function-keyword procedure-keyword))))
(setq mod1 (list (cdr st-ass))))
;; A special topic -- only system help
((and st-ass (not (memq cw '(function-keyword procedure-keyword))))
(setq mod1 (list (cdr st-ass))))
;; An executive command -- only system help
((string-match "^\\.\\([A-Z_]+\\)" this-word)
(let* ((word (match-string 1 this-word))
;; An executive command -- only system help
((string-match "^\\.\\([A-Z_]+\\)" this-word)
(let* ((word (match-string 1 this-word))
(name (concat (downcase this-word) "__define"))
(link (nth 1 (assq 'link entry))))
(setq mod1 (list link name 'pro))))
(name (concat (downcase this-word) "__define"))
(link (nth 1 (assq 'link entry))))
(setq mod1 (list link name 'pro))))
;; A class structure tag (self.BLAH) -- only in-text help available
(classtag
(let ((tag (substring this-word (match-end 0)))
class-with found-in)
;; A class structure tag (self.BLAH) -- only in-text help available
(classtag
(let ((tag (substring this-word (match-end 0)))
class-with found-in)
(idlwave-class-or-superclass-with-tag
(nth 2 (idlwave-current-routine))
tag))
(setq found-in (idlwave-class-found-in class-with))
(idlwave-class-or-superclass-with-tag
(nth 2 (idlwave-current-routine))
tag))
(setq found-in (idlwave-class-found-in class-with))
idlwave-system-class-info)
(error "No help available for system class tags"))
(setq idlwave-help-do-class-struct-tag t)
idlwave-system-class-info)
(error "No help available for system class tags"))
(setq idlwave-help-do-class-struct-tag t)
(if found-in
(cons (concat found-in "__define") class-with)
(concat class-with "__define"))
'pro
nil ; no class.... it's a procedure!
tag)))))
(if found-in
(cons (concat found-in "__define") class-with)
(concat class-with "__define"))
'pro
nil ; no class.... it's a procedure!
tag)))))
;; A regular structure tag -- only in text, and if
;; optional `complete-structtag' loaded.
(structtag
;; A regular structure tag -- only in text, and if
;; optional `complete-structtag' loaded.
(structtag
(setq idlwave-help-do-struct-tag
idlwave-structtag-struct-location
mod1 (list nil nil nil nil tag))))
(setq idlwave-help-do-struct-tag
idlwave-structtag-struct-location
mod1 (list nil nil nil nil tag))))
(setq mod1 (append (list t) module (list keyword))
mod2 (list t this-word 'fun nil)
mod3 (append (list t) module)))))
(setq mod1 (append (list t) module (list keyword))
mod2 (list t this-word 'fun nil)
mod3 (append (list t) module)))))
;; See if we can also find help somewhere, e.g. for multiple classes
(setq word (idlwave-this-word))
(if (string= word "")
(error "No help item selected"))
;; See if we can also find help somewhere, e.g. for multiple classes
(setq word (idlwave-this-word))
(if (string= word "")
(error "No help item selected"))
"Select Class" 'sort))))
;; XXX is this necessary, given all-method-classes?
(if (stringp class)
(setq class (idlwave-find-inherited-class
"Select Class" 'sort))))
;; XXX is this necessary, given all-method-classes?
(if (stringp class)
(setq class (idlwave-find-inherited-class
classes (cons class sclasses))))
(setq class (idlwave-popup-select ev classes
"Select Class" 'sort))
;; XXX is this necessary, given all-method-keyword-classes?
(if (stringp class)
(setq class (idlwave-find-inherited-class
classes (cons class sclasses))))
(setq class (idlwave-popup-select ev classes
"Select Class" 'sort))
;; XXX is this necessary, given all-method-keyword-classes?
(if (stringp class)
(setq class (idlwave-find-inherited-class
"Highlight all completions for which help is available and attach link.
Those words in `idlwave-completion-help-links' have links. The
`idlwave-help-link' face is used for this."
"Highlight all completions for which help is available and attach link.
Those words in `idlwave-completion-help-links' have links. The
`idlwave-help-link' face is used for this."
(setq beg (match-beginning 1) end (match-end 1)
word (match-string 1) doit nil)
;; Call special completion function test
(setq beg (match-beginning 1) end (match-end 1)
word (match-string 1) doit nil)
;; Call special completion function test
;; Try to select the return frame.
;; This can crash on slow network connections, obviously when
;; we kill the help frame before the return-frame is selected.
;; Try to select the return frame.
;; This can crash on slow network connections, obviously when
;; we kill the help frame before the return-frame is selected.
;; and check if the return-frame *is* now selected.
;; This is marked "eperimental" since we are not sure when its OK.
(let ((maxtime 1.0) (time 0.) (step 0.1))
(select-frame idlwave-help-return-frame)
(while (and (sit-for step)
;; and check if the return-frame *is* now selected.
;; This is marked "eperimental" since we are not sure when its OK.
(let ((maxtime 1.0) (time 0.) (step 0.1))
(select-frame idlwave-help-return-frame)
(while (and (sit-for step)
idlwave-help-return-frame))
(< (setq time (+ time step)) maxtime)))))
(delete-frame idlwave-help-frame))
idlwave-help-return-frame))
(< (setq time (+ time step)) maxtime)))))
(delete-frame idlwave-help-frame))
Move window start to POS-OR-FUNC, if passed as a position, or call it
if passed as a function. See `idlwave-help-use-dedicated-frame'."
(let ((cw (selected-window))
Move window start to POS-OR-FUNC, if passed as a position, or call it
if passed as a function. See `idlwave-help-use-dedicated-frame'."
(let ((cw (selected-window))
(current-window-configuration)))
(display-buffer buf nil (selected-frame))
(select-window (get-buffer-window buf)))
(raise-frame)
(current-window-configuration)))
(display-buffer buf nil (selected-frame))
(select-window (get-buffer-window buf)))
(raise-frame)
(select-frame idlwave-help-return-frame)))
(defun idlwave-online-help (link &optional name type class keyword)
(select-frame idlwave-help-return-frame)))
(defun idlwave-online-help (link &optional name type class keyword)
Either loads an HTML link, if LINK is non-nil, or gets special-help on
the optional arguments, if any special help is defined. If LINK is
Either loads an HTML link, if LINK is non-nil, or gets special-help on
the optional arguments, if any special help is defined. If LINK is
(idlwave-entry-find-keyword entry keyword)))))
;; Default, regular entry link
(t (setq link (idlwave-entry-has-help entry))))
(idlwave-entry-find-keyword entry keyword)))))
;; Default, regular entry link
(t (setq link (idlwave-entry-has-help entry))))
class
;; Check for system class help
(setq entry (assq (idlwave-sintern-class class)
idlwave-system-class-info)
link (nth 1 (assq 'link entry))))
class
;; Check for system class help
(setq entry (assq (idlwave-sintern-class class)
idlwave-system-class-info)
link (nth 1 (assq 'link entry))))
(concat "No routine info for %s"
", falling back on class help.")
(idlwave-make-full-name class name))))))
(cond
;; An explicit link
(concat "No routine info for %s"
", falling back on class help.")
(idlwave-make-full-name class name))))))
(cond
;; An explicit link
(defun idlwave-help-get-special-help (name type class keyword)
"Call the function given by `idlwave-extra-help-function'."
(let* ((cw (selected-window))
(defun idlwave-help-get-special-help (name type class keyword)
"Call the function given by `idlwave-extra-help-function'."
(let* ((cw (selected-window))
(let ((browse-url-browser-function idlwave-help-browser-function)
(help-loc (idlwave-html-help-location))
(browse-url-generic-program idlwave-help-browser-generic-program)
(let ((browse-url-browser-function idlwave-help-browser-function)
(help-loc (idlwave-html-help-location))
(browse-url-generic-program idlwave-help-browser-generic-program)
;; Just a regular file name (+ anchor name)
(unless (and (stringp help-loc)
(file-directory-p help-loc))
;; Just a regular file name (+ anchor name)
(unless (and (stringp help-loc)
(file-directory-p help-loc))
(defvar idlwave-current-tags-buffer)
(defvar idlwave-current-tags-class)
(defun idlwave-help-with-source (name type class keyword)
(defvar idlwave-current-tags-buffer)
(defvar idlwave-current-tags-class)
(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.
+ "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)
This function can be used as `idlwave-extra-help-function'."
(let* ((class-struct-tag idlwave-help-do-class-struct-tag)
(if (or struct-tag (stringp file))
(progn
(setq in-buf ; structure-tag completion is always in current buffer
(if (or struct-tag (stringp file))
(progn
(setq in-buf ; structure-tag completion is always in current buffer
idlwave-current-tags-buffer
(idlwave-get-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))
idlwave-current-tags-buffer
(idlwave-get-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))
(substring name 0 (match-beginning 1))
idlwave-current-tags-class))
(and
(idlwave-find-class-definition class nil real-class)
(idlwave-find-struct-tag keyword))))
(substring name 0 (match-beginning 1))
idlwave-current-tags-class))
(and
(idlwave-find-class-definition class nil real-class)
(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)
;; 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 (boundp 'idlwave-help-min-frame-width)
(setq idlwave-help-min-frame-width 80))
(goto-char (or header-pos def-pos)))
(if (boundp 'idlwave-help-min-frame-width)
(setq idlwave-help-min-frame-width 80))
(goto-char (or header-pos def-pos)))
(defun idlwave-help-find-routine-definition (name type class keyword)
"Find the definition of routine CLASS::NAME in current buffer.
(defun idlwave-help-find-routine-definition (name type class keyword)
"Find the definition of routine CLASS::NAME in current buffer.
If there is a match, we assume it is the keyword description."
(let* ((case-fold-search t)
(rname (if (stringp class)
If there is a match, we assume it is the keyword description."
(let* ((case-fold-search t)
(rname (if (stringp class)
"\\("
;; Traditional name or class::name
"\\("
"\\(" (regexp-quote (downcase class)) "::\\)?"
(regexp-quote (downcase name))
"\\>\\)"
"\\("
;; Traditional name or class::name
"\\("
"\\(" (regexp-quote (downcase class)) "::\\)?"
(regexp-quote (downcase name))
"\\>\\)"
"\\|"
;; class__define or just class
(regexp-quote (downcase class)) "\\(__define\\)?")
"\\)")
(regexp-quote (downcase name))))
"\\|"
;; class__define or just class
(regexp-quote (downcase class)) "\\(__define\\)?")
"\\)")
(regexp-quote (downcase name))))
(idlwave-help-find-first-header nil)
(setq idlwave-help-in-header nil)
(idlwave-help-toggle-header-match-and-def arg 'top)))
(idlwave-help-find-first-header nil)
(setq idlwave-help-in-header nil)
(idlwave-help-toggle-header-match-and-def arg 'top)))
(defun idlwave-help-error (name type class keyword)
(error "Can't find help on %s%s %s"
(or (and (or class name) (idlwave-make-full-name class name))
(defun idlwave-help-error (name type class keyword)
(error "Can't find help on %s%s %s"
(or (and (or class name) (idlwave-make-full-name class name))
;; The Windows version does not have a !DIR/bin/* set of front-end
;; scripts, but instead only links directly to bin.x86. As a result,
;; we must pass the -profile argument as well.
;; The Windows version does not have a !DIR/bin/* set of front-end
;; scripts, but instead only links directly to bin.x86. As a result,
;; we must pass the -profile argument as well.
(not (eq (process-status idlwave-help-assistant-socket) 'open)))
(let* ((help-loc (idlwave-html-help-location))
(command (idlwave-help-assistant-command))
(not (eq (process-status idlwave-help-assistant-socket) 'open)))
(let* ((help-loc (idlwave-html-help-location))
(command (idlwave-help-assistant-command))
(nconc
(if (memq system-type '(ms-dos windows-nt))
`("-profile" ,(expand-file-name "idl.adp" help-loc)))
(if full-link `("-file" ,full-link))))
port)
(nconc
(if (memq system-type '(ms-dos windows-nt))
`("-profile" ,(expand-file-name "idl.adp" help-loc)))
(if full-link `("-file" ,full-link))))
port)
(set-process-filter idlwave-help-assistant-process
(lambda (proc string)
(setq port (string-to-number string))))
(unless (accept-process-output idlwave-help-assistant-process 15)
(error "Failed binding IDL_ASSISTANT socket"))
(if (not port)
(set-process-filter idlwave-help-assistant-process
(lambda (proc string)
(setq port (string-to-number string))))
(unless (accept-process-output idlwave-help-assistant-process 15)
(error "Failed binding IDL_ASSISTANT socket"))
(if (not port)
;; Open a link (file name with anchor, no leading path) in the assistant.
(let ((help-loc (idlwave-html-help-location))
topic anchor file just-started exists full-link)
;; Open a link (file name with anchor, no leading path) in the assistant.
(let ((help-loc (idlwave-html-help-location))
topic anchor file just-started exists full-link)
(if (string-match "\.html" link)
(setq topic (substring link 0 (match-beginning 0))
anchor (substring link (match-end 0)))
(if (string-match "\.html" link)
(setq topic (substring link 0 (match-beginning 0))
anchor (substring link (match-end 0)))
(setq full-link (concat file anchor)
just-started (idlwave-help-assistant-start (if exists full-link)))
(if exists
(setq full-link (concat file anchor)
just-started (idlwave-help-assistant-start (if exists full-link)))
(if exists
"Help Topic: " list
nil nil nil
'idlwave-help-assistant-help-with-topic-history)))
(if (and topic (not (string= topic "")))
(idlwave-help-assistant-open-link (concat topic ".html")))))
"Help Topic: " list
nil nil nil
'idlwave-help-assistant-help-with-topic-history)))
(if (and topic (not (string= topic "")))
(idlwave-help-assistant-open-link (concat topic ".html")))))
(defun idlwave-help-assistant-close ()
(when (and idlwave-help-assistant-process
(eq (process-status idlwave-help-assistant-process) 'run))
(defun idlwave-help-assistant-close ()
(when (and idlwave-help-assistant-process
(eq (process-status idlwave-help-assistant-process) 'run))