diff options
| author | Juanma Barranquero | 2005-08-30 11:08:18 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2005-08-30 11:08:18 +0000 |
| commit | a6d5fd231428e7a29215a481e93efffcff6332bc (patch) | |
| tree | 72c6c980c54eb0201cdb03aee7bdb604047f9a59 | |
| parent | fca8b94cf0138be6a92b24b039c10e3680227d5d (diff) | |
| download | emacs-a6d5fd231428e7a29215a481e93efffcff6332bc.tar.gz emacs-a6d5fd231428e7a29215a481e93efffcff6332bc.zip | |
(browse-url-generic-args): Add defvar.
(idlwave-help-with-source): Use `insert-buffer-substring', not `insert-buffer'.
| -rw-r--r-- | lisp/progmodes/idlw-help.el | 149 |
1 files changed, 76 insertions, 73 deletions
diff --git a/lisp/progmodes/idlw-help.el b/lisp/progmodes/idlw-help.el index 8c43831ebac..0a848128032 100644 --- a/lisp/progmodes/idlw-help.el +++ b/lisp/progmodes/idlw-help.el | |||
| @@ -36,11 +36,13 @@ | |||
| 36 | ;; information, at: | 36 | ;; information, at: |
| 37 | ;; | 37 | ;; |
| 38 | ;; http://idlwave.org | 38 | ;; http://idlwave.org |
| 39 | ;; | 39 | ;; |
| 40 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 40 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 41 | 41 | ||
| 42 | 42 | ||
| 43 | ;;; Code: | 43 | ;;; Code: |
| 44 | (defvar browse-url-generic-args) | ||
| 45 | |||
| 44 | (defvar idlwave-help-browse-url-available nil | 46 | (defvar idlwave-help-browse-url-available nil |
| 45 | "Whether browse-url is available") | 47 | "Whether browse-url is available") |
| 46 | 48 | ||
| @@ -58,10 +60,10 @@ | |||
| 58 | :group 'idlwave-online-help | 60 | :group 'idlwave-online-help |
| 59 | :type 'boolean) | 61 | :type 'boolean) |
| 60 | 62 | ||
| 61 | (defvar idlwave-html-link-sep | 63 | (defvar idlwave-html-link-sep |
| 62 | (if idlwave-html-help-pre-v6 "#" "#wp")) | 64 | (if idlwave-html-help-pre-v6 "#" "#wp")) |
| 63 | 65 | ||
| 64 | (defcustom idlwave-html-help-location | 66 | (defcustom idlwave-html-help-location |
| 65 | (if (memq system-type '(ms-dos windows-nt)) | 67 | (if (memq system-type '(ms-dos windows-nt)) |
| 66 | nil | 68 | nil |
| 67 | "/usr/local/etc/") | 69 | "/usr/local/etc/") |
| @@ -89,7 +91,7 @@ Defaults to `browse-url-browser-function', which see." | |||
| 89 | :group 'idlwave-online-help | 91 | :group 'idlwave-online-help |
| 90 | :type 'string) | 92 | :type 'string) |
| 91 | 93 | ||
| 92 | (defcustom idlwave-help-browser-generic-args | 94 | (defcustom idlwave-help-browser-generic-args |
| 93 | (if (boundp 'browse-url-generic-args) | 95 | (if (boundp 'browse-url-generic-args) |
| 94 | browse-url-generic-args "") | 96 | browse-url-generic-args "") |
| 95 | "Program args to use if using browse-url-generic-program." | 97 | "Program args to use if using browse-url-generic-program." |
| @@ -196,7 +198,7 @@ support." | |||
| 196 | 198 | ||
| 197 | (defvar idlwave-help-activate-links-aggressively nil | 199 | (defvar idlwave-help-activate-links-aggressively nil |
| 198 | "Obsolete variable.") | 200 | "Obsolete variable.") |
| 199 | 201 | ||
| 200 | (defvar idlwave-completion-help-info) | 202 | (defvar idlwave-completion-help-info) |
| 201 | 203 | ||
| 202 | (defvar idlwave-help-frame nil | 204 | (defvar idlwave-help-frame nil |
| @@ -324,7 +326,7 @@ It collects and prints the diagnostics messages." | |||
| 324 | (setq idlwave-last-context-help-pos marker) | 326 | (setq idlwave-last-context-help-pos marker) |
| 325 | (idlwave-do-context-help1 arg) | 327 | (idlwave-do-context-help1 arg) |
| 326 | (if idlwave-help-diagnostics | 328 | (if idlwave-help-diagnostics |
| 327 | (message "%s" (mapconcat 'identity | 329 | (message "%s" (mapconcat 'identity |
| 328 | (nreverse idlwave-help-diagnostics) | 330 | (nreverse idlwave-help-diagnostics) |
| 329 | "; ")))))) | 331 | "; ")))))) |
| 330 | 332 | ||
| @@ -337,7 +339,7 @@ It collects and prints the diagnostics messages." | |||
| 337 | (defun idlwave-do-context-help1 (&optional arg) | 339 | (defun idlwave-do-context-help1 (&optional arg) |
| 338 | "The work-horse version of `idlwave-context-help', which see." | 340 | "The work-horse version of `idlwave-context-help', which see." |
| 339 | (save-excursion | 341 | (save-excursion |
| 340 | (if (equal (char-after) ?/) | 342 | (if (equal (char-after) ?/) |
| 341 | (forward-char 1) | 343 | (forward-char 1) |
| 342 | (if (equal (char-before) ?=) | 344 | (if (equal (char-before) ?=) |
| 343 | (backward-char 1))) | 345 | (backward-char 1))) |
| @@ -347,7 +349,7 @@ It collects and prints the diagnostics messages." | |||
| 347 | (beg (save-excursion (skip-chars-backward chars) (point))) | 349 | (beg (save-excursion (skip-chars-backward chars) (point))) |
| 348 | (end (save-excursion (skip-chars-forward chars) (point))) | 350 | (end (save-excursion (skip-chars-forward chars) (point))) |
| 349 | (this-word (buffer-substring-no-properties beg end)) | 351 | (this-word (buffer-substring-no-properties beg end)) |
| 350 | (st-ass (assoc (downcase this-word) | 352 | (st-ass (assoc (downcase this-word) |
| 351 | idlwave-help-special-topic-words)) | 353 | idlwave-help-special-topic-words)) |
| 352 | (classtag (and (string-match "self\\." this-word) | 354 | (classtag (and (string-match "self\\." this-word) |
| 353 | (< beg (- end 4)))) | 355 | (< beg (- end 4)))) |
| @@ -355,7 +357,7 @@ It collects and prints the diagnostics messages." | |||
| 355 | (string-match "\\`\\([^.]+\\)\\." this-word) | 357 | (string-match "\\`\\([^.]+\\)\\." this-word) |
| 356 | (< beg (- end 4)))) | 358 | (< beg (- end 4)))) |
| 357 | module keyword cw mod1 mod2 mod3) | 359 | module keyword cw mod1 mod2 mod3) |
| 358 | (if (or arg | 360 | (if (or arg |
| 359 | (and (not st-ass) | 361 | (and (not st-ass) |
| 360 | (not classtag) | 362 | (not classtag) |
| 361 | (not structtag) | 363 | (not structtag) |
| @@ -374,15 +376,15 @@ It collects and prints the diagnostics messages." | |||
| 374 | (setq module (list "init" 'fun (match-string 1 str)) | 376 | (setq module (list "init" 'fun (match-string 1 str)) |
| 375 | idlwave-current-obj_new-class (match-string 1 str)) | 377 | idlwave-current-obj_new-class (match-string 1 str)) |
| 376 | ))))) | 378 | ))))) |
| 377 | (cond | 379 | (cond |
| 378 | (arg (setq mod1 module)) | 380 | (arg (setq mod1 module)) |
| 379 | 381 | ||
| 380 | ;; A special topic -- only system help | 382 | ;; A special topic -- only system help |
| 381 | (st-ass (setq mod1 (list (cdr st-ass)))) | 383 | (st-ass (setq mod1 (list (cdr st-ass)))) |
| 382 | 384 | ||
| 383 | ;; A system variable -- only system help | 385 | ;; A system variable -- only system help |
| 384 | ((string-match | 386 | ((string-match |
| 385 | "\\`!\\([a-zA-Z0-9_]+\\)\\(\.\\([A-Za-z0-9_]+\\)\\)?" | 387 | "\\`!\\([a-zA-Z0-9_]+\\)\\(\.\\([A-Za-z0-9_]+\\)\\)?" |
| 386 | this-word) | 388 | this-word) |
| 387 | (let* ((word (match-string-no-properties 1 this-word)) | 389 | (let* ((word (match-string-no-properties 1 this-word)) |
| 388 | (entry (assq (idlwave-sintern-sysvar word) | 390 | (entry (assq (idlwave-sintern-sysvar word) |
| @@ -394,10 +396,10 @@ It collects and prints the diagnostics messages." | |||
| 394 | (cdr (assq 'tags entry)))))) | 396 | (cdr (assq 'tags entry)))))) |
| 395 | (link (nth 1 (assq 'link entry)))) | 397 | (link (nth 1 (assq 'link entry)))) |
| 396 | (if tag-target | 398 | (if tag-target |
| 397 | (setq link (idlwave-substitute-link-target link | 399 | (setq link (idlwave-substitute-link-target link |
| 398 | tag-target))) | 400 | tag-target))) |
| 399 | (setq mod1 (list link)))) | 401 | (setq mod1 (list link)))) |
| 400 | 402 | ||
| 401 | ;; An executive command -- only system help | 403 | ;; An executive command -- only system help |
| 402 | ((string-match "^\\.\\([A-Z_]+\\)" this-word) | 404 | ((string-match "^\\.\\([A-Z_]+\\)" this-word) |
| 403 | (let* ((word (match-string 1 this-word)) | 405 | (let* ((word (match-string 1 this-word)) |
| @@ -405,7 +407,7 @@ It collects and prints the diagnostics messages." | |||
| 405 | word | 407 | word |
| 406 | idlwave-executive-commands-alist t)))) | 408 | idlwave-executive-commands-alist t)))) |
| 407 | (setq mod1 (list link)))) | 409 | (setq mod1 (list link)))) |
| 408 | 410 | ||
| 409 | ;; A class -- system OR in-text help (via class__define). | 411 | ;; A class -- system OR in-text help (via class__define). |
| 410 | ((and (eq cw 'class) | 412 | ((and (eq cw 'class) |
| 411 | (or (idlwave-in-quote) ; e.g. obj_new | 413 | (or (idlwave-in-quote) ; e.g. obj_new |
| @@ -419,28 +421,28 @@ It collects and prints the diagnostics messages." | |||
| 419 | (name (concat (downcase this-word) "__define")) | 421 | (name (concat (downcase this-word) "__define")) |
| 420 | (link (nth 1 (assq 'link entry)))) | 422 | (link (nth 1 (assq 'link entry)))) |
| 421 | (setq mod1 (list link name 'pro)))) | 423 | (setq mod1 (list link name 'pro)))) |
| 422 | 424 | ||
| 423 | ;; A class structure tag (self.BLAH) -- only in-text help available | 425 | ;; A class structure tag (self.BLAH) -- only in-text help available |
| 424 | (classtag | 426 | (classtag |
| 425 | (let ((tag (substring this-word (match-end 0))) | 427 | (let ((tag (substring this-word (match-end 0))) |
| 426 | class-with found-in) | 428 | class-with found-in) |
| 427 | (when (setq class-with | 429 | (when (setq class-with |
| 428 | (idlwave-class-or-superclass-with-tag | 430 | (idlwave-class-or-superclass-with-tag |
| 429 | (nth 2 (idlwave-current-routine)) | 431 | (nth 2 (idlwave-current-routine)) |
| 430 | tag)) | 432 | tag)) |
| 431 | (setq found-in (idlwave-class-found-in class-with)) | 433 | (setq found-in (idlwave-class-found-in class-with)) |
| 432 | (if (assq (idlwave-sintern-class class-with) | 434 | (if (assq (idlwave-sintern-class class-with) |
| 433 | idlwave-system-class-info) | 435 | idlwave-system-class-info) |
| 434 | (error "No help available for system class tags")) | 436 | (error "No help available for system class tags")) |
| 435 | (setq idlwave-help-do-class-struct-tag t) | 437 | (setq idlwave-help-do-class-struct-tag t) |
| 436 | (setq mod1 (list nil | 438 | (setq mod1 (list nil |
| 437 | (if found-in | 439 | (if found-in |
| 438 | (cons (concat found-in "__define") class-with) | 440 | (cons (concat found-in "__define") class-with) |
| 439 | (concat class-with "__define")) | 441 | (concat class-with "__define")) |
| 440 | 'pro | 442 | 'pro |
| 441 | nil ; no class.... it's a procedure! | 443 | nil ; no class.... it's a procedure! |
| 442 | tag))))) | 444 | tag))))) |
| 443 | 445 | ||
| 444 | ;; A regular structure tag -- only in text, and if | 446 | ;; A regular structure tag -- only in text, and if |
| 445 | ;; optional `complete-structtag' loaded. | 447 | ;; optional `complete-structtag' loaded. |
| 446 | (structtag | 448 | (structtag |
| @@ -451,7 +453,7 @@ It collects and prints the diagnostics messages." | |||
| 451 | (setq idlwave-help-do-struct-tag | 453 | (setq idlwave-help-do-struct-tag |
| 452 | idlwave-structtag-struct-location | 454 | idlwave-structtag-struct-location |
| 453 | mod1 (list nil nil nil nil tag)))) | 455 | mod1 (list nil nil nil nil tag)))) |
| 454 | 456 | ||
| 455 | ;; A routine keyword -- in text or system help | 457 | ;; A routine keyword -- in text or system help |
| 456 | ((and (memq cw '(function-keyword procedure-keyword)) | 458 | ((and (memq cw '(function-keyword procedure-keyword)) |
| 457 | (stringp this-word) | 459 | (stringp this-word) |
| @@ -493,7 +495,7 @@ It collects and prints the diagnostics messages." | |||
| 493 | (setq mod1 (append (list t) module (list keyword)) | 495 | (setq mod1 (append (list t) module (list keyword)) |
| 494 | mod2 (list t this-word 'fun nil) | 496 | mod2 (list t this-word 'fun nil) |
| 495 | mod3 (append (list t) module))))) | 497 | mod3 (append (list t) module))))) |
| 496 | 498 | ||
| 497 | ;; Everything else | 499 | ;; Everything else |
| 498 | (t | 500 | (t |
| 499 | (setq mod1 (append (list t) module)))) | 501 | (setq mod1 (append (list t) module)))) |
| @@ -526,14 +528,14 @@ Needs additional info stored in global `idlwave-completion-help-info'." | |||
| 526 | word link) | 528 | word link) |
| 527 | (mouse-set-point ev) | 529 | (mouse-set-point ev) |
| 528 | 530 | ||
| 529 | 531 | ||
| 530 | ;; See if we can also find help somewhere, e.g. for multiple classes | 532 | ;; See if we can also find help somewhere, e.g. for multiple classes |
| 531 | (setq word (idlwave-this-word)) | 533 | (setq word (idlwave-this-word)) |
| 532 | (if (string= word "") | 534 | (if (string= word "") |
| 533 | (error "No help item selected")) | 535 | (error "No help item selected")) |
| 534 | (setq link (get-text-property 0 'link word)) | 536 | (setq link (get-text-property 0 'link word)) |
| 535 | (select-window cw) | 537 | (select-window cw) |
| 536 | (cond | 538 | (cond |
| 537 | ;; Routine name | 539 | ;; Routine name |
| 538 | ((memq what '(procedure function routine)) | 540 | ((memq what '(procedure function routine)) |
| 539 | (setq name word) | 541 | (setq name word) |
| @@ -544,9 +546,9 @@ Needs additional info stored in global `idlwave-completion-help-info'." | |||
| 544 | type))) | 546 | type))) |
| 545 | (setq link t) ; No specific link valid yet | 547 | (setq link t) ; No specific link valid yet |
| 546 | (if sclasses | 548 | (if sclasses |
| 547 | (setq classes (idlwave-members-only | 549 | (setq classes (idlwave-members-only |
| 548 | classes (cons class sclasses)))) | 550 | classes (cons class sclasses)))) |
| 549 | (setq class (idlwave-popup-select ev classes | 551 | (setq class (idlwave-popup-select ev classes |
| 550 | "Select Class" 'sort)))) | 552 | "Select Class" 'sort)))) |
| 551 | 553 | ||
| 552 | ;; XXX is this necessary, given all-method-classes? | 554 | ;; XXX is this necessary, given all-method-classes? |
| @@ -566,7 +568,7 @@ Needs additional info stored in global `idlwave-completion-help-info'." | |||
| 566 | type))) | 568 | type))) |
| 567 | (setq link t) ; Link can't be correct yet | 569 | (setq link t) ; Link can't be correct yet |
| 568 | (if sclasses | 570 | (if sclasses |
| 569 | (setq classes (idlwave-members-only | 571 | (setq classes (idlwave-members-only |
| 570 | classes (cons class sclasses)))) | 572 | classes (cons class sclasses)))) |
| 571 | (setq class (idlwave-popup-select ev classes | 573 | (setq class (idlwave-popup-select ev classes |
| 572 | "Select Class" 'sort)) | 574 | "Select Class" 'sort)) |
| @@ -578,14 +580,14 @@ Needs additional info stored in global `idlwave-completion-help-info'." | |||
| 578 | (if (string= (downcase name) "obj_new") | 580 | (if (string= (downcase name) "obj_new") |
| 579 | (setq class idlwave-current-obj_new-class | 581 | (setq class idlwave-current-obj_new-class |
| 580 | name "Init")))) | 582 | name "Init")))) |
| 581 | 583 | ||
| 582 | ;; Class name | 584 | ;; Class name |
| 583 | ((eq what 'class) | 585 | ((eq what 'class) |
| 584 | (setq class word | 586 | (setq class word |
| 585 | word nil)) | 587 | word nil)) |
| 586 | 588 | ||
| 587 | ;; A special named function to call which sets some of our variables | 589 | ;; A special named function to call which sets some of our variables |
| 588 | ((and (symbolp what) | 590 | ((and (symbolp what) |
| 589 | (fboundp what)) | 591 | (fboundp what)) |
| 590 | (funcall what 'set word)) | 592 | (funcall what 'set word)) |
| 591 | 593 | ||
| @@ -600,7 +602,7 @@ Needs additional info stored in global `idlwave-completion-help-info'." | |||
| 600 | "Highlight all completions for which help is available and attach link. | 602 | "Highlight all completions for which help is available and attach link. |
| 601 | Those words in `idlwave-completion-help-links' have links. The | 603 | Those words in `idlwave-completion-help-links' have links. The |
| 602 | `idlwave-help-link' face is used for this." | 604 | `idlwave-help-link' face is used for this." |
| 603 | (if idlwave-highlight-help-links-in-completion | 605 | (if idlwave-highlight-help-links-in-completion |
| 604 | (with-current-buffer (get-buffer "*Completions*") | 606 | (with-current-buffer (get-buffer "*Completions*") |
| 605 | (save-excursion | 607 | (save-excursion |
| 606 | (let* ((case-fold-search t) | 608 | (let* ((case-fold-search t) |
| @@ -616,7 +618,7 @@ Those words in `idlwave-completion-help-links' have links. The | |||
| 616 | (setq beg (match-beginning 1) end (match-end 1) | 618 | (setq beg (match-beginning 1) end (match-end 1) |
| 617 | word (match-string 1) doit nil) | 619 | word (match-string 1) doit nil) |
| 618 | ;; Call special completion function test | 620 | ;; Call special completion function test |
| 619 | (if (and (symbolp what) | 621 | (if (and (symbolp what) |
| 620 | (fboundp what)) | 622 | (fboundp what)) |
| 621 | (setq doit (funcall what 'test word)) | 623 | (setq doit (funcall what 'test word)) |
| 622 | ;; Look for special link property passed in help-links | 624 | ;; Look for special link property passed in help-links |
| @@ -647,13 +649,13 @@ Those words in `idlwave-completion-help-links' have links. The | |||
| 647 | ;; Try to select the return frame. | 649 | ;; Try to select the return frame. |
| 648 | ;; This can crash on slow network connections, obviously when | 650 | ;; This can crash on slow network connections, obviously when |
| 649 | ;; we kill the help frame before the return-frame is selected. | 651 | ;; we kill the help frame before the return-frame is selected. |
| 650 | ;; To protect the workings, we wait for up to one second | 652 | ;; To protect the workings, we wait for up to one second |
| 651 | ;; and check if the return-frame *is* now selected. | 653 | ;; and check if the return-frame *is* now selected. |
| 652 | ;; This is marked "eperimental" since we are not sure when its OK. | 654 | ;; This is marked "eperimental" since we are not sure when its OK. |
| 653 | (let ((maxtime 1.0) (time 0.) (step 0.1)) | 655 | (let ((maxtime 1.0) (time 0.) (step 0.1)) |
| 654 | (select-frame idlwave-help-return-frame) | 656 | (select-frame idlwave-help-return-frame) |
| 655 | (while (and (sit-for step) | 657 | (while (and (sit-for step) |
| 656 | (not (eq (selected-frame) | 658 | (not (eq (selected-frame) |
| 657 | idlwave-help-return-frame)) | 659 | idlwave-help-return-frame)) |
| 658 | (< (setq time (+ time step)) maxtime))))) | 660 | (< (setq time (+ time step)) maxtime))))) |
| 659 | (delete-frame idlwave-help-frame)) | 661 | (delete-frame idlwave-help-frame)) |
| @@ -666,7 +668,7 @@ Those words in `idlwave-completion-help-links' have links. The | |||
| 666 | (defvar default-toolbar-visible-p) | 668 | (defvar default-toolbar-visible-p) |
| 667 | 669 | ||
| 668 | (defun idlwave-help-display-help-window (&optional pos-or-func) | 670 | (defun idlwave-help-display-help-window (&optional pos-or-func) |
| 669 | "Display the help window. | 671 | "Display the help window. |
| 670 | Move window start to POS-OR-FUNC, if passed as a position, or call it | 672 | Move window start to POS-OR-FUNC, if passed as a position, or call it |
| 671 | if passed as a function. See `idlwave-help-use-dedicated-frame'." | 673 | if passed as a function. See `idlwave-help-use-dedicated-frame'." |
| 672 | (let ((cw (selected-window)) | 674 | (let ((cw (selected-window)) |
| @@ -677,13 +679,13 @@ if passed as a function. See `idlwave-help-use-dedicated-frame'." | |||
| 677 | (switch-to-buffer buf)) | 679 | (switch-to-buffer buf)) |
| 678 | ;; Do it in this frame and save the window configuration | 680 | ;; Do it in this frame and save the window configuration |
| 679 | (if (not (get-buffer-window buf nil)) | 681 | (if (not (get-buffer-window buf nil)) |
| 680 | (setq idlwave-help-window-configuration | 682 | (setq idlwave-help-window-configuration |
| 681 | (current-window-configuration))) | 683 | (current-window-configuration))) |
| 682 | (display-buffer buf nil (selected-frame)) | 684 | (display-buffer buf nil (selected-frame)) |
| 683 | (select-window (get-buffer-window buf))) | 685 | (select-window (get-buffer-window buf))) |
| 684 | (raise-frame) | 686 | (raise-frame) |
| 685 | (if pos-or-func | 687 | (if pos-or-func |
| 686 | (if (functionp pos-or-func) | 688 | (if (functionp pos-or-func) |
| 687 | (funcall pos-or-func) | 689 | (funcall pos-or-func) |
| 688 | (goto-char pos-or-func) | 690 | (goto-char pos-or-func) |
| 689 | (recenter 0))) | 691 | (recenter 0))) |
| @@ -705,31 +707,31 @@ if passed as a function. See `idlwave-help-use-dedicated-frame'." | |||
| 705 | (select-frame idlwave-help-return-frame))) | 707 | (select-frame idlwave-help-return-frame))) |
| 706 | 708 | ||
| 707 | (defun idlwave-online-help (link &optional name type class keyword) | 709 | (defun idlwave-online-help (link &optional name type class keyword) |
| 708 | "Display HTML or other special help on a certain topic. | 710 | "Display HTML or other special help on a certain topic. |
| 709 | Either loads an HTML link, if LINK is non-nil, or gets special-help on | 711 | Either loads an HTML link, if LINK is non-nil, or gets special-help on |
| 710 | the optional arguments, if any special help is defined. If LINK is | 712 | the optional arguments, if any special help is defined. If LINK is |
| 711 | `t', first look up the optional arguments in the routine info list to | 713 | `t', first look up the optional arguments in the routine info list to |
| 712 | see if a link is set for it. Try extra help functions if necessary." | 714 | see if a link is set for it. Try extra help functions if necessary." |
| 713 | ;; Lookup link | 715 | ;; Lookup link |
| 714 | (if (eq link t) | 716 | (if (eq link t) |
| 715 | (let ((entry (idlwave-best-rinfo-assoc name type class | 717 | (let ((entry (idlwave-best-rinfo-assoc name type class |
| 716 | (idlwave-routines) nil t))) | 718 | (idlwave-routines) nil t))) |
| 717 | (cond | 719 | (cond |
| 718 | ;; Try keyword link | 720 | ;; Try keyword link |
| 719 | ((and keyword | 721 | ((and keyword |
| 720 | (setq link (cdr (idlwave-entry-find-keyword entry keyword))))) | 722 | (setq link (cdr (idlwave-entry-find-keyword entry keyword))))) |
| 721 | ;; Default, regular entry link | 723 | ;; Default, regular entry link |
| 722 | (t (setq link (idlwave-entry-has-help entry)))))) | 724 | (t (setq link (idlwave-entry-has-help entry)))))) |
| 723 | 725 | ||
| 724 | (cond | 726 | (cond |
| 725 | ;; An explicit link | 727 | ;; An explicit link |
| 726 | ((stringp link) | 728 | ((stringp link) |
| 727 | (idlwave-help-html-link link)) | 729 | (idlwave-help-html-link link)) |
| 728 | 730 | ||
| 729 | ;; Any extra help | 731 | ;; Any extra help |
| 730 | (idlwave-extra-help-function | 732 | (idlwave-extra-help-function |
| 731 | (idlwave-help-get-special-help name type class keyword)) | 733 | (idlwave-help-get-special-help name type class keyword)) |
| 732 | 734 | ||
| 733 | ;; Nothing worked | 735 | ;; Nothing worked |
| 734 | (t (idlwave-help-error name type class keyword)))) | 736 | (t (idlwave-help-error name type class keyword)))) |
| 735 | 737 | ||
| @@ -740,7 +742,7 @@ see if a link is set for it. Try extra help functions if necessary." | |||
| 740 | (help-pos (save-excursion | 742 | (help-pos (save-excursion |
| 741 | (set-buffer (idlwave-help-get-help-buffer)) | 743 | (set-buffer (idlwave-help-get-help-buffer)) |
| 742 | (let ((buffer-read-only nil)) | 744 | (let ((buffer-read-only nil)) |
| 743 | (funcall idlwave-extra-help-function | 745 | (funcall idlwave-extra-help-function |
| 744 | name type class keyword))))) | 746 | name type class keyword))))) |
| 745 | (if help-pos | 747 | (if help-pos |
| 746 | (idlwave-help-display-help-window help-pos) | 748 | (idlwave-help-display-help-window help-pos) |
| @@ -754,7 +756,7 @@ see if a link is set for it. Try extra help functions if necessary." | |||
| 754 | (browse-url-generic-program idlwave-help-browser-generic-program) | 756 | (browse-url-generic-program idlwave-help-browser-generic-program) |
| 755 | ;(browse-url-generic-args idlwave-help-browser-generic-args) | 757 | ;(browse-url-generic-args idlwave-help-browser-generic-args) |
| 756 | full-link) | 758 | full-link) |
| 757 | 759 | ||
| 758 | (unless idlwave-help-browse-url-available | 760 | (unless idlwave-help-browse-url-available |
| 759 | (error "browse-url is not available -- install it to use HTML help.")) | 761 | (error "browse-url is not available -- install it to use HTML help.")) |
| 760 | 762 | ||
| @@ -772,12 +774,12 @@ see if a link is set for it. Try extra help functions if necessary." | |||
| 772 | ;; Just a regular file name (+ anchor name) | 774 | ;; Just a regular file name (+ anchor name) |
| 773 | (unless (and (stringp help-loc) | 775 | (unless (and (stringp help-loc) |
| 774 | (file-directory-p help-loc)) | 776 | (file-directory-p help-loc)) |
| 775 | (error | 777 | (error |
| 776 | "Invalid help location; customize `idlwave-html-help-location'.")) | 778 | "Invalid help location; customize `idlwave-html-help-location'.")) |
| 777 | (setq full-link (concat | 779 | (setq full-link (concat |
| 778 | "file://" | 780 | "file://" |
| 779 | (expand-file-name | 781 | (expand-file-name |
| 780 | link | 782 | link |
| 781 | (expand-file-name "idl_html_help" help-loc))))) | 783 | (expand-file-name "idl_html_help" help-loc))))) |
| 782 | 784 | ||
| 783 | ;; Check for a local browser | 785 | ;; Check for a local browser |
| @@ -812,7 +814,7 @@ This function can be used as `idlwave-extra-help-function'." | |||
| 812 | (if class-only ;Help with class? Using "Init" as source. | 814 | (if class-only ;Help with class? Using "Init" as source. |
| 813 | (setq name "Init" | 815 | (setq name "Init" |
| 814 | type 'fun)) | 816 | type 'fun)) |
| 815 | (if (not struct-tag) | 817 | (if (not struct-tag) |
| 816 | (setq file | 818 | (setq file |
| 817 | (idlwave-routine-source-file | 819 | (idlwave-routine-source-file |
| 818 | (nth 3 (idlwave-best-rinfo-assoc | 820 | (nth 3 (idlwave-best-rinfo-assoc |
| @@ -825,7 +827,7 @@ This function can be used as `idlwave-extra-help-function'." | |||
| 825 | (if (or struct-tag (stringp file)) | 827 | (if (or struct-tag (stringp file)) |
| 826 | (progn | 828 | (progn |
| 827 | (setq in-buf ; structure-tag completion is always in current buffer | 829 | (setq in-buf ; structure-tag completion is always in current buffer |
| 828 | (if struct-tag | 830 | (if struct-tag |
| 829 | idlwave-current-tags-buffer | 831 | idlwave-current-tags-buffer |
| 830 | (idlwave-get-buffer-visiting file))) | 832 | (idlwave-get-buffer-visiting file))) |
| 831 | ;; see if file is in a visited buffer, insert those contents | 833 | ;; see if file is in a visited buffer, insert those contents |
| @@ -833,7 +835,8 @@ This function can be used as `idlwave-extra-help-function'." | |||
| 833 | (progn | 835 | (progn |
| 834 | (setq file (buffer-file-name in-buf)) | 836 | (setq file (buffer-file-name in-buf)) |
| 835 | (erase-buffer) | 837 | (erase-buffer) |
| 836 | (insert-buffer in-buf)) | 838 | (insert-buffer-substring in-buf) |
| 839 | (goto-char (point-min))) | ||
| 837 | (if (file-exists-p file) ;; otherwise just load the file | 840 | (if (file-exists-p file) ;; otherwise just load the file |
| 838 | (progn | 841 | (progn |
| 839 | (erase-buffer) | 842 | (erase-buffer) |
| @@ -847,19 +850,19 @@ This function can be used as `idlwave-extra-help-function'." | |||
| 847 | ;; Try to find a good place to display | 850 | ;; Try to find a good place to display |
| 848 | (setq def-pos | 851 | (setq def-pos |
| 849 | ;; Find the class structure tag if that's what we're after | 852 | ;; Find the class structure tag if that's what we're after |
| 850 | (cond | 853 | (cond |
| 851 | ;; Class structure tags: find the class or named structure | 854 | ;; Class structure tags: find the class or named structure |
| 852 | ;; definition | 855 | ;; definition |
| 853 | (class-struct-tag | 856 | (class-struct-tag |
| 854 | (save-excursion | 857 | (save-excursion |
| 855 | (setq class | 858 | (setq class |
| 856 | (if (string-match "[a-zA-Z0-9]\\(__\\)" name) | 859 | (if (string-match "[a-zA-Z0-9]\\(__\\)" name) |
| 857 | (substring name 0 (match-beginning 1)) | 860 | (substring name 0 (match-beginning 1)) |
| 858 | idlwave-current-tags-class)) | 861 | idlwave-current-tags-class)) |
| 859 | (and | 862 | (and |
| 860 | (idlwave-find-class-definition class nil real-class) | 863 | (idlwave-find-class-definition class nil real-class) |
| 861 | (idlwave-find-struct-tag keyword)))) | 864 | (idlwave-find-struct-tag keyword)))) |
| 862 | 865 | ||
| 863 | ;; Generic structure tags: the structure definition | 866 | ;; Generic structure tags: the structure definition |
| 864 | ;; location within the file has been recorded in | 867 | ;; location within the file has been recorded in |
| 865 | ;; `struct-tag' | 868 | ;; `struct-tag' |
| @@ -869,14 +872,14 @@ This function can be used as `idlwave-extra-help-function'." | |||
| 869 | (integerp struct-tag) | 872 | (integerp struct-tag) |
| 870 | (goto-char struct-tag) | 873 | (goto-char struct-tag) |
| 871 | (idlwave-find-struct-tag keyword)))) | 874 | (idlwave-find-struct-tag keyword)))) |
| 872 | 875 | ||
| 873 | ;; Just find the routine definition | 876 | ;; Just find the routine definition |
| 874 | (t | 877 | (t |
| 875 | (if class-only (point-min) | 878 | (if class-only (point-min) |
| 876 | (idlwave-help-find-routine-definition name type class keyword)))) | 879 | (idlwave-help-find-routine-definition name type class keyword)))) |
| 877 | idlwave-help-def-pos def-pos) | 880 | idlwave-help-def-pos def-pos) |
| 878 | 881 | ||
| 879 | (if (and idlwave-help-source-try-header | 882 | (if (and idlwave-help-source-try-header |
| 880 | (not (or struct-tag class-struct-tag))) | 883 | (not (or struct-tag class-struct-tag))) |
| 881 | ;; Check if we can find the header | 884 | ;; Check if we can find the header |
| 882 | (save-excursion | 885 | (save-excursion |
| @@ -886,7 +889,7 @@ This function can be used as `idlwave-extra-help-function'." | |||
| 886 | idlwave-help-in-header header-pos))) | 889 | idlwave-help-in-header header-pos))) |
| 887 | 890 | ||
| 888 | (if (or header-pos def-pos) | 891 | (if (or header-pos def-pos) |
| 889 | (progn | 892 | (progn |
| 890 | (if (boundp 'idlwave-help-min-frame-width) | 893 | (if (boundp 'idlwave-help-min-frame-width) |
| 891 | (setq idlwave-help-min-frame-width 80)) | 894 | (setq idlwave-help-min-frame-width 80)) |
| 892 | (goto-char (or header-pos def-pos))) | 895 | (goto-char (or header-pos def-pos))) |
| @@ -900,7 +903,7 @@ This function can be used as `idlwave-extra-help-function'." | |||
| 900 | KEYWORD is ignored. Returns the point of match if successful, nil otherwise." | 903 | KEYWORD is ignored. Returns the point of match if successful, nil otherwise." |
| 901 | (save-excursion | 904 | (save-excursion |
| 902 | (goto-char (point-max)) | 905 | (goto-char (point-max)) |
| 903 | (if (re-search-backward | 906 | (if (re-search-backward |
| 904 | (concat "^[ \t]*" | 907 | (concat "^[ \t]*" |
| 905 | (if (eq type 'pro) "pro" | 908 | (if (eq type 'pro) "pro" |
| 906 | (if (eq type 'fun) "function" | 909 | (if (eq type 'fun) "function" |
| @@ -946,22 +949,22 @@ with spaces allowed between the keyword and the following dash or equal sign. | |||
| 946 | If there is a match, we assume it is the keyword description." | 949 | If there is a match, we assume it is the keyword description." |
| 947 | (let* ((case-fold-search t) | 950 | (let* ((case-fold-search t) |
| 948 | (rname (if (stringp class) | 951 | (rname (if (stringp class) |
| 949 | (concat | 952 | (concat |
| 950 | "\\(" | 953 | "\\(" |
| 951 | ;; Traditional name or class::name | 954 | ;; Traditional name or class::name |
| 952 | "\\(" | 955 | "\\(" |
| 953 | "\\(" (regexp-quote (downcase class)) "::\\)?" | 956 | "\\(" (regexp-quote (downcase class)) "::\\)?" |
| 954 | (regexp-quote (downcase name)) | 957 | (regexp-quote (downcase name)) |
| 955 | "\\>\\)" | 958 | "\\>\\)" |
| 956 | (concat | 959 | (concat |
| 957 | "\\|" | 960 | "\\|" |
| 958 | ;; class__define or just class | 961 | ;; class__define or just class |
| 959 | (regexp-quote (downcase class)) "\\(__define\\)?") | 962 | (regexp-quote (downcase class)) "\\(__define\\)?") |
| 960 | "\\)") | 963 | "\\)") |
| 961 | (regexp-quote (downcase name)))) | 964 | (regexp-quote (downcase name)))) |
| 962 | 965 | ||
| 963 | ;; NAME tag plus the routine name. The new version is from JD. | 966 | ;; NAME tag plus the routine name. The new version is from JD. |
| 964 | (name-re (concat | 967 | (name-re (concat |
| 965 | "\\(^;+\\*?[ \t]*" | 968 | "\\(^;+\\*?[ \t]*" |
| 966 | idlwave-help-doclib-name | 969 | idlwave-help-doclib-name |
| 967 | "\\([ \t]*:\\|[ \t]*$\\)[ \t]*\\(\n;+[ \t]*\\)*" | 970 | "\\([ \t]*:\\|[ \t]*$\\)[ \t]*\\(\n;+[ \t]*\\)*" |
| @@ -996,7 +999,7 @@ If there is a match, we assume it is the keyword description." | |||
| 996 | (regexp-quote (upcase keyword)) | 999 | (regexp-quote (upcase keyword)) |
| 997 | "\\>"))) | 1000 | "\\>"))) |
| 998 | dstart dend name-pos kwds-pos kwd-pos) | 1001 | dstart dend name-pos kwds-pos kwd-pos) |
| 999 | (catch 'exit | 1002 | (catch 'exit |
| 1000 | (save-excursion | 1003 | (save-excursion |
| 1001 | (goto-char (point-min)) | 1004 | (goto-char (point-min)) |
| 1002 | (while (and (setq dstart (re-search-forward idlwave-doclib-start nil t)) | 1005 | (while (and (setq dstart (re-search-forward idlwave-doclib-start nil t)) |
| @@ -1004,7 +1007,7 @@ If there is a match, we assume it is the keyword description." | |||
| 1004 | ;; found a routine header | 1007 | ;; found a routine header |
| 1005 | (goto-char dstart) | 1008 | (goto-char dstart) |
| 1006 | (if (setq name-pos (re-search-forward name-re dend t)) | 1009 | (if (setq name-pos (re-search-forward name-re dend t)) |
| 1007 | (progn | 1010 | (progn |
| 1008 | (if keyword | 1011 | (if keyword |
| 1009 | ;; We do need a keyword | 1012 | ;; We do need a keyword |
| 1010 | (progn | 1013 | (progn |
| @@ -1086,7 +1089,7 @@ When DING is non-nil, ring the bell as well." | |||
| 1086 | (idlwave-help-find-first-header nil) | 1089 | (idlwave-help-find-first-header nil) |
| 1087 | (setq idlwave-help-in-header nil) | 1090 | (setq idlwave-help-in-header nil) |
| 1088 | (idlwave-help-toggle-header-match-and-def arg 'top))) | 1091 | (idlwave-help-toggle-header-match-and-def arg 'top))) |
| 1089 | 1092 | ||
| 1090 | (defun idlwave-help-toggle-header-match-and-def (arg &optional top) | 1093 | (defun idlwave-help-toggle-header-match-and-def (arg &optional top) |
| 1091 | (interactive "P") | 1094 | (interactive "P") |
| 1092 | (let ((args idlwave-help-args) | 1095 | (let ((args idlwave-help-args) |
| @@ -1098,7 +1101,7 @@ When DING is non-nil, ring the bell as well." | |||
| 1098 | (setq pos idlwave-help-def-pos)) | 1101 | (setq pos idlwave-help-def-pos)) |
| 1099 | ;; Try to display header | 1102 | ;; Try to display header |
| 1100 | (setq pos (apply 'idlwave-help-find-in-doc-header | 1103 | (setq pos (apply 'idlwave-help-find-in-doc-header |
| 1101 | (if top | 1104 | (if top |
| 1102 | (list (car args) (nth 1 args) (nth 2 args) nil) | 1105 | (list (car args) (nth 1 args) (nth 2 args) nil) |
| 1103 | args))) | 1106 | args))) |
| 1104 | (if pos | 1107 | (if pos |
| @@ -1132,7 +1135,7 @@ Useful when source code is displayed as help. See the option | |||
| 1132 | (font-lock-fontify-buffer)) | 1135 | (font-lock-fontify-buffer)) |
| 1133 | (set-syntax-table syntax-table))))) | 1136 | (set-syntax-table syntax-table))))) |
| 1134 | 1137 | ||
| 1135 | 1138 | ||
| 1136 | (defun idlwave-help-error (name type class keyword) | 1139 | (defun idlwave-help-error (name type class keyword) |
| 1137 | (error "Can't find help on %s%s %s" | 1140 | (error "Can't find help on %s%s %s" |
| 1138 | (or (and (or class name) (idlwave-make-full-name class name)) | 1141 | (or (and (or class name) (idlwave-make-full-name class name)) |