(Frename_file): Undo last change: no need to ifdef away
[bpt/emacs.git] / lisp / progmodes / idlw-help.el
CommitLineData
a3b8a372
S
1;;; idlw-help.el --- HTML Help code for IDLWAVE
2;; Copyright (c) 2000 Carsten Dominik
3;; Copyright (c) 2001, 2002 J.D. Smith
ea81d57e 4;; Copyright (c) 2003,2004,2005 Free Software Foundation
a3b8a372
S
5;;
6;; Authors: J.D. Smith <jdsmith@as.arizona.edu>
7;; Carsten Dominik <dominik@astro.uva.nl>
8;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu>
9;; Version: 5.5
10
11;; This file is part of GNU Emacs.
12
13;; This file is free software; you can redistribute it and/or modify
14;; it under the terms of the GNU General Public License as published by
15;; the Free Software Foundation; either version 2, or (at your option)
16;; any later version.
17
18;; This file is distributed in the hope that it will be useful,
19;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;; GNU General Public License for more details.
22
23;; You should have received a copy of the GNU General Public License
24;; along with GNU Emacs; see the file COPYING. If not, write to the
25;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26;; Boston, MA 02111-1307, USA.
27
28;;; Commentary:
29
30;; The help link information for IDLWAVE's online help feature for
31;; system routines is extracted automatically from the IDL
32;; documentation, and is available, along with general routine
33;; information, in the file idlw-rinfo.el. The HTML help file
34;; themselves are not distributable with Emacs, but are available,
35;; along with new versions of IDLWAVE, documentation, and more
36;; information, at:
37;;
38;; http://idlwave.org
cf4fa77a 39;;
a3b8a372
S
40;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
41\f
42
43;;; Code:
44(require 'browse-url)
45
46(defgroup idlwave-online-help nil
47 "Online Help options for IDLWAVE mode."
48 :group 'idlwave)
49
50(defcustom idlwave-html-help-pre-v6 nil
51 "Whether pre or post-v6.0 IDL help documents are being used."
52 :group 'idlwave-online-help
53 :type 'boolean)
54
cf4fa77a 55(defvar idlwave-html-link-sep
a3b8a372
S
56 (if idlwave-html-help-pre-v6 "#" "#wp"))
57
cf4fa77a 58(defcustom idlwave-html-help-location
a3b8a372
S
59 (if (memq system-type '(ms-dos windows-nt))
60 nil
61 "/usr/local/etc/")
62 "The directory where the idl_html_help/ dir or idl.chm help file
63(Windows only) lives."
64 :group 'idlwave-online-help
65 :type 'directory)
66
67(defcustom idlwave-help-use-hh nil
68 "Whether to use the HTMLHelp viewer with idl.chm (Windows only)."
69 :group 'idlwave-online-help
70 :type '(choice :tag "use help viewer"
71 (const :tag "<none>" nil)
72 (const :tag "hh" 'hh)
73 (const :tag "keyhh" 'keyhh)))
74
75(defcustom idlwave-help-browser-function browse-url-browser-function
76 "Function to use to display html help.
77Defaults to `browse-url-browser-function', which see."
78 :group 'idlwave-online-help
79 :type 'function)
80
81(defcustom idlwave-help-browser-generic-program browse-url-generic-program
82 "Program to run if using browse-url-generic-program."
83 :group 'idlwave-online-help
84 :type 'string)
85
cf4fa77a 86(defcustom idlwave-help-browser-generic-args
a3b8a372
S
87 (if (boundp 'browse-url-generic-args)
88 browse-url-generic-args "")
89 "Program args to use if using browse-url-generic-program."
90 :group 'idlwave-online-help
91 :type 'string)
92
93(defcustom idlwave-help-browser-is-local nil
94 "Whether the browser will display locally in an Emacs window.
95Several browsers run and/or display inside Emacs windows, but most are
96external programs. If the browser name contains \"-w3\", it is
97assumed to be local to Emacs. For other local browsers, this variable
98must be explicitly set non-nil in order for the variable
99`idlwave-help-use-dedicated-frame' to function."
100 :group 'idlwave-online-help
101 :type 'boolean)
102
103(defvar idlwave-help-directory ""
104 "Obsolete variable. See idlwave-html-help-location.")
105
106(defcustom idlwave-help-use-dedicated-frame t
107 "*Non-nil means, use a separate frame for Online Help if possible."
108 :group 'idlwave-online-help
109 :type 'boolean)
110
111(defcustom idlwave-help-frame-parameters
112 '((height . 32) (unsplittable . t))
113 "The frame parameters for the special Online Help frame.
114See also `idlwave-help-use-dedicated-frame'.
115If you do not set the frame width here, the value specified in
116`idlw-help.el' will be used."
117 :group 'idlwave-online-help
118 :type '(repeat
119 (cons symbol sexp)))
120
121(defcustom idlwave-max-popup-menu-items 20
122 "Maximum number of items per pane in popup menus.
123Currently only used for class selection during completion help."
124 :group 'idlwave-online-help
125 :type 'integer)
126
127(defcustom idlwave-extra-help-function 'idlwave-help-with-source
128 "The function to call for online help if the normal help fails.
129Online help works only for system routines which are described in the
130IDL manuals. A function may be specified to access help from other sources.
131
132The function must accept four arguments: NAME, TYPE, CLASS, KEYWORD.
133The Help buffer is current when this function is called, and the help
134text should be loaded into this buffer. If help is found, the
135function should return the buffer position which should be used as
136`window-start' in the help window. Also, the variable
137`idlwave-help-mode-line-indicator' should be set to a useful string,
138which will be displayed in the mode line of the help window. If
139should also set the variable `idlwave-help-min-frame-width' to a
140positive integer. IDLWAVE will ensure that the help frame is at least
141that many columns wide. Failure to find help should be indicated by
142throwing an error.
143
144When this variable is non-nil, IDLWAVE will allow the mouse-3 help click
145for every routine and keyword, even though the item may not be highlighted
146in blue (indicating the availability of system documentation).
147
148The default value for this function is `idlwave-help-with-source' which
149loads the routine source file into the help buffer. If you try to write
150a different function which accesses a special help file or so, it is
151probably a good idea to still call this function as a fallback."
152 :group 'idlwave-online-help
153 :type 'symbol)
154
155(defcustom idlwave-help-fontify-source-code nil
156 "*Non-nil means, fontify source code displayed as help like normal code."
157 :group 'idlwave-online-help
158 :type 'boolean)
159
160(defcustom idlwave-help-source-try-header t
161 "*Non-nil means, try to find help in routine header when displaying source.
162Routines which are not documented in the system manual use their source as
163help text. When this variable is non-nil, we try to find a description of
164the help item in the first routine doclib header above the routine definition.
165If the variable is nil, or if we cannot find/parse the header, the routine
166definition is displayed instead."
167 :group 'idlwave-online-help
168 :type 'boolean)
169
170
171(defcustom idlwave-help-doclib-name "name"
172 "*A regexp for the heading word to search for in doclib headers
173which specifies the `name' section. Can be used for localization
174support."
175 :group 'idlwave-online-help
176 :type 'string)
177
178(defcustom idlwave-help-doclib-keyword "KEYWORD"
179 "*A regexp for the heading word to search for in doclib headers
180which specifies the `keywords' section. Can be used for localization
181support."
182 :group 'idlwave-online-help
183 :type 'string)
184
57267a95 185(defface idlwave-help-link
ea81d57e
DN
186 '((((min-colors 88) (class color)) (:foreground "Blue1"))
187 (((class color)) (:foreground "Blue"))
a3b8a372
S
188 (t (:weight bold)))
189 "Face for highlighting links into IDLWAVE online help."
190 :group 'idlwave-online-help)
57267a95
MB
191;; backward-compatibility alias
192(put 'idlwave-help-link-face 'face-alias 'idlwave-help-link)
a3b8a372
S
193
194(defvar idlwave-help-activate-links-aggressively nil
195 "Obsolete variable.")
cf4fa77a 196
a3b8a372
S
197(defvar idlwave-completion-help-info)
198
199(defvar idlwave-help-frame nil
200 "The frame for display of IDL online help.")
201(defvar idlwave-help-frame-width 102
202 "The default width of the help frame.")
203
204(defvar idlwave-html-help-is-available nil
205 "Is the system online help text avaiable?")
206
207(defvar idlwave-help-mode-line-indicator ""
208 "Used for the special mode line in the idlwave-help-mode.")
209
210(defvar idlwave-help-window-configuration nil)
211(defvar idlwave-help-special-topic-words nil) ; defined by get_rinfo
212
213;; Define the key bindings for the Help application
214
215(defvar idlwave-help-mode-map (make-sparse-keymap)
216 "The keymap used in idlwave-help-mode.")
217
218(define-key idlwave-help-mode-map "q" 'idlwave-help-quit)
219(define-key idlwave-help-mode-map "w" 'widen)
220(define-key idlwave-help-mode-map "\C-m" (lambda (arg)
221 (interactive "p")
222 (scroll-up arg)))
223(define-key idlwave-help-mode-map " " 'scroll-up)
224(define-key idlwave-help-mode-map [delete] 'scroll-down)
225(define-key idlwave-help-mode-map "h" 'idlwave-help-find-header)
226(define-key idlwave-help-mode-map "H" 'idlwave-help-find-first-header)
227(define-key idlwave-help-mode-map "." 'idlwave-help-toggle-header-match-and-def)
228(define-key idlwave-help-mode-map "F" 'idlwave-help-fontify)
229(define-key idlwave-help-mode-map "\M-?" 'idlwave-help-return-to-calling-frame)
230(define-key idlwave-help-mode-map "x" 'idlwave-help-return-to-calling-frame)
231
232;; Define the menu for the Help application
233
234(easy-menu-define
235 idlwave-help-menu idlwave-help-mode-map
236 "Menu for Help IDLWAVE system"
237 '("IDLHelp"
238 ["Definition <-> Help Text" idlwave-help-toggle-header-match-and-def t]
239 ["Find DocLib Header" idlwave-help-find-header t]
240 ["Find First DocLib Header" idlwave-help-find-first-header t]
241 ["Fontify help buffer" idlwave-help-fontify t]
242 "--"
243 ["Quit" idlwave-help-quit t]))
244
245(defun idlwave-help-mode ()
246 "Major mode for displaying IDL Help.
247
248This is a VIEW mode for the ASCII version of IDL Help files,
249with some extras. Its main purpose is speed - so don't
250expect a fully hyper-linked help.
251
252Scrolling: SPC DEL RET
253Text Searches: Inside Topic: Use Emacs search functions
254Exit: [q]uit or mouse button 3 will kill the frame
255
256When the hep text is a source file, the following commands are available
257
258Fontification: [F]ontify the buffer like source code
259Jump: [h] to function doclib header
260 [H] to file doclib header
261 [.] back and forward between header and definition
262
263Here are all keybindings.
264\\{idlwave-help-mode-map}"
265 (kill-all-local-variables)
266 (buffer-disable-undo)
267 (setq major-mode 'idlwave-help-mode
268 mode-name "IDLWAVE Help")
269 (use-local-map idlwave-help-mode-map)
270 (easy-menu-add idlwave-help-menu idlwave-help-mode-map)
271 (setq truncate-lines t)
272 (setq case-fold-search t)
273 (setq mode-line-format
274 (list ""
275 'mode-line-modified
276 'mode-line-buffer-identification
277 ": " 'idlwave-help-mode-line-indicator
278 " -%-"))
279 (setq buffer-read-only t)
280 (set (make-local-variable 'idlwave-help-def-pos) nil)
281 (set (make-local-variable 'idlwave-help-args) nil)
282 (set (make-local-variable 'idlwave-help-in-header) nil)
9a969196 283 (run-mode-hooks 'idlwave-help-mode-hook))
a3b8a372
S
284
285(defun idlwave-html-help-location ()
286 "Return the help directory where HTML files are, or nil if that is unknown."
287 (or (and (stringp idlwave-html-help-location)
288 (> (length idlwave-html-help-location) 0)
289 (file-directory-p idlwave-html-help-location)
290 idlwave-html-help-location)
291 (getenv "IDLWAVE_HELP_LOCATION")
292 (and (memq system-type '(ms-dos windows-nt)) ; Base it on sysdir
293 idlwave-help-use-hh
294 (stringp idlwave-system-directory)
295 (> (length idlwave-system-directory) 0)
296 (file-directory-p idlwave-system-directory)
297 (expand-file-name "HELP" idlwave-system-directory))))
298
299(defvar idlwave-current-obj_new-class)
300(defvar idlwave-help-diagnostics)
301(defvar idlwave-experimental)
302(defvar idlwave-last-context-help-pos)
303(defun idlwave-do-context-help (&optional arg)
304 "Wrapper around the call to idlwave-context-help1.
305It collects and prints the diagnostics messages."
306 (let ((marker (list (current-buffer) (point)))
307 (idlwave-help-diagnostics nil))
308 ;; Check for frame switching. When the command is invoked twice
309 ;; at the same position, we try to switch to the help frame
310 ;; FIXME: Frame switching works only on XEmacs
311 (if (and idlwave-experimental
312 (equal last-command this-command)
313 (equal idlwave-last-context-help-pos marker))
314 (idlwave-help-select-help-frame)
315 ;; Do the real thing.
316 (setq idlwave-last-context-help-pos marker)
317 (idlwave-do-context-help1 arg)
318 (if idlwave-help-diagnostics
cf4fa77a 319 (message "%s" (mapconcat 'identity
a3b8a372
S
320 (nreverse idlwave-help-diagnostics)
321 "; "))))))
322
323(defvar idlwave-help-do-class-struct-tag nil)
324(defvar idlwave-help-do-struct-tag nil)
325(defun idlwave-do-context-help1 (&optional arg)
326 "The work-horse version of `idlwave-context-help', which see."
327 (save-excursion
cf4fa77a 328 (if (equal (char-after) ?/)
a3b8a372
S
329 (forward-char 1)
330 (if (equal (char-before) ?=)
331 (backward-char 1)))
332 (let* ((idlwave-query-class nil)
333 (idlwave-force-class-query (equal arg '(4)))
334 (chars "a-zA-Z0-9_$.!")
335 (beg (save-excursion (skip-chars-backward chars) (point)))
336 (end (save-excursion (skip-chars-forward chars) (point)))
337 (this-word (buffer-substring-no-properties beg end))
cf4fa77a 338 (st-ass (assoc (downcase this-word)
a3b8a372
S
339 idlwave-help-special-topic-words))
340 (classtag (and (string-match "self\\." this-word)
341 (< beg (- end 4))))
342 (structtag (and (fboundp 'idlwave-complete-structure-tag)
343 (string-match "\\`\\([^.]+\\)\\." this-word)
344 (< beg (- end 4))))
345 module keyword cw mod1 mod2 mod3)
cf4fa77a 346 (if (or arg
a3b8a372
S
347 (and (not st-ass)
348 (not classtag)
349 (not structtag)
350 (not (member (string-to-char this-word) '(?! ?.)))))
351 ;; Need the module information
352 (progn
353 ;; MODULE is (name type class), for this or any inheriting class
354 (setq module (idlwave-what-module-find-class)
355 cw (nth 2 (idlwave-where))) ;what would we complete here?
356 ;; Correct for OBJ_NEW, we may need an INIT method instead.
357 (if (equal (idlwave-downcase-safe (car module)) "obj_new")
358 (let* ((bos (save-excursion (idlwave-beginning-of-statement)
359 (point)))
360 (str (buffer-substring bos (point))))
361 (if (string-match "OBJ_NEW([ \t]*['\"]\\([a-zA-Z][a-zA-Z0-9$_]+\\)['\"]" str)
362 (setq module (list "init" 'fun (match-string 1 str))
363 idlwave-current-obj_new-class (match-string 1 str))
364 )))))
cf4fa77a 365 (cond
a3b8a372 366 (arg (setq mod1 module))
cf4fa77a 367
a3b8a372
S
368 ;; A special topic -- only system help
369 (st-ass (setq mod1 (list (cdr st-ass))))
cf4fa77a 370
a3b8a372 371 ;; A system variable -- only system help
cf4fa77a
JB
372 ((string-match
373 "\\`!\\([a-zA-Z0-9_]+\\)\\(\.\\([A-Za-z0-9_]+\\)\\)?"
a3b8a372
S
374 this-word)
375 (let* ((word (match-string-no-properties 1 this-word))
376 (entry (assq (idlwave-sintern-sysvar word)
377 idlwave-system-variables-alist))
378 (tag (match-string-no-properties 3 this-word))
379 (tag-target (if tag
380 (cdr
381 (assq (idlwave-sintern-sysvartag tag)
382 (cdr (assq 'tags entry))))))
383 (link (nth 1 (assq 'link entry))))
384 (if tag-target
cf4fa77a 385 (setq link (idlwave-substitute-link-target link
a3b8a372
S
386 tag-target)))
387 (setq mod1 (list link))))
cf4fa77a 388
a3b8a372
S
389 ;; An executive command -- only system help
390 ((string-match "^\\.\\([A-Z_]+\\)" this-word)
391 (let* ((word (match-string 1 this-word))
cf4fa77a 392 (link (cdr (assoc-string
a3b8a372 393 word
cf4fa77a
JB
394 idlwave-executive-commands-alist
395 t))))
a3b8a372 396 (setq mod1 (list link))))
cf4fa77a 397
a3b8a372
S
398 ;; A class -- system OR in-text help (via class__define).
399 ((and (eq cw 'class)
400 (or (idlwave-in-quote) ; e.g. obj_new
401 (re-search-backward "\\<inherits[ \t]+[A-Za-z0-9_]*\\="
402 (max (point-min) (- (point) 40)) t)))
403 ;; Class completion inside string delimiters must be
404 ;; the class inside OBJ_NEW.
405 (let* ((entry (assq
406 (idlwave-sintern-class this-word)
407 idlwave-system-class-info))
408 (name (concat (downcase this-word) "__define"))
409 (link (nth 1 (assq 'link entry))))
410 (setq mod1 (list link name 'pro))))
cf4fa77a 411
a3b8a372
S
412 ;; A class structure tag (self.BLAH) -- only in-text help available
413 (classtag
414 (let ((tag (substring this-word (match-end 0)))
415 class-with found-in)
cf4fa77a 416 (when (setq class-with
a3b8a372
S
417 (idlwave-class-or-superclass-with-tag
418 (nth 2 (idlwave-current-routine))
419 tag))
420 (setq found-in (idlwave-class-found-in class-with))
cf4fa77a 421 (if (assq (idlwave-sintern-class class-with)
a3b8a372
S
422 idlwave-system-class-info)
423 (error "No help available for system class tags"))
424 (setq idlwave-help-do-class-struct-tag t)
cf4fa77a 425 (setq mod1 (list nil
a3b8a372
S
426 (if found-in
427 (cons (concat found-in "__define") class-with)
428 (concat class-with "__define"))
429 'pro
430 nil ; no class.... it's a procedure!
431 tag)))))
cf4fa77a 432
a3b8a372
S
433 ;; A regular structure tag -- only in text, and if
434 ;; optional `complete-structtag' loaded.
435 (structtag
436 (let ((var (match-string 1 this-word))
437 (tag (substring this-word (match-end 0))))
438 ;; Check if we need to update the "current" structure
439 (idlwave-prepare-structure-tag-completion var)
440 (setq idlwave-help-do-struct-tag
441 idlwave-structtag-struct-location
442 mod1 (list nil nil nil nil tag))))
cf4fa77a 443
a3b8a372
S
444 ;; A routine keyword -- in text or system help
445 ((and (memq cw '(function-keyword procedure-keyword))
446 (stringp this-word)
447 (string-match "\\S-" this-word)
448 (not (string-match "!" this-word)))
449 (cond ((or (= (char-before beg) ?/)
450 (save-excursion (goto-char end)
451 (looking-at "[ \t]*=")))
452 ;; Certainly a keyword. Check for abbreviation etc.
453 (setq keyword (idlwave-expand-keyword this-word module))
454 (cond
455 ((null keyword)
456 (idlwave-help-diagnostics
457 (format "%s does not accept `%s' kwd"
458 (idlwave-make-full-name (nth 2 module)
459 (car module))
460 (upcase this-word))
461 'ding))
462 ((consp keyword)
463 (idlwave-help-diagnostics
464 (format "%d matches for kwd abbrev `%s'"
465 (length keyword) this-word)
466 'ding)
467 ;; We continue anyway with the first match...
468 (setq keyword (car keyword))))
469 ;; Keyword, or just module
470 (setq mod1 (append (list t) module (list keyword)))
471 (setq mod2 (append (list t) module)))
472 ((equal (char-after end) ?\()
473 ;; A function - what-module will have caught this
474 (setq mod1 (append (list t) module)))
475 (t
476 ;; undecided - try function, keyword, then enclosing mod.
477 ;; Check for keyword abbreviations, but do not report
478 ;; errors, because it might be something else.
479 ;; FIXME: is this a good way to handle this?
480 (setq keyword (idlwave-expand-keyword this-word module))
481 (if (consp keyword) (setq keyword (car keyword)))
482 (setq mod1 (append (list t) module (list keyword))
483 mod2 (list t this-word 'fun nil)
484 mod3 (append (list t) module)))))
cf4fa77a 485
a3b8a372
S
486 ;; Everything else
487 (t
488 (setq mod1 (append (list t) module))))
489 (if mod3
490 (condition-case nil
491 (apply 'idlwave-online-help mod1)
492 (error (condition-case nil
493 (apply 'idlwave-online-help mod2)
494 (error (apply 'idlwave-online-help mod3)))))
495 (if mod2
496 (condition-case nil
497 (apply 'idlwave-online-help mod1)
498 (error (apply 'idlwave-online-help mod2)))
499 (if mod1
500 (apply 'idlwave-online-help mod1)
501 (error "Don't know which item to show help for")))))))
502
503(defun idlwave-do-mouse-completion-help (ev)
504 "Display online help on an item in the *Completions* buffer.
505Needs additional info stored in global `idlwave-completion-help-info'."
506 (let* ((cw (selected-window))
507 (info idlwave-completion-help-info) ; global passed in
508 (what (nth 0 info))
509 (name (nth 1 info))
510 (type (nth 2 info))
511 (class (nth 3 info))
512 (need-class class)
513 (kwd (nth 4 info))
514 (sclasses (nth 5 info))
515 word link)
516 (mouse-set-point ev)
517
cf4fa77a 518
a3b8a372
S
519 ;; See if we can also find help somewhere, e.g. for multiple classes
520 (setq word (idlwave-this-word))
521 (if (string= word "")
522 (error "No help item selected"))
523 (setq link (get-text-property 0 'link word))
524 (select-window cw)
cf4fa77a 525 (cond
a3b8a372
S
526 ;; Routine name
527 ((memq what '(procedure function routine))
528 (setq name word)
529 (if (or (eq class t)
530 (and (stringp class) sclasses))
531 (let* ((classes (idlwave-all-method-classes
532 (idlwave-sintern-method name)
533 type)))
534 (setq link t) ; No specific link valid yet
535 (if sclasses
cf4fa77a 536 (setq classes (idlwave-members-only
a3b8a372 537 classes (cons class sclasses))))
cf4fa77a 538 (setq class (idlwave-popup-select ev classes
a3b8a372
S
539 "Select Class" 'sort))))
540
541 ;; XXX is this necessary, given all-method-classes?
542 (if (stringp class)
543 (setq class (idlwave-find-inherited-class
544 (idlwave-sintern-routine-or-method name class)
545 type (idlwave-sintern-class class)))))
546
547 ;; Keyword
548 ((eq what 'keyword)
549 (setq kwd word)
550 (if (or (eq class t)
551 (and (stringp class) sclasses))
552 (let ((classes (idlwave-all-method-keyword-classes
553 (idlwave-sintern-method name)
554 (idlwave-sintern-keyword kwd)
555 type)))
556 (setq link t) ; Link can't be correct yet
557 (if sclasses
cf4fa77a 558 (setq classes (idlwave-members-only
a3b8a372
S
559 classes (cons class sclasses))))
560 (setq class (idlwave-popup-select ev classes
561 "Select Class" 'sort))
562 ;; XXX is this necessary, given all-method-keyword-classes?
563 (if (stringp class)
564 (setq class (idlwave-find-inherited-class
565 (idlwave-sintern-routine-or-method name class)
566 type (idlwave-sintern-class class)))))
567 (if (string= (downcase name) "obj_new")
568 (setq class idlwave-current-obj_new-class
569 name "Init"))))
cf4fa77a 570
a3b8a372
S
571 ;; Class name
572 ((eq what 'class)
573 (setq class word
574 word nil))
cf4fa77a 575
a3b8a372 576 ;; A special named function to call which sets some of our variables
cf4fa77a 577 ((and (symbolp what)
a3b8a372
S
578 (fboundp what))
579 (funcall what 'set word))
580
581 (t (error "Cannot help with this item")))
582 (if (and need-class (not class) (not (and link (not (eq link t)))))
583 (error "Cannot help with this item"))
584 (idlwave-online-help link (or name word) type class kwd)))
585
586(defvar idlwave-highlight-help-links-in-completion)
587(defvar idlwave-completion-help-links)
588(defun idlwave-highlight-linked-completions ()
589 "Highlight all completions for which help is available and attach link.
590Those words in `idlwave-completion-help-links' have links. The
57267a95 591`idlwave-help-link' face is used for this."
cf4fa77a 592 (if idlwave-highlight-help-links-in-completion
a3b8a372
S
593 (with-current-buffer (get-buffer "*Completions*")
594 (save-excursion
595 (let* ((case-fold-search t)
57267a95 596 (props (list 'face 'idlwave-help-link))
a3b8a372
S
597 (info idlwave-completion-help-info) ; global passed in
598 (what (nth 0 info)) ; what was completed, or a func
599 (class (nth 3 info)) ; any class
600 word beg end doit)
601 (goto-char (point-min))
602 (re-search-forward "possible completions are:" nil t)
603 (while (re-search-forward "\\s-\\([A-Za-z0-9_.]+\\)\\(\\s-\\|\\'\\)"
604 nil t)
605 (setq beg (match-beginning 1) end (match-end 1)
606 word (match-string 1) doit nil)
607 ;; Call special completion function test
cf4fa77a 608 (if (and (symbolp what)
a3b8a372
S
609 (fboundp what))
610 (setq doit (funcall what 'test word))
611 ;; Look for special link property passed in help-links
612 (if idlwave-completion-help-links
cf4fa77a
JB
613 (setq doit (assoc-string
614 word idlwave-completion-help-links t))))
a3b8a372
S
615 (when doit
616 (if (consp doit)
617 (setq props (append props `(link ,(cdr doit)))))
618 (let ((buffer-read-only nil))
619 (add-text-properties beg end props)))
620 (goto-char end)))))))
621
622;; Arrange for this function to be called after completion
623(add-hook 'idlwave-completion-setup-hook
624 'idlwave-highlight-linked-completions)
625
626(defvar idlwave-help-return-frame nil
627 "The frame to return to from the help frame.")
628
629(defun idlwave-help-quit ()
630 "Exit IDLWAVE Help buffer. Kill the dedicated frame if any."
631 (interactive)
632 (cond ((and idlwave-help-use-dedicated-frame
633 (eq (selected-frame) idlwave-help-frame))
634 (if (and idlwave-experimental
635 (frame-live-p idlwave-help-return-frame))
636 ;; Try to select the return frame.
637 ;; This can crash on slow network connections, obviously when
638 ;; we kill the help frame before the return-frame is selected.
cf4fa77a 639 ;; To protect the workings, we wait for up to one second
a3b8a372
S
640 ;; and check if the return-frame *is* now selected.
641 ;; This is marked "eperimental" since we are not sure when its OK.
642 (let ((maxtime 1.0) (time 0.) (step 0.1))
643 (select-frame idlwave-help-return-frame)
644 (while (and (sit-for step)
cf4fa77a 645 (not (eq (selected-frame)
a3b8a372
S
646 idlwave-help-return-frame))
647 (< (setq time (+ time step)) maxtime)))))
648 (delete-frame idlwave-help-frame))
649 ((window-configuration-p idlwave-help-window-configuration)
650 (set-window-configuration idlwave-help-window-configuration)
651 (select-window (previous-window)))
652 (t (kill-buffer (idlwave-help-get-help-buffer)))))
653
654
655(defvar default-toolbar-visible-p)
656
657(defun idlwave-help-display-help-window (&optional pos-or-func)
cf4fa77a 658 "Display the help window.
a3b8a372
S
659Move window start to POS-OR-FUNC, if passed as a position, or call it
660if passed as a function. See `idlwave-help-use-dedicated-frame'."
661 (let ((cw (selected-window))
662 (buf (idlwave-help-get-help-buffer)))
663 (if (and window-system idlwave-help-use-dedicated-frame)
664 (progn
665 (idlwave-help-show-help-frame)
666 (switch-to-buffer buf))
667 ;; Do it in this frame and save the window configuration
668 (if (not (get-buffer-window buf nil))
cf4fa77a 669 (setq idlwave-help-window-configuration
a3b8a372
S
670 (current-window-configuration)))
671 (display-buffer buf nil (selected-frame))
672 (select-window (get-buffer-window buf)))
673 (raise-frame)
cf4fa77a
JB
674 (if pos-or-func
675 (if (functionp pos-or-func)
a3b8a372
S
676 (funcall pos-or-func)
677 (goto-char pos-or-func)
678 (recenter 0)))
679 (select-window cw)))
680
681(defun idlwave-help-select-help-frame ()
682 "Select the help frame."
683 (if (and (frame-live-p idlwave-help-frame)
684 (not (eq (selected-frame) idlwave-help-frame)))
685 (progn
686 (setq idlwave-help-return-frame (selected-frame))
687 (select-frame idlwave-help-frame))))
688
689(defun idlwave-help-return-to-calling-frame ()
690 "Select the frame from which the help frame was selected."
691 (interactive)
692 (if (and (frame-live-p idlwave-help-return-frame)
693 (not (eq (selected-frame) idlwave-help-return-frame)))
694 (select-frame idlwave-help-return-frame)))
695
696(defun idlwave-online-help (link &optional name type class keyword)
cf4fa77a 697 "Display HTML or other special help on a certain topic.
a3b8a372
S
698Either loads an HTML link, if LINK is non-nil, or gets special-help on
699the optional arguments, if any special help is defined. If LINK is
700`t', first look up the optional arguments in the routine info list to
701see if a link is set for it. Try extra help functions if necessary."
702 ;; Lookup link
cf4fa77a
JB
703 (if (eq link t)
704 (let ((entry (idlwave-best-rinfo-assoc name type class
a3b8a372
S
705 (idlwave-routines) nil t)))
706 (cond
707 ;; Try keyword link
cf4fa77a 708 ((and keyword
a3b8a372
S
709 (setq link (cdr (idlwave-entry-find-keyword entry keyword)))))
710 ;; Default, regular entry link
711 (t (setq link (idlwave-entry-has-help entry))))))
712
713 (cond
714 ;; An explicit link
cf4fa77a 715 ((stringp link)
a3b8a372 716 (idlwave-help-html-link link))
cf4fa77a 717
a3b8a372
S
718 ;; Any extra help
719 (idlwave-extra-help-function
720 (idlwave-help-get-special-help name type class keyword))
cf4fa77a 721
a3b8a372
S
722 ;; Nothing worked
723 (t (idlwave-help-error name type class keyword))))
724
725
726(defun idlwave-help-get-special-help (name type class keyword)
727 "Call the function given by `idlwave-extra-help-function'."
728 (let* ((cw (selected-window))
729 (help-pos (save-excursion
730 (set-buffer (idlwave-help-get-help-buffer))
731 (let ((buffer-read-only nil))
cf4fa77a 732 (funcall idlwave-extra-help-function
a3b8a372
S
733 name type class keyword)))))
734 (if help-pos
735 (idlwave-help-display-help-window help-pos)
736 (idlwave-help-error name type class keyword))
737 (select-window cw)))
738
739(defun idlwave-help-html-link (link)
740 "Get html help on a given LINK."
741 (let ((browse-url-browser-function idlwave-help-browser-function)
742 (help-loc (idlwave-html-help-location))
743 (browse-url-generic-program idlwave-help-browser-generic-program)
744 ;(browse-url-generic-args idlwave-help-browser-generic-args)
745 full-link)
cf4fa77a 746
a3b8a372
S
747 (if (and (memq system-type '(ms-dos windows-nt))
748 idlwave-help-use-hh)
749 (progn
750 (setq browse-url-browser-function 'browse-url-generic
751 full-link (concat (expand-file-name "idl.chm" help-loc)
752 "::/"
753 link))
754 (if (memq 'keyhh idlwave-help-use-hh)
755 (setq browse-url-generic-program "KEYHH"
756 browse-url-generic-args '("-IDLWAVE"))
757 (setq browse-url-generic-program "HH")))
758 ;; Just a regular file name (+ anchor name)
759 (unless (and (stringp help-loc)
760 (file-directory-p help-loc))
cf4fa77a 761 (error
a3b8a372 762 "Invalid help location; customize `idlwave-html-help-location'."))
cf4fa77a 763 (setq full-link (concat
a3b8a372 764 "file://"
cf4fa77a
JB
765 (expand-file-name
766 link
a3b8a372
S
767 (expand-file-name "idl_html_help" help-loc)))))
768
769 ;; Check for a local browser
770 (if (or idlwave-help-browser-is-local
771 (string-match "w3" (symbol-name idlwave-help-browser-function)))
772 (idlwave-help-display-help-window '(lambda () (browse-url full-link)))
773 (browse-url full-link))))
774
775;; A special help routine for source-level syntax help in files.
776(defvar idlwave-help-def-pos)
777(defvar idlwave-help-args)
778(defvar idlwave-help-in-header)
779(defvar idlwave-help-fontify-source-code)
780(defvar idlwave-help-source-try-header)
781(defun idlwave-help-with-source (name type class keyword)
782 "Provide help for routines not documented in the IDL manuals. Works
783by loading the routine source file into the help buffer. Depending on
784the value of `idlwave-help-source-try-header', it attempts to show the
785routine definition or the header description. If
786`idlwave-help-do-class-struct-tag' is non-nil, keyword is a tag to
787show help on from the class definition structure. If
788`idlwave-help-do-struct-tag' is non-nil, show help from the matching
789structure tag definition.
790
791This function can be used as `idlwave-extra-help-function'."
792 (let* ((class-struct-tag idlwave-help-do-class-struct-tag)
793 (struct-tag idlwave-help-do-struct-tag)
794 (case-fold-search t)
795 (real-class (if (consp name) (cdr name)))
796 (name (if (consp name) (car name) name))
797 (class-only (and (stringp class) (not (stringp name))))
798 file header-pos def-pos in-buf)
799 (if class-only ;Help with class? Using "Init" as source.
800 (setq name "Init"
801 type 'fun))
cf4fa77a 802 (if (not struct-tag)
a3b8a372
S
803 (setq file
804 (idlwave-routine-source-file
805 (nth 3 (idlwave-best-rinfo-assoc
806 name (or type t) class (idlwave-routines))))))
807 (setq idlwave-help-def-pos nil
808 idlwave-help-args (list name type class keyword)
809 idlwave-help-in-header nil
810 idlwave-help-do-struct-tag nil
811 idlwave-help-do-class-struct-tag nil)
812 (if (or struct-tag (stringp file))
813 (progn
814 (setq in-buf ; structure-tag completion is always in current buffer
cf4fa77a 815 (if struct-tag
a3b8a372
S
816 idlwave-current-tags-buffer
817 (idlwave-get-buffer-visiting file)))
818 ;; see if file is in a visited buffer, insert those contents
819 (if in-buf
820 (progn
821 (setq file (buffer-file-name in-buf))
822 (erase-buffer)
823 (insert-buffer in-buf))
824 (if (file-exists-p file) ;; otherwise just load the file
825 (progn
826 (erase-buffer)
827 (insert-file-contents file nil nil nil 'replace))
828 (idlwave-help-error name type class keyword)))
829 (if (and idlwave-help-fontify-source-code (not in-buf))
830 (idlwave-help-fontify)))
831 (idlwave-help-error name type class keyword))
832 (setq idlwave-help-mode-line-indicator file)
833
834 ;; Try to find a good place to display
835 (setq def-pos
836 ;; Find the class structure tag if that's what we're after
cf4fa77a 837 (cond
a3b8a372
S
838 ;; Class structure tags: find the class or named structure
839 ;; definition
840 (class-struct-tag
cf4fa77a 841 (save-excursion
a3b8a372 842 (setq class
cf4fa77a 843 (if (string-match "[a-zA-Z0-9]\\(__\\)" name)
a3b8a372
S
844 (substring name 0 (match-beginning 1))
845 idlwave-current-tags-class))
846 (and
847 (idlwave-find-class-definition class nil real-class)
848 (idlwave-find-struct-tag keyword))))
cf4fa77a 849
a3b8a372
S
850 ;; Generic structure tags: the structure definition
851 ;; location within the file has been recorded in
852 ;; `struct-tag'
853 (struct-tag
854 (save-excursion
855 (and
856 (integerp struct-tag)
857 (goto-char struct-tag)
858 (idlwave-find-struct-tag keyword))))
cf4fa77a 859
a3b8a372
S
860 ;; Just find the routine definition
861 (t
862 (if class-only (point-min)
863 (idlwave-help-find-routine-definition name type class keyword))))
864 idlwave-help-def-pos def-pos)
865
cf4fa77a 866 (if (and idlwave-help-source-try-header
a3b8a372
S
867 (not (or struct-tag class-struct-tag)))
868 ;; Check if we can find the header
869 (save-excursion
870 (goto-char (or def-pos (point-max)))
871 (setq header-pos (idlwave-help-find-in-doc-header
872 name type class keyword 'exact)
873 idlwave-help-in-header header-pos)))
874
875 (if (or header-pos def-pos)
cf4fa77a 876 (progn
a3b8a372
S
877 (if (boundp 'idlwave-help-min-frame-width)
878 (setq idlwave-help-min-frame-width 80))
879 (goto-char (or header-pos def-pos)))
880 (idlwave-help-error name type class keyword))
881
882 (point)))
883
884
885(defun idlwave-help-find-routine-definition (name type class keyword)
886 "Find the definition of routine CLASS::NAME in current buffer.
887KEYWORD is ignored. Returns the point of match if successful, nil otherwise."
888 (save-excursion
889 (goto-char (point-max))
cf4fa77a 890 (if (re-search-backward
a3b8a372
S
891 (concat "^[ \t]*"
892 (if (eq type 'pro) "pro"
893 (if (eq type 'fun) "function"
894 "\\(pro\\|function\\)"))
895 "[ \t]+"
896 (regexp-quote (downcase (idlwave-make-full-name class name)))
897 "[, \t\r\n]")
898 nil t)
899 (match-beginning 0)
900 nil)))
901
902(defvar idlwave-doclib-start)
903(defvar idlwave-doclib-end)
904(defun idlwave-help-find-in-doc-header (name type class keyword
905 &optional exact)
906 "Find the requested help in the doc-header above point.
907
908First checks if there is a doc-lib header which describes the correct
909routine. Then tries to find the KEYWORDS section and the KEYWORD, if
910given. Returns the point which should be window start of the help
911window. If EXACT is non-nil, the full help position must be found -
912down to the keyword requested. This setting is for context help, if
913the exact spot is needed.
914
915If EXACT is nil, the position of the header is returned if it
916describes the correct routine - even if the keyword description cannot
917be found. TYPE is ignored.
918
919This function expects a more or less standard routine header. In
920particlar it looks for the `NAME:' tag, either with a colon, or alone
921on a line. Then `NAME:' must be followed by the routine name on the
922same or the next line. When KEYWORD is non-nil, looks first for a
923`KEYWORDS' section. It is amazing how inconsisten this is through
924some IDL libraries I have seen. We settle for a line containing an
925upper case \"KEYWORD\" string. If this line is not fould we search
926for the keyword anyway to increase the hit-rate
927
928When one of these sections exists we check for a line starting with any of
929
930 /KEYWORD KEYWORD- KEYWORD= KEYWORD
931
932with spaces allowed between the keyword and the following dash or equal sign.
933If there is a match, we assume it is the keyword description."
934 (let* ((case-fold-search t)
935 (rname (if (stringp class)
cf4fa77a 936 (concat
a3b8a372
S
937 "\\("
938 ;; Traditional name or class::name
939 "\\("
940 "\\(" (regexp-quote (downcase class)) "::\\)?"
941 (regexp-quote (downcase name))
942 "\\>\\)"
cf4fa77a 943 (concat
a3b8a372
S
944 "\\|"
945 ;; class__define or just class
946 (regexp-quote (downcase class)) "\\(__define\\)?")
947 "\\)")
948 (regexp-quote (downcase name))))
cf4fa77a 949
a3b8a372 950 ;; NAME tag plus the routine name. The new version is from JD.
cf4fa77a 951 (name-re (concat
a3b8a372
S
952 "\\(^;+\\*?[ \t]*"
953 idlwave-help-doclib-name
954 "\\([ \t]*:\\|[ \t]*$\\)[ \t]*\\(\n;+[ \t]*\\)*"
955 rname
956 "\\|"
957 "^;+[ \t]*"
958 rname
959 ":[ \t]*$\\)"))
960
961 ;; Header start plus name
962 (header-re (concat "\\(" idlwave-doclib-start "\\).*\n"
963 "\\(^;+.*\n\\)*"
964 "\\(" name-re "\\)"))
965 ;; A keywords section
966 (kwds-re (concat ; forgiving
967 "^;+\\*?[ \t]*"
968 "\\([-A-Z_ ]*"
969 idlwave-help-doclib-keyword
970 "[-A-Z_ ]*\\)"
971 "\\(:\\|[ \t]*\n\\)"))
972
973 ;; The individual keyword description line.
974 (kwd-re (if keyword ; hard (well...)
975 (concat
976 "^;+[ \t]+"
977 "\\(/" (regexp-quote (upcase keyword))
978 "\\|" (regexp-quote (upcase keyword)) "[ \t]*[-=:\n]"
979 "\\)")))
980 (kwd-re2 (if keyword ; forgiving
981 (concat
982 "^;+[ \t]+"
983 (regexp-quote (upcase keyword))
984 "\\>")))
985 dstart dend name-pos kwds-pos kwd-pos)
cf4fa77a 986 (catch 'exit
a3b8a372
S
987 (save-excursion
988 (goto-char (point-min))
989 (while (and (setq dstart (re-search-forward idlwave-doclib-start nil t))
990 (setq dend (re-search-forward idlwave-doclib-end nil t)))
991 ;; found a routine header
992 (goto-char dstart)
993 (if (setq name-pos (re-search-forward name-re dend t))
cf4fa77a 994 (progn
a3b8a372
S
995 (if keyword
996 ;; We do need a keyword
997 (progn
998 ;; Try to find a keyword section, but don't force it.
999 (goto-char name-pos)
1000 (if (let ((case-fold-search nil))
1001 (re-search-forward kwds-re dend t))
1002 (setq kwds-pos (match-beginning 0)))
1003 ;; Find the keyword description
1004 (if (or (let ((case-fold-search nil))
1005 (re-search-forward kwd-re dend t))
1006 (re-search-forward kwd-re dend t)
1007 (let ((case-fold-search nil))
1008 (re-search-forward kwd-re2 dend t))
1009 (re-search-forward kwd-re2 dend t))
1010 (setq kwd-pos (match-beginning 0))
1011 (if exact
1012 (progn
1013 (idlwave-help-diagnostics
1014 (format "Could not find description of kwd %s"
1015 (upcase keyword)))
1016 (throw 'exit nil))))))
1017 ;; Return the best position we got
1018 (throw 'exit (or kwd-pos kwds-pos name-pos dstart)))
1019 (goto-char dend))))
1020 (idlwave-help-diagnostics "Could not find doclib header")
1021 (throw 'exit nil))))
1022
1023(defun idlwave-help-diagnostics (string &optional ding)
1024 "Add a diagnostics string to the list.
1025When DING is non-nil, ring the bell as well."
1026 (if (boundp 'idlwave-help-diagnostics)
1027 (progn
1028 (setq idlwave-help-diagnostics
1029 (cons string idlwave-help-diagnostics))
1030 (if ding (ding)))))
1031
1032(defun idlwave-help-toggle-header-top-and-def (arg)
1033 (interactive "P")
1034 (let (pos)
1035 (if idlwave-help-in-header
1036 ;; Header was the last thing displayed
1037 (progn
1038 (setq idlwave-help-in-header nil)
1039 (setq pos idlwave-help-def-pos))
1040 ;; Try to display header
1041 (setq pos (idlwave-help-find-in-doc-header
1042 (nth 0 idlwave-help-args)
1043 (nth 1 idlwave-help-args)
1044 (nth 2 idlwave-help-args)
1045 nil))
1046 (if pos
1047 (setq idlwave-help-in-header t)
1048 (error "Cannot find doclib header for routine %s"
1049 (idlwave-make-full-name (nth 2 idlwave-help-args)
1050 (nth 0 idlwave-help-args)))))
1051 (if pos
1052 (progn
1053 (goto-char pos)
1054 (recenter 0)))))
1055
1056(defun idlwave-help-find-first-header (arg)
1057 (interactive "P")
1058 (let (pos)
1059 (save-excursion
1060 (goto-char (point-min))
1061 (if (re-search-forward idlwave-doclib-start nil t)
1062 (setq pos (match-beginning 0))))
1063 (if pos
1064 (progn
1065 (goto-char pos)
1066 (recenter 0))
1067 (error "No DocLib Header in current file"))))
1068
1069(defun idlwave-help-find-header (arg)
1070 "Jump to the DocLib Header."
1071 (interactive "P")
1072 (if arg
1073 (idlwave-help-find-first-header nil)
1074 (setq idlwave-help-in-header nil)
1075 (idlwave-help-toggle-header-match-and-def arg 'top)))
cf4fa77a 1076
a3b8a372
S
1077(defun idlwave-help-toggle-header-match-and-def (arg &optional top)
1078 (interactive "P")
1079 (let ((args idlwave-help-args)
1080 pos)
1081 (if idlwave-help-in-header
1082 ;; Header was the last thing displayed
1083 (progn
1084 (setq idlwave-help-in-header nil)
1085 (setq pos idlwave-help-def-pos))
1086 ;; Try to display header
1087 (setq pos (apply 'idlwave-help-find-in-doc-header
cf4fa77a 1088 (if top
a3b8a372
S
1089 (list (car args) (nth 1 args) (nth 2 args) nil)
1090 args)))
1091 (if pos
1092 (setq idlwave-help-in-header t)
1093 (error "Cannot find doclib header for routine %s"
1094 (idlwave-make-full-name (nth 2 idlwave-help-args)
1095 (nth 0 idlwave-help-args)))))
1096 (if pos
1097 (progn
1098 (goto-char pos)
1099 (recenter 0)))))
1100
1101(defvar font-lock-verbose)
1102(defvar idlwave-mode-syntax-table)
1103(defvar idlwave-font-lock-defaults)
1104(defun idlwave-help-fontify ()
1105 "Fontify the Help buffer as source code.
1106Useful when source code is displayed as help. See the option
1107`idlwave-help-fontify-source-code'."
1108 (interactive)
1109 (if (featurep 'font-lock)
1110 (let ((major-mode 'idlwave-mode)
1111 (font-lock-verbose
1112 (if (interactive-p) font-lock-verbose nil))
1113 (syntax-table (syntax-table)))
1114 (unwind-protect
1115 (progn
1116 (set-syntax-table idlwave-mode-syntax-table)
1117 (set (make-local-variable 'font-lock-defaults)
1118 idlwave-font-lock-defaults)
1119 (font-lock-fontify-buffer))
1120 (set-syntax-table syntax-table)))))
1121
cf4fa77a 1122
a3b8a372
S
1123(defun idlwave-help-error (name type class keyword)
1124 (error "Can't find help on %s%s %s"
1125 (or (and (or class name) (idlwave-make-full-name class name))
1126 "<unknown>")
1127 (if keyword (format ", keyword %s" (upcase keyword)) "")
1128 (if idlwave-html-help-location
1129 ""
1130 "(help location unknown)")))
1131
1132(defun idlwave-help-show-help-frame ()
1133 "Show the help frame, creating it if necessary"
1134 ;; Use a special frame for this
1135 (unless (frame-live-p idlwave-help-frame)
1136 (setq idlwave-help-frame
1137 (make-frame idlwave-help-frame-parameters))
1138 ;; Strip menubar (?) and toolbar from the Help frame.
1139 (if (fboundp 'set-specifier)
1140 (progn
1141 ;; XEmacs
1142 (let ((sval (cons idlwave-help-frame nil)))
1143 ;; (set-specifier menubar-visible-p sval)
1144 (set-specifier default-toolbar-visible-p sval)))
1145 ;; Emacs
1146 (modify-frame-parameters idlwave-help-frame
1147 '(;;(menu-bar-lines . 0)
1148 (tool-bar-lines . 0)))))
1149 (select-frame idlwave-help-frame))
1150
1151(defun idlwave-help-get-help-buffer ()
1152 "Return the IDLWAVE Help buffer. Make it first if necessary."
1153 (let ((buf (get-buffer "*IDLWAVE Help*")))
1154 (if buf
1155 nil
1156 (setq buf (get-buffer-create "*IDLWAVE Help*"))
1157 (save-excursion
1158 (set-buffer buf)
1159 (idlwave-help-mode)))
1160 buf))
1161
1162(defun idlwave-grep (regexp list)
1163 (let (rtn)
1164 (while list
1165 (if (string-match regexp (car list))
1166 (setq rtn (cons (car list) rtn)))
1167 (setq list (cdr list)))
1168 (nreverse rtn)))
1169
1170(defun idlwave-entry-has-help (entry)
1171 (and entry (car (nth 5 entry))))
1172
1173(defun idlwave-has-help (name type class)
1174 "Does this have help associated with it?"
1175 (let ((entry (idlwave-best-rinfo-assoc name type class (idlwave-routines))))
1176 (idlwave-entry-has-help entry)))
1177
1178(provide 'idlw-help)
1179(provide 'idlwave-help)
1180
8df608c1
MB
1181;; arch-tag: d27b5505-59de-497f-ba3f-f199fd4fb911
1182;;; idlw-help.el ends here