Spelling fixes.
[bpt/emacs.git] / lisp / progmodes / idlw-help.el
index 9500dfc..0266fc1 100644 (file)
@@ -1,12 +1,12 @@
 ;;; idlw-help.el --- HTML Help code for IDLWAVE
 
-;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 2000-2011  Free Software Foundation, Inc.
 ;;
 ;; Authors: J.D. Smith <jdsmith@as.arizona.edu>
 ;;          Carsten Dominik <dominik@science.uva.nl>
 ;; Maintainer: J.D. Smith <jdsmith@as.arizona.edu>
-;; Version: 6.1_em22
+;; Version: 6.1.22
+;; Package: idlwave
 
 ;; This file is part of GNU Emacs.
 
@@ -41,7 +41,7 @@
 
 ;;; Code:
 (defvar idlwave-help-browse-url-available t
-  "Whether browse-url is available")
+  "Whether browse-url is available.")
 
 (require 'browse-url)
 
@@ -58,9 +58,9 @@
   (if idlwave-html-help-pre-v6 "#" "#wp"))
 
 (defcustom idlwave-html-system-help-location   "help/online_help/"
-  "The directory, relative to idlwave-system-directory, where the idl
+  "The directory, relative to `idlwave-system-directory', where the IDL
 HTML help files live, for IDL 6.2 and later.  This location, if found,
-is used in preference to the old idlwave-html-help-location."
+is used in preference to the old `idlwave-html-help-location'."
   :group 'idlwave-online-help
   :type 'directory)
 
@@ -69,7 +69,7 @@ is used in preference to the old idlwave-html-help-location."
       nil
     "/usr/local/etc/")
   "The directory where the idl_html_help/ dir lives.  Obsolete for IDL
-6.2 or later (see idlwave-html-system-help-location)."
+6.2 or later (see `idlwave-html-system-help-location')."
   :group 'idlwave-online-help
   :type 'directory)
 
@@ -82,13 +82,13 @@ is used in preference to the old idlwave-html-help-location."
   :type 'boolean)
 
 (defcustom idlwave-help-browser-function browse-url-browser-function
-  "Function to use to display html help.
+  "Function to use to display HTML help.
 Defaults to `browse-url-browser-function', which see."
   :group 'idlwave-online-help
   :type 'function)
 
 (defcustom idlwave-help-browser-generic-program browse-url-generic-program
-  "Program to run if using browse-url-generic-program."
+  "Program to run if using `browse-url-generic-program'."
   :group 'idlwave-online-help
   :type 'string)
 
@@ -97,7 +97,7 @@ Defaults to `browse-url-browser-function', which see."
 (defcustom idlwave-help-browser-generic-args
   (if (boundp 'browse-url-generic-args)
       browse-url-generic-args "")
-  "Program args to use if using browse-url-generic-program."
+  "Program args to use if using `browse-url-generic-program'."
   :group 'idlwave-online-help
   :type 'string)
 
@@ -112,7 +112,7 @@ must be explicitly set non-nil in order for the variable
   :type 'boolean)
 
 (defvar idlwave-help-directory ""
-  "Obsolete variable.  See idlwave-html-help-location.")
+  "Obsolete variable.  See `idlwave-html-help-location'.")
 
 (defcustom idlwave-help-use-dedicated-frame t
   "*Non-nil means, use a separate frame for Online Help if possible."
@@ -194,8 +194,7 @@ support."
   :type 'string)
 
 (defface idlwave-help-link
-  '((((class color)) (:foreground "Blue"))
-    (t (:weight bold)))
+  '((t :inherit link))
   "Face for highlighting links into IDLWAVE online help."
   :group 'idlwave-online-help)
 
@@ -210,32 +209,33 @@ support."
   "The default width of the help frame.")
 
 (defvar idlwave-html-help-is-available nil
-  "Is the system online help text avaiable?")
+  "Is the system online help text available?")
 
 (defvar idlwave-help-mode-line-indicator ""
-  "Used for the special mode line in the idlwave-help-mode.")
+  "Used for the special mode line in the `idlwave-help-mode'.")
 
 (defvar idlwave-help-window-configuration nil)
 (defvar idlwave-help-special-topic-words nil) ; defined by get_rinfo
 
 ;; Define the key bindings for the Help application
 
-(defvar idlwave-help-mode-map (make-sparse-keymap)
-  "The keymap used in idlwave-help-mode.")
-
-(define-key idlwave-help-mode-map "q" 'idlwave-help-quit)
-(define-key idlwave-help-mode-map "w" 'widen)
-(define-key idlwave-help-mode-map "\C-m" (lambda (arg)
-                                          (interactive "p")
-                                          (scroll-up arg)))
-(define-key idlwave-help-mode-map " " 'scroll-up)
-(define-key idlwave-help-mode-map [delete] 'scroll-down)
-(define-key idlwave-help-mode-map "h" 'idlwave-help-find-header)
-(define-key idlwave-help-mode-map "H" 'idlwave-help-find-first-header)
-(define-key idlwave-help-mode-map "." 'idlwave-help-toggle-header-match-and-def)
-(define-key idlwave-help-mode-map "F" 'idlwave-help-fontify)
-(define-key idlwave-help-mode-map "\M-?" 'idlwave-help-return-to-calling-frame)
-(define-key idlwave-help-mode-map "x" 'idlwave-help-return-to-calling-frame)
+(defvar idlwave-help-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "q" 'idlwave-help-quit)
+    (define-key map "w" 'widen)
+    (define-key map "\C-m" (lambda (arg)
+                             (interactive "p")
+                             (scroll-up arg)))
+    (define-key map " " 'scroll-up-command)
+    (define-key map [delete] 'scroll-down-command)
+    (define-key map "h" 'idlwave-help-find-header)
+    (define-key map "H" 'idlwave-help-find-first-header)
+    (define-key map "." 'idlwave-help-toggle-header-match-and-def)
+    (define-key map "F" 'idlwave-help-fontify)
+    (define-key map "\M-?" 'idlwave-help-return-to-calling-frame)
+    (define-key map "x" 'idlwave-help-return-to-calling-frame)
+    map)
+  "The keymap used in `idlwave-help-mode'.")
 
 ;; Define the menu for the Help application
 
@@ -287,7 +287,7 @@ support."
 (declare-function idlwave-what-module-find-class "idlwave")
 (declare-function idlwave-where "idlwave")
 
-(defun idlwave-help-mode ()
+(define-derived-mode idlwave-help-mode special-mode "IDLWAVE Help"
   "Major mode for displaying IDL Help.
 
 This is a VIEW mode for the ASCII version of IDL Help files,
@@ -303,15 +303,11 @@ When the hep text is a source file, the following commands are available
 Fontification:      [F]ontify the buffer like source code
 Jump:               [h] to function doclib header
                     [H] to file doclib header
-                    [.] back and forward between header and definition
+                    [.] back and forth between header and definition
 
 Here are all keybindings.
 \\{idlwave-help-mode-map}"
-  (kill-all-local-variables)
   (buffer-disable-undo)
-  (setq major-mode 'idlwave-help-mode
-       mode-name "IDLWAVE Help")
-  (use-local-map idlwave-help-mode-map)
   (easy-menu-add idlwave-help-menu idlwave-help-mode-map)
   (setq truncate-lines t)
   (setq case-fold-search t)
@@ -324,8 +320,7 @@ Here are all keybindings.
   (setq buffer-read-only t)
   (set (make-local-variable 'idlwave-help-def-pos) nil)
   (set (make-local-variable 'idlwave-help-args) nil)
-  (set (make-local-variable 'idlwave-help-in-header) nil)
-  (run-hooks 'idlwave-help-mode-hook))
+  (set (make-local-variable 'idlwave-help-in-header) nil))
 
 (defun idlwave-html-help-location ()
   "Return the help directory where HTML files are, or nil if that is unknown."
@@ -359,7 +354,7 @@ Here are all keybindings.
       (message "Cannot locate IDL Assistant, enabling default browser.")
       (setq idlwave-help-use-assistant nil)
       (unless idlwave-help-browse-url-available
-       (error "browse-url is not available; install it or IDL Assistant to use HTML help.")))))
+       (error "browse-url is not available; install it or IDL Assistant to use HTML help")))))
 
 
 (defvar idlwave-current-obj_new-class)
@@ -367,7 +362,7 @@ Here are all keybindings.
 (defvar idlwave-experimental)
 (defvar idlwave-last-context-help-pos)
 (defun idlwave-do-context-help (&optional arg)
-  "Wrapper around the call to idlwave-context-help1.
+  "Wrapper around the call to `idlwave-do-context-help1'.
 It collects and prints the diagnostics messages."
   (let ((marker (list (current-buffer) (point)))
        (idlwave-help-diagnostics nil))
@@ -575,13 +570,13 @@ Needs additional info stored in global `idlwave-completion-help-info'."
   (let* ((cw (selected-window))
         (info idlwave-completion-help-info) ; global passed in
         (what (nth 0 info))
-        (name (nth 1 info))
+        (idlw-help-name (nth 1 info))
         (type (nth 2 info))
         (class (nth 3 info))
         (need-class class)
-        (kwd (nth 4 info))
+        (idlw-help-kwd (nth 4 info))
         (sclasses (nth 5 info))
-        word link)
+        word idlw-help-link)
     (mouse-set-point ev)
 
 
@@ -589,18 +584,18 @@ Needs additional info stored in global `idlwave-completion-help-info'."
     (setq word (idlwave-this-word))
     (if (string= word "")
        (error "No help item selected"))
-    (setq link (get-text-property 0 'link word))
+    (setq idlw-help-link (get-text-property 0 'link word))
     (select-window cw)
     (cond
      ;; Routine name
      ((memq what '(procedure function routine))
-      (setq name word)
+      (setq idlw-help-name word)
       (if (or (eq class t)
              (and (stringp class) sclasses))
          (let* ((classes (idlwave-all-method-classes
-                          (idlwave-sintern-method name)
+                          (idlwave-sintern-method idlw-help-name)
                           type)))
-           (setq link t)               ; No specific link valid yet
+           (setq idlw-help-link t)             ; No specific link valid yet
            (if sclasses
                (setq classes (idlwave-members-only
                               classes (cons class sclasses))))
@@ -610,19 +605,19 @@ Needs additional info stored in global `idlwave-completion-help-info'."
       ;; XXX is this necessary, given all-method-classes?
       (if (stringp class)
          (setq class (idlwave-find-inherited-class
-                      (idlwave-sintern-routine-or-method name class)
+                      (idlwave-sintern-routine-or-method idlw-help-name class)
                       type (idlwave-sintern-class class)))))
 
      ;; Keyword
      ((eq what 'keyword)
-      (setq kwd word)
+      (setq idlw-help-kwd word)
       (if (or (eq class t)
              (and (stringp class) sclasses))
          (let ((classes  (idlwave-all-method-keyword-classes
-                          (idlwave-sintern-method name)
-                          (idlwave-sintern-keyword kwd)
+                          (idlwave-sintern-method idlw-help-name)
+                          (idlwave-sintern-keyword idlw-help-kwd)
                           type)))
-           (setq link t) ; Link can't be correct yet
+           (setq idlw-help-link t) ; Link can't be correct yet
            (if sclasses
                (setq classes (idlwave-members-only
                               classes (cons class sclasses))))
@@ -631,11 +626,12 @@ Needs additional info stored in global `idlwave-completion-help-info'."
            ;; XXX is this necessary, given all-method-keyword-classes?
            (if (stringp class)
                (setq class (idlwave-find-inherited-class
-                            (idlwave-sintern-routine-or-method name class)
+                            (idlwave-sintern-routine-or-method
+                             idlw-help-name class)
                             type (idlwave-sintern-class class)))))
-       (if (string= (downcase name) "obj_new")
+       (if (string= (downcase idlw-help-name) "obj_new")
            (setq class idlwave-current-obj_new-class
-                 name "Init"))))
+                 idlw-help-name "Init"))))
 
      ;; Class name
      ((eq what 'class)
@@ -648,9 +644,11 @@ Needs additional info stored in global `idlwave-completion-help-info'."
       (funcall what 'set word))
 
      (t (error "Cannot help with this item")))
-    (if (and need-class (not class) (not (and link (not (eq link t)))))
+    (if (and need-class (not class)
+            (not (and idlw-help-link (not (eq idlw-help-link t)))))
        (error "Cannot help with this item"))
-    (idlwave-online-help link (or name word) type class kwd)))
+    (idlwave-online-help idlw-help-link (or idlw-help-name word)
+                        type class idlw-help-kwd)))
 
 (defvar idlwave-highlight-help-links-in-completion)
 (defvar idlwave-completion-help-links)
@@ -707,7 +705,8 @@ Those words in `idlwave-completion-help-links' have links.  The
             ;; we kill the help frame before the return-frame is selected.
             ;; To protect the workings, we wait for up to one second
             ;; and check if the return-frame *is* now selected.
-            ;; This is marked "eperimental" since we are not sure when its OK.
+            ;; This is marked "experimental" since we are not sure when
+            ;; it's OK.
             (let ((maxtime 1.0) (time 0.) (step 0.1))
               (select-frame idlwave-help-return-frame)
               (while (and (sit-for step)
@@ -766,7 +765,7 @@ if passed as a function.  See `idlwave-help-use-dedicated-frame'."
   "Display HTML or other special help on a certain topic.
 Either loads an HTML link, if LINK is non-nil, or gets special-help on
 the optional arguments, if any special help is defined.  If LINK is
-`t', first look up the optional arguments in the routine info list to
+t, first look up the optional arguments in the routine info list to
 see if a link is set for it.  Try extra help functions if necessary."
   ;; Lookup link
   (if (eq link t)
@@ -807,8 +806,7 @@ see if a link is set for it.  Try extra help functions if necessary."
 (defun idlwave-help-get-special-help (name type class keyword)
   "Call the function given by `idlwave-extra-help-function'."
   (let* ((cw (selected-window))
-        (help-pos (save-excursion
-                    (set-buffer (idlwave-help-get-help-buffer))
+        (help-pos (with-current-buffer (idlwave-help-get-help-buffer)
                     (let ((buffer-read-only nil))
                       (funcall idlwave-extra-help-function
                                name type class keyword)))))
@@ -818,7 +816,7 @@ see if a link is set for it.  Try extra help functions if necessary."
     (select-window cw)))
 
 (defun idlwave-help-html-link (link)
-  "Get html help on a given LINK."
+  "Get HTML help on a given LINK."
   (let ((browse-url-browser-function idlwave-help-browser-function)
        (help-loc (idlwave-html-help-location))
        (browse-url-generic-program idlwave-help-browser-generic-program)
@@ -828,7 +826,7 @@ see if a link is set for it.  Try extra help functions if necessary."
     ;; Just a regular file name (+ anchor name)
     (unless (and (stringp help-loc)
                 (file-directory-p help-loc))
-      (error "Invalid help location."))
+      (error "Invalid help location"))
     (setq full-link (browse-url-file-url (expand-file-name link help-loc)))
 
     ;; Select the browser
@@ -838,7 +836,7 @@ see if a link is set for it.  Try extra help functions if necessary."
 
      ((or idlwave-help-browser-is-local
          (string-match "w3" (symbol-name idlwave-help-browser-function)))
-      (idlwave-help-display-help-window '(lambda () (browse-url full-link))))
+      (idlwave-help-display-help-window (lambda () (browse-url full-link))))
 
      (t (browse-url full-link)))))
 
@@ -848,14 +846,14 @@ see if a link is set for it.  Try extra help functions if necessary."
 (defvar idlwave-current-tags-buffer)
 (defvar idlwave-current-tags-class)
 (defun idlwave-help-with-source (name type class keyword)
-  "Provide help for routines not documented in the IDL manuals.  Works
-by loading the routine source file into the help buffer.  Depending on
-the value of `idlwave-help-source-try-header', it attempts to show the
-routine definition or the header description.  If
-`idlwave-help-do-class-struct-tag' is non-nil, keyword is a tag to
-show help on from the class definition structure.  If
-`idlwave-help-do-struct-tag' is non-nil, show help from the matching
-structure tag definition.
+  "Provide help for routines not documented in the IDL manuals.
+Works by loading the routine source file into the help buffer.
+Depending on the value of `idlwave-help-source-try-header', it
+attempts to show the routine definition or the header description.
+If `idlwave-help-do-class-struct-tag' is non-nil, keyword is a tag
+to show help on from the class definition structure.
+If `idlwave-help-do-struct-tag' is non-nil, show help from the
+matching structure tag definition.
 
 This function can be used as `idlwave-extra-help-function'."
   (let* ((class-struct-tag idlwave-help-do-class-struct-tag)
@@ -954,7 +952,8 @@ This function can be used as `idlwave-extra-help-function'."
 
 (defun idlwave-help-find-routine-definition (name type class keyword)
   "Find the definition of routine CLASS::NAME in current buffer.
-KEYWORD is ignored. Returns the point of match if successful, nil otherwise."
+Returns the point of match if successful, nil otherwise.
+KEYWORD is ignored."
   (save-excursion
     (goto-char (point-max))
     (if (re-search-backward
@@ -987,12 +986,12 @@ describes the correct routine - even if the keyword description cannot
 be found.  TYPE is ignored.
 
 This function expects a more or less standard routine header.  In
-particlar it looks for the `NAME:' tag, either with a colon, or alone
+particular it looks for the `NAME:' tag, either with a colon, or alone
 on a line.  Then `NAME:' must be followed by the routine name on the
 same or the next line.  When KEYWORD is non-nil, looks first for a
-`KEYWORDS' section.  It is amazing how inconsisten this is through
+`KEYWORDS' section.  It is amazing how inconsistent this is through
 some IDL libraries I have seen.  We settle for a line containing an
-upper case \"KEYWORD\" string.  If this line is not fould we search
+upper case \"KEYWORD\" string.  If this line is not found we search
 for the keyword anyway to increase the hit-rate
 
 When one of these sections exists we check for a line starting with any of
@@ -1200,7 +1199,7 @@ Useful when source code is displayed as help.  See the option
           "(help location unknown)")))
 
 (defun idlwave-help-show-help-frame ()
-  "Show the help frame, creating it if necessary"
+  "Show the help frame, creating it if necessary."
   ;; Use a special frame for this
   (unless (frame-live-p idlwave-help-frame)
     (setq idlwave-help-frame
@@ -1224,8 +1223,7 @@ Useful when source code is displayed as help.  See the option
     (if buf
        nil
       (setq buf (get-buffer-create "*IDLWAVE Help*"))
-      (save-excursion
-       (set-buffer buf)
+      (with-current-buffer buf
        (idlwave-help-mode)))
     buf))
 
@@ -1256,7 +1254,7 @@ Useful when source code is displayed as help.  See the option
   (if (memq system-type '(ms-dos windows-nt))
       "bin/bin.x86/idl_assistant.exe"
     "bin/idl_assistant")
-  "The command, rooted at idlwave-system-directory, which invokes the
+  "The command, rooted at `idlwave-system-directory', which invokes the
 IDL assistant.")
 
 (defun idlwave-help-assistant-available ()
@@ -1295,7 +1293,7 @@ IDL assistant.")
       (unless (accept-process-output idlwave-help-assistant-process 15)
        (error "Failed binding IDL_ASSISTANT socket"))
       (if (not port)
-         (error "Unable to open IDL_ASSISTANT.")
+         (error "Unable to open IDL_ASSISTANT")
        (set-process-filter idlwave-help-assistant-process nil)
        (setq idlwave-help-assistant-socket
              (open-network-stream "IDL_ASSISTANT_SOCK"
@@ -1320,7 +1318,7 @@ IDL assistant.")
     (if (string-match "\.html" link)
        (setq topic (substring link 0 (match-beginning 0))
              anchor (substring link (match-end 0)))
-      (error "Malformed help link."))
+      (error "Malformed help link"))
 
     (setq file (expand-file-name (concat topic ".html") help-loc))
     (if (file-exists-p file)
@@ -1383,5 +1381,4 @@ IDL assistant.")
 (provide 'idlw-help)
 (provide 'idlwave-help)
 
-;; arch-tag: d27b5505-59de-497f-ba3f-f199fd4fb911
 ;;; idlw-help.el ends here