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