;;; idlw-help.el --- HTML Help code for IDLWAVE
-;; Copyright (c) 2000 Carsten Dominik
-;; Copyright (c) 2001, 2002 J.D. Smith
-;; Copyright (c) 2003, 2004, 2005, Free Software Foundation
+
+;; 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>
-;; Version: 5.7_22
+;; Version: 6.1.22
+;; Package: idlwave
;; This file is part of GNU Emacs.
-;; This file is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
-;; This file is distributed in the hope that it will be useful,
+;; GNU Emacs is distributed in the hope that it will be useful,
;; 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/>.
;;; Commentary:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\f
-;;; Code:
-(defvar browse-url-generic-args)
-(defvar idlwave-help-browse-url-available nil
- "Whether browse-url is available")
+;;; Code:
+(defvar idlwave-help-browse-url-available t
+ "Whether browse-url is available.")
-(setq idlwave-help-browse-url-available
- (condition-case nil
- (require 'browse-url)
- (error nil)))
+(require 'browse-url)
(defgroup idlwave-online-help nil
"Online Help options for IDLWAVE mode."
(defvar idlwave-html-link-sep
(if idlwave-html-help-pre-v6 "#" "#wp"))
+(defcustom idlwave-html-system-help-location "help/online_help/"
+ "The directory, relative to `idlwave-system-directory', where the IDL
+HTML help files live, for IDL 6.2 and later. This location, if found,
+is used in preference to the old `idlwave-html-help-location'."
+ :group 'idlwave-online-help
+ :type 'directory)
+
(defcustom idlwave-html-help-location
- (if (memq system-type '(ms-dos windows-nt))
+ (if (memq system-type '(ms-dos windows-nt))
nil
"/usr/local/etc/")
- "The directory where the idl_html_help/ dir or idl.chm help file
-(Windows only) lives."
+ "The directory where the idl_html_help/ dir lives. Obsolete for IDL
+6.2 or later (see `idlwave-html-system-help-location')."
:group 'idlwave-online-help
:type 'directory)
-(defcustom idlwave-help-use-hh nil
- "Whether to use the HTMLHelp viewer with idl.chm (Windows only)."
+(defvar idlwave-help-use-hh nil
+ "Obsolete variable.")
+
+(defcustom idlwave-help-use-assistant t
+ "Whether to use the IDL Assistant as the help browser."
:group 'idlwave-online-help
- :type '(choice :tag "use help viewer"
- (const :tag "<none>" nil)
- (const :tag "hh" 'hh)
- (const :tag "keyhh" 'keyhh)))
+ :type 'boolean)
(defcustom idlwave-help-browser-function browse-url-browser-function
- "Function to use to display html help.
+ "Function to use to display HTML help.
Defaults to `browse-url-browser-function', which see."
:group 'idlwave-online-help
:type 'function)
(defcustom idlwave-help-browser-generic-program browse-url-generic-program
- "Program to run if using browse-url-generic-program."
+ "Program to run if using `browse-url-generic-program'."
:group 'idlwave-online-help
:type 'string)
+(defvar browse-url-generic-args)
+
(defcustom idlwave-help-browser-generic-args
(if (boundp 'browse-url-generic-args)
browse-url-generic-args "")
- "Program args to use if using browse-url-generic-program."
+ "Program args to use if using `browse-url-generic-program'."
:group 'idlwave-online-help
:type 'string)
:type 'boolean)
(defvar idlwave-help-directory ""
- "Obsolete variable. See idlwave-html-help-location.")
+ "Obsolete variable. See `idlwave-html-help-location'.")
(defcustom idlwave-help-use-dedicated-frame t
"*Non-nil means, use a separate frame for Online Help if possible."
:type 'string)
(defface idlwave-help-link
- '((((class color)) (:foreground "Blue"))
- (t (:weight bold)))
+ '((t :inherit link))
"Face for highlighting links into IDLWAVE online help."
:group 'idlwave-online-help)
"The default width of the help frame.")
(defvar idlwave-html-help-is-available nil
- "Is the system online help text avaiable?")
+ "Is the system online help text available?")
(defvar idlwave-help-mode-line-indicator ""
- "Used for the special mode line in the idlwave-help-mode.")
+ "Used for the special mode line in the `idlwave-help-mode'.")
(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)
- "The keymap used in idlwave-help-mode.")
+ "The keymap used in `idlwave-help-mode'.")
(define-key idlwave-help-mode-map "q" 'idlwave-help-quit)
(define-key idlwave-help-mode-map "w" 'widen)
(defvar idlwave-help-def-pos)
(defvar idlwave-help-args)
(defvar idlwave-help-in-header)
-
-(defun idlwave-help-mode ()
+(declare-function idlwave-prepare-structure-tag-completion "idlw-complete-structtag")
+(declare-function idlwave-all-method-classes "idlwave")
+(declare-function idlwave-all-method-keyword-classes "idlwave")
+(declare-function idlwave-beginning-of-statement "idlwave")
+(declare-function idlwave-best-rinfo-assoc "idlwave")
+(declare-function idlwave-class-found-in "idlwave")
+(declare-function idlwave-class-or-superclass-with-tag "idlwave")
+(declare-function idlwave-completing-read "idlwave")
+(declare-function idlwave-current-routine "idlwave")
+(declare-function idlwave-downcase-safe "idlwave")
+(declare-function idlwave-entry-find-keyword "idlwave")
+(declare-function idlwave-expand-keyword "idlwave")
+(declare-function idlwave-find-class-definition "idlwave")
+(declare-function idlwave-find-inherited-class "idlwave")
+(declare-function idlwave-find-struct-tag "idlwave")
+(declare-function idlwave-get-buffer-visiting "idlwave")
+(declare-function idlwave-in-quote "idlwave")
+(declare-function idlwave-make-full-name "idlwave")
+(declare-function idlwave-members-only "idlwave")
+(declare-function idlwave-popup-select "idlwave")
+(declare-function idlwave-routine-source-file "idlwave")
+(declare-function idlwave-routines "idlwave")
+(declare-function idlwave-sintern-class "idlwave")
+(declare-function idlwave-sintern-keyword "idlwave")
+(declare-function idlwave-sintern-method "idlwave")
+(declare-function idlwave-sintern-routine-or-method "idlwave")
+(declare-function idlwave-sintern-sysvar "idlwave" t t);idlwave-new-sintern-type
+(declare-function idlwave-sintern-sysvartag "idlwave" t t)
+(declare-function idlwave-substitute-link-target "idlwave")
+(declare-function idlwave-sys-dir "idlwave")
+(declare-function idlwave-this-word "idlwave")
+(declare-function idlwave-what-module-find-class "idlwave")
+(declare-function idlwave-where "idlwave")
+
+(define-derived-mode idlwave-help-mode special-mode "IDLWAVE Help"
"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
- [.] back and forward between header and definition
+ [.] back and forth between header and definition
Here are all keybindings.
\\{idlwave-help-mode-map}"
- (kill-all-local-variables)
(buffer-disable-undo)
- (setq major-mode 'idlwave-help-mode
- mode-name "IDLWAVE Help")
- (use-local-map idlwave-help-mode-map)
(easy-menu-add idlwave-help-menu idlwave-help-mode-map)
(setq truncate-lines t)
(setq case-fold-search t)
(setq buffer-read-only t)
(set (make-local-variable 'idlwave-help-def-pos) nil)
(set (make-local-variable 'idlwave-help-args) nil)
- (set (make-local-variable 'idlwave-help-in-header) nil)
- (run-mode-hooks 'idlwave-help-mode-hook))
+ (set (make-local-variable 'idlwave-help-in-header) nil))
-(defvar idlwave-system-directory)
(defun idlwave-html-help-location ()
"Return the help directory where HTML files are, or nil if that is unknown."
- (or (and (stringp idlwave-html-help-location)
- (> (length idlwave-html-help-location) 0)
- (file-directory-p idlwave-html-help-location)
- idlwave-html-help-location)
- (getenv "IDLWAVE_HELP_LOCATION")
- (and (memq system-type '(ms-dos windows-nt)) ; Base it on sysdir
- idlwave-help-use-hh
- (stringp idlwave-system-directory)
- (> (length idlwave-system-directory) 0)
- (file-directory-p idlwave-system-directory)
- (expand-file-name "HELP" idlwave-system-directory))))
+ (let ((syshelp-dir (expand-file-name
+ 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-help-location)
+ (getenv "IDLWAVE_HELP_LOCATION"))))
+ (if (and syshelp-dir (file-directory-p syshelp-dir))
+ syshelp-dir
+ (if help-dir
+ (progn
+ (setq help-dir (expand-file-name "idl_html_help" help-dir))
+ (if (file-directory-p help-dir) help-dir))))))
+
+(defvar idlwave-help-assistant-available nil)
+
+(defun idlwave-help-check-locations ()
+ ;; Check help locations and assistant.
+ (let ((sys-dir (idlwave-sys-dir))
+ (help-loc (idlwave-html-help-location)))
+ (if (or (not (file-directory-p sys-dir))
+ (not help-loc)
+ (not (file-directory-p help-loc)))
+ (message
+ "HTML help location not found: try setting `idlwave-system-directory' and/or `idlwave-html-help-location'."))
+ ;; see if we have the assistant
+ (when (and idlwave-help-use-assistant
+ (not (eq (idlwave-help-assistant-available) t)))
+ (message "Cannot locate IDL Assistant, enabling default browser.")
+ (setq idlwave-help-use-assistant nil)
+ (unless idlwave-help-browse-url-available
+ (error "browse-url is not available; install it or IDL Assistant to use HTML help")))))
+
(defvar idlwave-current-obj_new-class)
(defvar idlwave-help-diagnostics)
(defvar idlwave-experimental)
(defvar idlwave-last-context-help-pos)
(defun idlwave-do-context-help (&optional arg)
- "Wrapper around the call to idlwave-context-help1.
+ "Wrapper around the call to `idlwave-do-context-help1'.
It collects and prints the diagnostics messages."
(let ((marker (list (current-buffer) (point)))
(idlwave-help-diagnostics nil))
(beg (save-excursion (skip-chars-backward chars) (point)))
(end (save-excursion (skip-chars-forward chars) (point)))
(this-word (buffer-substring-no-properties beg end))
- (st-ass (assoc (downcase this-word)
- idlwave-help-special-topic-words))
+ (st-ass (assoc-string this-word
+ idlwave-help-special-topic-words t))
(classtag (and (string-match "self\\." this-word)
(< beg (- end 4))))
(structtag (and (fboundp 'idlwave-complete-structure-tag)
(< beg (- end 4))))
module keyword cw mod1 mod2 mod3)
(if (or arg
- (and (not st-ass)
- (not classtag)
+ (and (not classtag)
(not structtag)
(not (member (string-to-char this-word) '(?! ?.)))))
;; Need the module information
(arg (setq mod1 module))
;; A special topic -- only system help
- (st-ass (setq mod1 (list (cdr st-ass))))
+ ((and st-ass (not (memq cw '(function-keyword procedure-keyword))))
+ (setq mod1 (list (cdr st-ass))))
;; A system variable -- only system help
((string-match
(let* ((cw (selected-window))
(info idlwave-completion-help-info) ; global passed in
(what (nth 0 info))
- (name (nth 1 info))
+ (idlw-help-name (nth 1 info))
(type (nth 2 info))
(class (nth 3 info))
(need-class class)
- (kwd (nth 4 info))
+ (idlw-help-kwd (nth 4 info))
(sclasses (nth 5 info))
- word link)
+ word idlw-help-link)
(mouse-set-point ev)
(setq word (idlwave-this-word))
(if (string= word "")
(error "No help item selected"))
- (setq link (get-text-property 0 'link word))
+ (setq idlw-help-link (get-text-property 0 'link word))
(select-window cw)
(cond
;; Routine name
((memq what '(procedure function routine))
- (setq name word)
+ (setq idlw-help-name word)
(if (or (eq class t)
(and (stringp class) sclasses))
(let* ((classes (idlwave-all-method-classes
- (idlwave-sintern-method name)
+ (idlwave-sintern-method idlw-help-name)
type)))
- (setq link t) ; No specific link valid yet
+ (setq idlw-help-link t) ; No specific link valid yet
(if sclasses
(setq classes (idlwave-members-only
classes (cons class sclasses))))
;; XXX is this necessary, given all-method-classes?
(if (stringp class)
(setq class (idlwave-find-inherited-class
- (idlwave-sintern-routine-or-method name class)
+ (idlwave-sintern-routine-or-method idlw-help-name class)
type (idlwave-sintern-class class)))))
;; Keyword
((eq what 'keyword)
- (setq kwd word)
+ (setq idlw-help-kwd word)
(if (or (eq class t)
(and (stringp class) sclasses))
(let ((classes (idlwave-all-method-keyword-classes
- (idlwave-sintern-method name)
- (idlwave-sintern-keyword kwd)
+ (idlwave-sintern-method idlw-help-name)
+ (idlwave-sintern-keyword idlw-help-kwd)
type)))
- (setq link t) ; Link can't be correct yet
+ (setq idlw-help-link t) ; Link can't be correct yet
(if sclasses
(setq classes (idlwave-members-only
classes (cons class sclasses))))
;; XXX is this necessary, given all-method-keyword-classes?
(if (stringp class)
(setq class (idlwave-find-inherited-class
- (idlwave-sintern-routine-or-method name class)
+ (idlwave-sintern-routine-or-method
+ idlw-help-name class)
type (idlwave-sintern-class class)))))
- (if (string= (downcase name) "obj_new")
+ (if (string= (downcase idlw-help-name) "obj_new")
(setq class idlwave-current-obj_new-class
- name "Init"))))
+ idlw-help-name "Init"))))
;; Class name
((eq what 'class)
(funcall what 'set word))
(t (error "Cannot help with this item")))
- (if (and need-class (not class) (not (and link (not (eq link t)))))
+ (if (and need-class (not class)
+ (not (and idlw-help-link (not (eq idlw-help-link t)))))
(error "Cannot help with this item"))
- (idlwave-online-help link (or name word) type class kwd)))
+ (idlwave-online-help idlw-help-link (or idlw-help-name word)
+ type class idlw-help-kwd)))
(defvar idlwave-highlight-help-links-in-completion)
(defvar idlwave-completion-help-links)
"Display HTML or other special help on a certain topic.
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
-`t', first look up the optional arguments in the routine info list to
+t, first look up the optional arguments in the routine info list to
see if a link is set for it. Try extra help functions if necessary."
;; Lookup link
(if (eq link t)
(let ((entry (idlwave-best-rinfo-assoc name type class
(idlwave-routines) nil t)))
- (cond
- ;; Try keyword link
- ((and keyword
- (setq link (cdr (idlwave-entry-find-keyword entry keyword)))))
- ;; Default, regular entry link
- (t (setq link (idlwave-entry-has-help entry))))))
+ (if entry
+ (cond
+ ;; Try keyword link
+ ((and keyword
+ (setq link (cdr
+ (idlwave-entry-find-keyword entry keyword)))))
+ ;; Default, regular entry link
+ (t (setq link (idlwave-entry-has-help entry))))
+ (if (and
+ class
+ ;; Check for system class help
+ (setq entry (assq (idlwave-sintern-class class)
+ idlwave-system-class-info)
+ link (nth 1 (assq 'link entry))))
+ (message
+ (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))
- (help-pos (save-excursion
- (set-buffer (idlwave-help-get-help-buffer))
+ (help-pos (with-current-buffer (idlwave-help-get-help-buffer)
(let ((buffer-read-only nil))
(funcall idlwave-extra-help-function
name type class keyword)))))
(select-window cw)))
(defun idlwave-help-html-link (link)
- "Get html help on a given LINK."
+ "Get HTML help on a given LINK."
(let ((browse-url-browser-function idlwave-help-browser-function)
(help-loc (idlwave-html-help-location))
(browse-url-generic-program idlwave-help-browser-generic-program)
;(browse-url-generic-args idlwave-help-browser-generic-args)
full-link)
- (unless idlwave-help-browse-url-available
- (error "browse-url is not available -- install it to use HTML help."))
+ ;; Just a regular file name (+ anchor name)
+ (unless (and (stringp help-loc)
+ (file-directory-p help-loc))
+ (error "Invalid help location"))
+ (setq full-link (browse-url-file-url (expand-file-name link help-loc)))
- (if (and (memq system-type '(ms-dos windows-nt))
- idlwave-help-use-hh)
- (progn
- (setq browse-url-browser-function 'browse-url-generic
- full-link (concat (expand-file-name "idl.chm" help-loc)
- "::/"
- link))
- (if (memq 'keyhh idlwave-help-use-hh)
- (setq browse-url-generic-program "KEYHH"
- browse-url-generic-args '("-IDLWAVE"))
- (setq browse-url-generic-program "HH")))
- ;; Just a regular file name (+ anchor name)
- (unless (and (stringp help-loc)
- (file-directory-p help-loc))
- (error
- "Invalid help location; customize `idlwave-html-help-location'."))
- (setq full-link (concat
- "file://"
- (expand-file-name
- link
- (expand-file-name "idl_html_help" help-loc)))))
-
- ;; Check for a local browser
- (if (or idlwave-help-browser-is-local
- (string-match "w3" (symbol-name idlwave-help-browser-function)))
- (idlwave-help-display-help-window '(lambda () (browse-url full-link)))
- (browse-url full-link))))
+ ;; Select the browser
+ (cond
+ (idlwave-help-use-assistant
+ (idlwave-help-assistant-open-link link))
+
+ ((or idlwave-help-browser-is-local
+ (string-match "w3" (symbol-name idlwave-help-browser-function)))
+ (idlwave-help-display-help-window '(lambda () (browse-url full-link))))
+
+ (t (browse-url full-link)))))
;; A special help routine for source-level syntax help in files.
(defvar idlwave-help-fontify-source-code)
(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)
(progn
(setq file (buffer-file-name in-buf))
(erase-buffer)
- (insert-buffer-substring in-buf)
- (goto-char (point-min)))
+ (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))
(defun idlwave-help-find-routine-definition (name type class keyword)
"Find the definition of routine CLASS::NAME in current buffer.
-KEYWORD is ignored. Returns the point of match if successful, nil otherwise."
+Returns the point of match if successful, nil otherwise.
+KEYWORD is ignored."
(save-excursion
(goto-char (point-max))
(if (re-search-backward
"(help location unknown)")))
(defun idlwave-help-show-help-frame ()
- "Show the help frame, creating it if necessary"
+ "Show the help frame, creating it if necessary."
;; Use a special frame for this
(unless (frame-live-p idlwave-help-frame)
(setq idlwave-help-frame
(if buf
nil
(setq buf (get-buffer-create "*IDLWAVE Help*"))
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(idlwave-help-mode)))
buf))
(let ((entry (idlwave-best-rinfo-assoc name type class (idlwave-routines))))
(idlwave-entry-has-help entry)))
+;;----- Control the IDL Assistant, which shipped with IDL v6.2
+(defvar idlwave-help-assistant-process nil)
+(defvar idlwave-help-assistant-socket nil)
+
+;; 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.
+(defvar idlwave-help-assistant-command
+ (if (memq system-type '(ms-dos windows-nt))
+ "bin/bin.x86/idl_assistant.exe"
+ "bin/idl_assistant")
+ "The command, rooted at `idlwave-system-directory', which invokes the
+IDL assistant.")
+
+(defun idlwave-help-assistant-available ()
+ (if idlwave-help-assistant-available
+ (eq idlwave-help-assistant-available t)
+ (setq idlwave-help-assistant-available
+ (if (file-executable-p (idlwave-help-assistant-command))
+ t
+ 'not-available))))
+
+(defun idlwave-help-assistant-command ()
+ (expand-file-name idlwave-help-assistant-command (idlwave-sys-dir)))
+
+(defun idlwave-help-assistant-start (&optional full-link)
+ "Start the IDL Assistant, loading link FULL-LINK, if passed."
+ (when (or (not idlwave-help-assistant-socket)
+ (not (eq (process-status idlwave-help-assistant-socket) 'open)))
+ (let* ((help-loc (idlwave-html-help-location))
+ (command (idlwave-help-assistant-command))
+ (extra-args
+ (nconc
+ (if (memq system-type '(ms-dos windows-nt))
+ `("-profile" ,(expand-file-name "idl.adp" help-loc)))
+ (if full-link `("-file" ,full-link))))
+ port)
+ (if idlwave-help-assistant-socket
+ (delete-process idlwave-help-assistant-socket))
+
+ (setq idlwave-help-assistant-process
+ (apply 'start-process
+ "IDL_ASSISTANT_PROC" nil command "-server" extra-args))
+
+ (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)
+ (error "Unable to open IDL_ASSISTANT")
+ (set-process-filter idlwave-help-assistant-process nil)
+ (setq idlwave-help-assistant-socket
+ (open-network-stream "IDL_ASSISTANT_SOCK"
+ nil "localhost" port))
+ (if (eq (process-status idlwave-help-assistant-socket) 'open)
+ (progn
+ (process-send-string idlwave-help-assistant-socket
+ (concat "setHelpPath " help-loc "\n"))
+ t)
+ (idlwave-help-assistant-close)
+ (error "Cannot communicate with IDL_ASSISTANT"))))))
+
+(defun idlwave-help-assistant-raise ()
+ (idlwave-help-assistant-start)
+ (process-send-string idlwave-help-assistant-socket "raise\n"))
+
+(defun idlwave-help-assistant-open-link (&optional 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)))
+ (error "Malformed help link"))
+
+ (setq file (expand-file-name (concat topic ".html") help-loc))
+ (if (file-exists-p file)
+ (setq exists t)
+ (setq file (expand-file-name
+ (concat (upcase topic) ".html") help-loc))
+ (setq exists (file-exists-p file)))
+
+ (setq full-link (concat file anchor)
+ just-started (idlwave-help-assistant-start (if exists full-link)))
+ (if exists
+ (progn
+ (if (not just-started)
+ (process-send-string idlwave-help-assistant-socket
+ (concat "openLink " full-link "\n")))
+ (process-send-string idlwave-help-assistant-socket
+ (concat "searchIndexNoOpen " topic "\n")))
+ (process-send-string idlwave-help-assistant-socket
+ (concat "searchIndexAndOpen " topic "\n"))))
+ (idlwave-help-assistant-raise))
+
+(defvar idlwave-help-assistant-help-with-topic-history nil
+ "The history of help topics selected with the minibuffer.")
+
+(defvar idlwave-system-routines)
+
+(defun idlwave-help-assistant-help-with-topic (&optional topic)
+ "Prompt for and provide help with TOPIC."
+ (interactive)
+ (let (list)
+ (unless topic
+ (idlwave-routines)
+ (setq list (append (mapcar (lambda (x)
+ (concat (nth 2 x) (car x)))
+ idlwave-system-routines)
+ (mapcar (lambda (x)
+ (concat "." (car x)))
+ idlwave-executive-commands-alist)
+ idlwave-system-class-info))
+ (setq topic
+ (idlwave-completing-read
+ "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))
+ (when idlwave-help-assistant-socket
+ (process-send-string idlwave-help-assistant-socket "quit\n")
+ (delete-process idlwave-help-assistant-socket))
+ (stop-process idlwave-help-assistant-process)
+ (delete-process idlwave-help-assistant-process)
+ (setq idlwave-help-assistant-socket nil
+ idlwave-help-assistant-process nil)))
+
+
(provide 'idlw-help)
(provide 'idlwave-help)
-;; arch-tag: d27b5505-59de-497f-ba3f-f199fd4fb911
;;; idlw-help.el ends here