[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Info enhancements
From: |
Juri Linkov |
Subject: |
Re: Info enhancements |
Date: |
Tue, 16 Dec 2003 04:14:34 +0200 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) |
Richard Stallman <address@hidden> writes:
> I see no harm in letting it include anchors in completion, given that
> it does handle anchor names. We could rename it "Info-goto"
> to avoid the conflict between the name (which comes from a time
> before there were anchors) and the functionality (which reflects
> the existence of anchors).
Yes, I remember that you already suggested two weeks ago to create
a new function to go to any locator. This is the function that you
suggest to name Info-goto. At the same time, Info-goto-node could
be changed to go to node names only, and it makes sense to create also
a new function Info-goto-anchor to go to anchors only.
So, what do you think about this patch? It provides three functions
Info-goto, Info-goto-node and Info-goto-anchor that differ only by
their completion lists. I'm still unsure about keybindings to these
functions. Maybe, "g" - for Info-goto-node, "G" - for Info-goto
and no keybindings for Info-goto-anchor because Info-goto-anchor will
be rarely used (actually, I added Info-goto-anchor because it was too
easy to add it when a completion list creation function was changed
to handle anchor and node names separately).
===================================================================
*** emacs/lisp/info.el Fri Dec 12 03:29:35 2003
--- emacs/lisp/info.el Tue Dec 16 03:31:18 2003
***************
*** 227,233 ****
"Buffer used for indirect tag tables.")
(defvar Info-current-file-completions nil
! "Cached completion list for current Info file.")
(defvar Info-index-alternatives nil
"List of possible matches for last `Info-index' command.")
--- 227,236 ----
"Buffer used for indirect tag tables.")
(defvar Info-current-file-completions nil
! "Cached node completion list for current Info file.")
!
! (defvar Info-current-file-anchor-completions nil
! "Cached anchor completion list for current Info file.")
(defvar Info-index-alternatives nil
"List of possible matches for last `Info-index' command.")
***************
*** 715,720 ****
--- 718,724 ----
(setq Info-current-file nil
Info-current-subfile nil
Info-current-file-completions nil
+ Info-current-file-anchor-completions nil
buffer-file-name nil)
(erase-buffer)
(if (eq filename t)
***************
*** 1234,1248 ****
;; of the sort that is found in pointers in nodes.
(defun Info-goto-node (nodename &optional fork)
! "Go to info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME.
! If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file
! FILENAME; otherwise, NODENAME should be in the current Info file (or one of
its sub-files).
Completion is available, but only for node names in the current Info file.
If FORK is non-nil (interactively with a prefix arg), show the node in
a new info buffer.
If FORK is a string, it is the name to use for the new buffer."
! (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg))
(info-initialize)
(if fork
(set-buffer
--- 1238,1266 ----
;; of the sort that is found in pointers in nodes.
(defun Info-goto-node (nodename &optional fork)
! "Go to info node named NODENAME."
! (interactive (list (Info-read-node-name "Go to node: ")
! current-prefix-arg))
! (Info-goto nodename fork))
!
! (defun Info-goto-anchor (anchorname &optional fork)
! "Go to info anchor named ANCHORNAME."
! (interactive (list (Info-read-node-name "Go to anchor: " nil 'anchor)
! current-prefix-arg))
! (Info-goto anchorname fork))
!
! (defun Info-goto (nodename &optional fork)
! "Go to info node or anchor named NODENAME.
! Give just NODENAME or (FILENAME)NODENAME. If NODENAME is of the
! form (FILENAME)NODENAME, the node is in the Info file FILENAME;
! otherwise, NODENAME should be in the current Info file (or one of
its sub-files).
Completion is available, but only for node names in the current Info file.
If FORK is non-nil (interactively with a prefix arg), show the node in
a new info buffer.
If FORK is a string, it is the name to use for the new buffer."
! (interactive (list (Info-read-node-name "Go to node or anchor: " nil t)
! current-prefix-arg))
(info-initialize)
(if fork
(set-buffer
***************
*** 1300,1317 ****
(t
(test-completion string Info-read-node-completion-table predicate))))
! (defun Info-read-node-name (prompt &optional default)
(let* ((completion-ignore-case t)
! (Info-read-node-completion-table (Info-build-node-completions))
(nodename (completing-read prompt 'Info-read-node-name-1 nil t)))
(if (equal nodename "")
(or default
! (Info-read-node-name prompt))
nodename)))
(defun Info-build-node-completions ()
(or Info-current-file-completions
(let ((compl nil)
;; Bind this in case the user sets it to nil.
(case-fold-search t)
(node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]"))
--- 1318,1345 ----
(t
(test-completion string Info-read-node-completion-table predicate))))
! (defun Info-read-node-name (prompt &optional default anchor)
(let* ((completion-ignore-case t)
! (node-completions (Info-build-node-completions))
! ;; On the first call of `Info-build-node-completions'
! ;; it should set `Info-current-file-anchor-completions'
! (anchor-completions Info-current-file-anchor-completions)
! (Info-read-node-completion-table
! (append
! ;; Include node names if anchor is nil or t
! (if (not (eq anchor 'anchor)) node-completions)
! ;; Include anchor names if anchor is 'anchor or t
! (if anchor anchor-completions)))
(nodename (completing-read prompt 'Info-read-node-name-1 nil t)))
(if (equal nodename "")
(or default
! (Info-read-node-name prompt anchor))
nodename)))
(defun Info-build-node-completions ()
(or Info-current-file-completions
(let ((compl nil)
+ (compl-anchors nil)
;; Bind this in case the user sets it to nil.
(case-fold-search t)
(node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]"))
***************
*** 1323,1332 ****
(widen)
(goto-char marker)
(while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177"
nil t)
! (or (string-equal "Ref" (match-string 1))
! (setq compl
(cons (list (match-string-no-properties 2))
! compl)))))
(widen)
(goto-char (point-min))
;; If the buffer begins with a node header, process that first.
--- 1351,1363 ----
(widen)
(goto-char marker)
(while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177"
nil t)
! (if (string-equal "Ref" (match-string 1))
! (setq compl-anchors
(cons (list (match-string-no-properties 2))
! compl-anchors))
! (setq compl
! (cons (list (match-string-no-properties 2))
! compl)))))
(widen)
(goto-char (point-min))
;; If the buffer begins with a node header, process that first.
***************
*** 1342,1347 ****
--- 1373,1379 ----
(cons (list (match-string-no-properties 1))
compl))))))))
(setq compl (cons '("*") compl))
+ (set (make-local-variable 'Info-current-file-anchor-completions)
compl-anchors)
(set (make-local-variable 'Info-current-file-completions) compl))))
(defun Info-restore-point (hl)
===================================================================
--
http://www.jurta.org/emacs/
- Re: Info enhancements, (continued)
- Re: Info enhancements, Juri Linkov, 2003/12/12
- Re: Info enhancements, Richard Stallman, 2003/12/13
- Re: Info enhancements,
Juri Linkov <=
- Re: Info enhancements, Richard Stallman, 2003/12/16
- Re: Info enhancements, Juri Linkov, 2003/12/17
- Re: Info enhancements, Richard Stallman, 2003/12/18
- Re: Info enhancements, Luc Teirlinck, 2003/12/19
- Re: Info enhancements, Juri Linkov, 2003/12/20
- Re: Info enhancements, Eli Zaretskii, 2003/12/13