;;; info-look.el --- major-mode-sensitive Info index lookup facility.
;; An older version of this was known as libc.el.
-;; Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
-;; Author: Ralph Schleicher <rs@purple.UL.BaWue.DE>
-;; Maintainers: FSF (unless Schleicher can be found)
+;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org>
;; Keywords: help languages
;; This file is part of GNU Emacs.
;;; Code:
(require 'info)
-(eval-and-compile
- (condition-case nil
- (require 'custom)
- (error
- (defmacro defgroup (&rest arg)
- nil)
- (defmacro defcustom (symbol value doc &rest arg)
- `(defvar ,symbol ,value ,doc ,@arg)))))
(defgroup info-lookup nil
"Major mode sensitive help agent."
(if (or (not info-lookup-other-window-flag)
(eq (current-buffer) (get-buffer "*info*")))
(info)
- (save-window-excursion (info))
- (switch-to-buffer-other-window "*info*"))
+ (progn
+ (save-window-excursion (info))
+ ;; Determine whether or not the Info buffer is visible in
+ ;; another frame on the same display. If it is, simply raise
+ ;; that frame. Otherwise, display it in another window.
+ (let* ((window (get-buffer-window "*info*" t))
+ (info-frame (and window (window-frame window))))
+ (if (and info-frame
+ (display-multi-frame-p)
+ (memq info-frame (frames-on-display-list)))
+ (select-frame info-frame)
+ (switch-to-buffer-other-window "*info*")))))
(while (and (not found) modes)
(setq doc-spec (info-lookup->doc-spec topic (car modes)))
(while (and (not found) doc-spec)
prefix (nth 2 (car doc-spec))
suffix (nth 3 (car doc-spec)))
(when (condition-case error-data
- (progn
+ (progn
(Info-goto-node node)
(setq doc-found t))
- (error
+ (error
(message "Cannot access Info node %s" node)
(sit-for 1)
nil))
(re-search-forward
(concat prefix (regexp-quote item) suffix))
(goto-char (match-beginning 0))
- (and window-system info-lookup-highlight-face
+ (and (display-color-p) info-lookup-highlight-face
;; Search again for ITEM so that the first
;; occurence of ITEM will be highlighted.
(re-search-forward (regexp-quote item))
(with-current-buffer buffer
(message "Processing Info node `%s'..." node)
(when (condition-case error-data
- (progn
+ (progn
(Info-goto-node node)
(setq doc-found t))
- (error
+ (error
(message "Cannot access Info node `%s'" node)
(sit-for 1)
nil))
;; `trans' can return nil if the regexp doesn't match.
(when (and item
;; Sometimes there's more than one Menu:
- (not (string= entry "Menu")))
+ (not (string= entry "Menu")))
(and (info-lookup->ignore-case topic mode)
(setq item (downcase item)))
(and (string-equal entry item)
subexp (cdr rule))
(setq regexp rule
subexp 0))
- (skip-chars-backward " \t\n") (setq end (point))
+ ;; If at start of symbol, don't go back to end of previous one.
+ (if (save-match-data
+ (looking-at "[ \t\n]"))
+ (skip-chars-backward " \t\n"))
+ (setq end (point))
(while (and (re-search-backward regexp nil t)
(looking-at regexp)
(>= (match-end 0) end))
(format "Complete %S: " topic)
completions nil t completion
info-lookup-history)))
- (delete-region (- start (length try)) start)
+ ;; Find the original symbol and zap it.
+ (end-of-line)
+ (while (and (search-backward try nil t)
+ (< start (point))))
+ (replace-match "")
(insert completion))
(t
(message "%s is complete"
(info-lookup-maybe-add-help
:mode 'octave-mode
:regexp "[_a-zA-Z0-9]+"
- :doc-spec '(("(octave)Function Index" nil "^ - [^:]+:[ ]+" nil)
+ :doc-spec '(("(octave)Function Index" nil
+ "^ - [^:]+:[ ]+\\(\\[[^=]*=[ ]+\\)?" nil)
("(octave)Variable Index" nil "^ - [^:]+:[ ]+" nil)
;; Catch lines of the form "xyz statement"
- ("(octave)Concept Index"
+ ("(octave)Concept Index"
(lambda (item)
(cond
((string-match "^\\([A-Z]+\\) statement\\b" item)