Function: Info-index

Info-index is an autoloaded, interactive and byte-compiled function defined in info.el.gz.

Signature

(Info-index TOPIC)

Documentation

Look up a string TOPIC in the index for this manual and go to that entry.

If there are no exact matches to the specified topic, this chooses the first match which is a case-insensitive substring of a topic. Use the , (Info-index-next) command to see the other matches. Give an empty topic name to go to the Index node itself.

Probably introduced at or before Emacs version 22.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/info.el.gz
;;;###autoload
(defun Info-index (topic)
  "Look up a string TOPIC in the index for this manual and go to that entry.
If there are no exact matches to the specified topic, this chooses
the first match which is a case-insensitive substring of a topic.
Use the \\<Info-mode-map>\\[Info-index-next] command to see the other matches.
Give an empty topic name to go to the Index node itself."
  (interactive
   (list
    (let ((completion-ignore-case t)
	  (Info-complete-menu-buffer (clone-buffer))
	  (Info-complete-nodes (Info-index-nodes))
	  (Info-history-list nil))
      (info--ensure-not-in-directory-node)
      (unwind-protect
	  (with-current-buffer Info-complete-menu-buffer
	    (Info-goto-index)
	    (completing-read "Index topic: " #'Info-complete-menu-item))
	(kill-buffer Info-complete-menu-buffer)))))
  (info--ensure-not-in-directory-node)
  ;; Strip leading colon in topic; index format does not allow them.
  (if (and (stringp topic)
	   (> (length topic) 0)
	   (= (aref topic 0) ?:))
      (setq topic (substring topic 1)))
  (let ((orignode Info-current-node)
	(pattern (format "\n\\* +\\([^\n]*\\(%s\\)[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
			 (regexp-quote topic)))
	node (nodes (Info-index-nodes))
	(ohist-list Info-history-list)
	(case-fold-search t))
    (Info-goto-index)
    (or (equal topic "")
	(let ((matches nil)
	      (exact nil)
	      ;; We bind Info-history to nil for internal node-switches so
	      ;; that we don't put junk in the history.  In the first
	      ;; Info-goto-index call, above, we do update the history
	      ;; because that is what the user's previous node choice into it.
	      (Info-history nil)
	      found)
	  (while
	      (progn
		(goto-char (point-min))
		(while (re-search-forward pattern nil t)
		  (let ((entry (match-string-no-properties 1))
			(nodename (match-string-no-properties 3))
			(line (string-to-number (concat "0" (match-string 4)))))
		    (add-text-properties
		     (- (match-beginning 2) (match-beginning 1))
		     (- (match-end 2) (match-beginning 1))
		     '(face info-index-match) entry)
		    (push (list entry nodename Info-current-node line) matches)))
		(setq nodes (cdr nodes) node (car nodes)))
	    (Info-goto-node node))
	  (or matches
	      (progn
		(Info-goto-node orignode)
		(user-error "No `%s' in index" topic)))
	  ;; Here it is a feature that assoc is case-sensitive.
	  (while (setq found (assoc topic matches))
	    (setq exact (cons found exact)
		  matches (delq found matches)))
          (setq Info-history-list ohist-list)
	  (setq Info-index-alternatives (nconc exact (nreverse matches))
                Info--current-index-alternative 0)
	  (Info-index-next 0)))))