aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-02-14 22:46:12 +0000
committerRichard M. Stallman1998-02-14 22:46:12 +0000
commit6bc7c7a2a7e5464e28c268c4087e69c9233237e4 (patch)
treef7fcc051fb35ee3231ea8a00c7b96e50d8315146
parentaff2ce94e2a60d5bb769fb23e14c6d1027088989 (diff)
downloademacs-6bc7c7a2a7e5464e28c268c4087e69c9233237e4.tar.gz
emacs-6bc7c7a2a7e5464e28c268c4087e69c9233237e4.zip
(info-complete): Display completions on second invocation at same point
or if initial guess is already ambiguous. (info-look-completion): New variable. (info-lookup-symbol-alist): Added support for latex-mode, perl-mode, awk-mode, emacs-lisp-mode.
-rw-r--r--lisp/info-look.el108
1 files changed, 103 insertions, 5 deletions
diff --git a/lisp/info-look.el b/lisp/info-look.el
index 4b5f5f5e6f7..010d073bdce 100644
--- a/lisp/info-look.el
+++ b/lisp/info-look.el
@@ -194,7 +194,85 @@ REFER-MODES is a list of other help modes to use.")
194 (lambda (item) 194 (lambda (item)
195 (if (string-match "^\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\( .*\\)?$" item) 195 (if (string-match "^\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\( .*\\)?$" item)
196 (concat "@" (match-string 1 item)))) 196 (concat "@" (match-string 1 item))))
197 "`" "'")))) 197 "`" "'")))
198 (awk-mode ;;; Added by Peter Galbraith <galbraith@mixing.qc.dfo.ca>
199 "[_a-zA-Z]+"
200 nil ; Don't ignore-case
201 (("(gawk)Index" ; info node
202 (lambda (item) ; TRANS-FUNC index-entry-->help-item
203 ;; In awk-mode, we want entries like:
204 ;; * BEGIN special pattern: BEGIN/END.
205 ;; * break statement: Break Statement.
206 ;; * FS: Field Separators.
207 ;; * gsub: String Functions.
208 ;; * system: I/O Functions.
209 ;; * systime: Time Functions.
210 ;;
211 ;; But not:
212 ;; * time of day: Time Functions.
213 ;; ^^^^^^^^^^^ More than one word.
214 ;;
215 ;; However, info-look's info-lookup-make-completions doesn't pass
216 ;; the whole line to the TRANS-FUNC, but only up to the first
217 ;; colon. So I can't use all the available info to decide what to
218 ;; keep. Therefore, I have to `set-buffer' to the *info* buffer.
219 ;;
220 ;; Also, info-look offers no way to add non-indexed entries like
221 ;; `cos' and other gawk Numeric Built-in Functions (or does it?)
222 ;; as in ftp://ftp.phys.ocean.dal.ca/users/rhogee/elisp/func-doc.el
223 ;; and http://www.ifi.uio.no/~jensthi/word-help.el (which adds a
224 ;; heap of stuff for latex!)
225 (let ((case-fold-search nil))
226 (cond
227 ((string-match "\\([^ ]+\\) *\\(special pattern\\|statement\\)$"
228 item)
229 (match-string 1 item))
230 ((string-match "^[A-Z]+$" item) ;This will grab FS and the like.
231 item)
232 ((string-match "^[a-z]+$" item)
233 (save-excursion
234 (set-buffer "*info*")
235 (if (looking-at " *\\(String\\|I/O\\|Time\\) Functions")
236 item))))))
237 "`" "'"))) ;Append PREFIX and SUFFIX to finetune
238 ; displayed location in Info node.
239 ;; Perl -- Added by Peter Galbraith <galbraith@mixing.qc.dfo.ca>
240 ;; Perl Version 5 Info files are available in CPAN sites, at:
241 ;; http://www.perl.com/CPAN/doc/manual/info/
242 ;;
243 ;; ftp://ftp.funet.fi/pub/languages/perl/CPAN/doc/manual/texinfo/
244 ;; ftp://ftp.pasteur.fr/pub/computing/unix/perl/CPAN/doc/manual/texinfo/
245 ;; ftp://mango.softwords.bc.ca/pub/perl/CPAN/doc/manual/texinfo/
246 ;; ftp://uiarchive.cso.uiuc.edu/pub/lang/perl/CPAN/doc/manual/texinfo/
247 (perl-mode
248 "$?[^ \n\t{(]+"
249 nil ; Don't ignore-case
250 (("(perl5)Function Index" ; info node
251 (lambda (item) ; TRANS-FUNC index-entry-->help-item
252 (if (string-match "^\\([a-z0-9]+\\)" item)
253 (match-string 1 item)))
254 "^" nil)
255 ("(perl5)Variable Index" ; info node
256 (lambda (item) ; TRANS-FUNC index-entry-->help-item
257 (if (string-match "^\\([^ \n\t{(]+\\)" item) ;First word
258 (match-string 1 item)))
259 "^" nil)))
260 ;; LaTeX -- Added by Peter Galbraith <galbraith@mixing.qc.dfo.ca>
261 ;; Info file available at:
262 ;; ftp://ftp.dante.de:pub/tex/info/latex2e-help-texinfo/latex2e.texi
263 (latex-mode "[\\a-zA-Z]+" nil (("(latex)Command Index" nil "`" nil)))
264 (emacs-lisp-mode
265 "[^][ ()\n\t.\"'#]+" nil
266 (("(elisp)Index"
267 (lambda (item)
268 (if (string-match "[^ ]+" item) ;First word
269 (match-string 0 item)))
270 "" "")
271 ("(emacs)Command Index"
272 (lambda (item)
273 (if (string-match "[^ ]+" item) ;First word
274 (match-string 0 item)))
275 "" ""))))
198 "*Alist of help specifications for symbol names. 276 "*Alist of help specifications for symbol names.
199See the documentation of the variable `info-lookup-alist' for more details.") 277See the documentation of the variable `info-lookup-alist' for more details.")
200 278
@@ -516,7 +594,9 @@ Return nil if there is nothing appropriate."
516 (or (info-lookup->mode-value topic mode) 594 (or (info-lookup->mode-value topic mode)
517 (error "No %s completion available for `%s'" topic mode)) 595 (error "No %s completion available for `%s'" topic mode))
518 (let ((modes (info-lookup->all-modes topic mode)) 596 (let ((modes (info-lookup->all-modes topic mode))
519 (start (point)) try completion) 597 (start (point))
598 (completion-list (info-lookup->completions topic mode))
599 try completion)
520 (while (and (not try) modes) 600 (while (and (not try) modes)
521 (setq mode (car modes) 601 (setq mode (car modes)
522 modes (cdr modes) 602 modes (cdr modes)
@@ -524,13 +604,31 @@ Return nil if there is nothing appropriate."
524 (goto-char start)) 604 (goto-char start))
525 (and (not try) 605 (and (not try)
526 (error "Found no %s to complete" topic)) 606 (error "Found no %s to complete" topic))
527 (setq completion (try-completion 607 (setq completion (try-completion try completion-list))
528 try (info-lookup->completions topic mode)))
529 (cond ((not completion) 608 (cond ((not completion)
609 (message "No %s match" topic)
530 (ding)) 610 (ding))
531 ((stringp completion) 611 ((stringp completion)
532 (delete-region (- start (length try)) start) 612 (delete-region (- start (length try)) start)
533 (insert completion))))) 613 (insert completion)
614 (if (or (string-equal try completion)
615 (and (boundp 'info-look-completion)
616 info-look-completion
617 (= (point) (car info-look-completion))
618 (equal completion (car (cdr info-look-completion)))))
619 ;; Show completion list
620 (let ((list (all-completions completion completion-list)))
621 (with-output-to-temp-buffer "*Completions*"
622 (display-completion-list list))
623 (if (member completion list)
624 (message "Complete but not unique"))))
625 (setq info-look-completion (list (point) completion)))
626 (t
627 (message "%s is complete" topic)))))
628
629(defvar info-look-completion nil
630 "info-look cache for last completion and point to display completion or not")
631(make-variable-buffer-local 'info-look-completion)
534 632
535(provide 'info-look) 633(provide 'info-look)
536 634