Mercurial > emacs
comparison lisp/info-look.el @ 48940:78987e4bee15
(info-lookup): For ease of use try item
case-insensitive if not found case-sensitive.
Do case sensitive search in index nodes, so items differing only in
case go correctly to their respective nodes.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 23 Dec 2002 17:54:31 +0000 |
parents | d09ed551daf4 |
children | d50289791f55 |
comparison
equal
deleted
inserted
replaced
48939:f3fc48331bdc | 48940:78987e4bee15 |
---|---|
316 (defun info-lookup (topic item mode) | 316 (defun info-lookup (topic item mode) |
317 "Display the documentation of a help item." | 317 "Display the documentation of a help item." |
318 (or mode (setq mode (info-lookup-select-mode))) | 318 (or mode (setq mode (info-lookup-select-mode))) |
319 (or (info-lookup->mode-value topic mode) | 319 (or (info-lookup->mode-value topic mode) |
320 (error "No %s help available for `%s'" topic mode)) | 320 (error "No %s help available for `%s'" topic mode)) |
321 (let ((entry (or (assoc (if (info-lookup->ignore-case topic mode) | 321 (let* ((completions (info-lookup->completions topic mode)) |
322 (downcase item) item) | 322 (ignore-case (info-lookup->ignore-case topic mode)) |
323 (info-lookup->completions topic mode)) | 323 (entry (or (assoc (if ignore-case (downcase item) item) completions) |
324 (error "Not documented as a %s: %s" topic (or item "")))) | 324 (assoc-ignore-case item completions) |
325 (modes (info-lookup->all-modes topic mode)) | 325 (error "Not documented as a %s: %s" topic (or item "")))) |
326 (window (selected-window)) | 326 (modes (info-lookup->all-modes topic mode)) |
327 found doc-spec node prefix suffix doc-found) | 327 (window (selected-window)) |
328 found doc-spec node prefix suffix doc-found) | |
328 (if (or (not info-lookup-other-window-flag) | 329 (if (or (not info-lookup-other-window-flag) |
329 (eq (current-buffer) (get-buffer "*info*"))) | 330 (eq (current-buffer) (get-buffer "*info*"))) |
330 (info) | 331 (info) |
331 (progn | 332 (progn |
332 (save-window-excursion (info)) | 333 (save-window-excursion (info)) |
354 (message "Cannot access Info node %s" node) | 355 (message "Cannot access Info node %s" node) |
355 (sit-for 1) | 356 (sit-for 1) |
356 nil)) | 357 nil)) |
357 (condition-case nil | 358 (condition-case nil |
358 (progn | 359 (progn |
359 (Info-menu (or (cdr entry) item)) | 360 ;; Don't use Info-menu, it forces case-fold-search to t |
361 (let ((case-fold-search nil)) | |
362 (re-search-forward | |
363 (concat "^\\* " (regexp-quote (or (cdr entry) (car entry))) | |
364 ":"))) | |
365 (Info-follow-nearest-node) | |
360 (setq found t) | 366 (setq found t) |
361 (if (or prefix suffix) | 367 (if (or prefix suffix) |
362 (let ((case-fold-search | 368 (let ((case-fold-search |
363 (info-lookup->ignore-case topic (car modes))) | 369 (info-lookup->ignore-case topic (car modes))) |
364 (buffer-read-only nil)) | 370 (buffer-read-only nil)) |
365 (goto-char (point-min)) | 371 (goto-char (point-min)) |
366 (re-search-forward | 372 (re-search-forward |
367 (concat prefix (regexp-quote item) suffix)) | 373 (concat prefix (regexp-quote (car entry)) suffix)) |
368 (goto-char (match-beginning 0)) | 374 (goto-char (match-beginning 0)) |
369 (and (display-color-p) info-lookup-highlight-face | 375 (and (display-color-p) info-lookup-highlight-face |
370 ;; Search again for ITEM so that the first | 376 ;; Search again for ITEM so that the first |
371 ;; occurrence of ITEM will be highlighted. | 377 ;; occurrence of ITEM will be highlighted. |
372 (re-search-forward (regexp-quote item)) | 378 (re-search-forward (regexp-quote (car entry))) |
373 (let ((start (match-beginning 0)) | 379 (let ((start (match-beginning 0)) |
374 (end (match-end 0))) | 380 (end (match-end 0))) |
375 (if (overlayp info-lookup-highlight-overlay) | 381 (if (overlayp info-lookup-highlight-overlay) |
376 (move-overlay info-lookup-highlight-overlay | 382 (move-overlay info-lookup-highlight-overlay |
377 start end (current-buffer)) | 383 start end (current-buffer)) |
380 (overlay-put info-lookup-highlight-overlay | 386 (overlay-put info-lookup-highlight-overlay |
381 'face info-lookup-highlight-face))))) | 387 'face info-lookup-highlight-face))))) |
382 (error nil))) | 388 (error nil))) |
383 (setq doc-spec (cdr doc-spec))) | 389 (setq doc-spec (cdr doc-spec))) |
384 (setq modes (cdr modes))) | 390 (setq modes (cdr modes))) |
391 ;; Alert the user if case was munged, and do this after bringing up the | |
392 ;; info buffer since that can print messages | |
393 (unless (or ignore-case | |
394 (string-equal item (car entry))) | |
395 (message "Found in differnt case: %s" (car entry))) | |
385 (or doc-found | 396 (or doc-found |
386 (error "Info documentation for lookup was not found")) | 397 (error "Info documentation for lookup was not found")) |
387 ;; Don't leave the Info buffer if the help item couldn't be looked up. | 398 ;; Don't leave the Info buffer if the help item couldn't be looked up. |
388 (if (and info-lookup-other-window-flag found) | 399 (if (and info-lookup-other-window-flag found) |
389 (select-window window)))) | 400 (select-window window)))) |