[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex d56502e 05/26: Support node name completion in t
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex d56502e 05/26: Support node name completion in texinfo |
Date: |
Fri, 13 Nov 2015 17:00:32 +0000 |
branch: externals/auctex
commit d56502e7dcba118c62d38f6fe2f5a855834e6816
Author: Vincent Belaïche <address@hidden>
Commit: Tassilo Horn <address@hidden>
Support node name completion in texinfo
* tex-info.el (Texinfo-nodename-de-escape): New defun.
(Texinfo-nodename-escape): New defun.
(Texinfo-make-node-list): New defun, code taken from
Texinfo-insert-node into this function for the sake of code
factorization. In addition, (1) allow node name not to be
followed by a comma --- i.e. next node etc. unspecified --- (2)
trim trailing blanks after node name, and (3) de-escape @comma{}
before insertion of node name into the list.
(Texinfo-insert-node): (1) Use new function
`Texinfo-make-node-list', and (2) escape node names for commas.
(Texinfo-arg-nodename): New defun.
(TeX-texinfo-mode): (1) Remove `group' from list of commands,
`group' is an environment, not a command. (2) Add
`guillemetleft', `guillemetright', `guilsinglleft',
`guilsinglright', `quotedblbase' and `quotesinglbase' to the list
of commands. (3) For commands `pxref', `ref' and `xref', use new
function `Texinfo-arg-nodename' to read node name with completion.
Signed-off-by: Tassilo Horn <address@hidden>
---
ChangeLog | 20 ++++++++++++
tex-info.el | 95 ++++++++++++++++++++++++++++++++++++++++++++++------------
2 files changed, 95 insertions(+), 20 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3f5aec6..73864da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2015-10-25 Vincent Bela�che <address@hidden>
+
+ * tex-info.el (Texinfo-nodename-de-escape): New defun.
+ (Texinfo-nodename-escape): New defun.
+ (Texinfo-make-node-list): New defun, code taken from
+ Texinfo-insert-node into this function for the sake of code
+ factorization. In addition, (1) allow node name not to be
+ followed by a comma --- i.e. next node etc. unspecified --- (2)
+ trim trailing blanks after node name, and (3) de-escape @comma{}
+ before insertion of node name into the list.
+ (Texinfo-insert-node): (1) Use new function
+ `Texinfo-make-node-list', and (2) escape node names for commas.
+ (Texinfo-arg-nodename): New defun.
+ (TeX-texinfo-mode): (1) Remove `group' from list of commands,
+ `group' is an environment, not a command. (2) Add
+ `guillemetleft', `guillemetright', `guilsinglleft',
+ `guilsinglright', `quotedblbase' and `quotesinglbase' to the list
+ of commands. (3) For commands `pxref', `ref' and `xref', use new
+ function `Texinfo-arg-nodename' to read node name with completion.
+
2015-10-24 Arash Esbati <address@hidden>
* style/enumitem.el (LaTeX-enumitem-auto-cleanup): Move some
diff --git a/tex-info.el b/tex-info.el
index 40b0391..39d1d5c 100644
--- a/tex-info.el
+++ b/tex-info.el
@@ -290,6 +290,50 @@ beginning of keyword address@hidden' or address@hidden'."
(goto-char beg)
(TeX-activate-region) )))
+(defun Texinfo-nodename-de-escape (node-name)
+ "In NODE-NAME, convert address@hidden' commands to the corresponding `,'
+character. Return the resulting string."
+ (let ((pos 0) (map '(("comma" . ","))))
+ (while (and (< pos (length
+ node-name)) (string-match "@\\(comma\\)[[:blank:]]*{}"
node-name pos))
+ (setq node-name (concat (substring node-name 0 (match-beginning 0))
+ (cdr (assoc-string (match-string 1 node-name)
map))
+ (substring node-name (match-end 0)))
+ pos (1+ (match-beginning 0)))))
+ node-name)
+
+
+(defun Texinfo-nodename-escape (node-name)
+ "Convert in NODE-NAME the `,' characters to address@hidden'
+commands. Return the resulting string."
+ (let* ((pos 0)
+ (map '(("," . "comma")))
+ (re (regexp-opt (mapcar 'car map))) )
+ (while (and (< pos (length node-name)) (string-match re node-name pos))
+ (setq node-name (concat (substring node-name 0 (match-beginning 0))
+ "@" (cdr (assoc-string (match-string 0
node-name) map))
+ "{}"
+ (substring node-name (match-end 0)))
+ pos (1+ (match-beginning 0)))))
+ node-name)
+
+
+(defun Texinfo-make-node-list (&optional nodes)
+ ;; Build list of nodes in current buffer.
+ ;; (What about using `imenu--index-alist'?)
+ ;; FIXME: Support multi-file documents.
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "address@hidden" nil t)
+ (skip-chars-forward "[:blank:]")
+ (pushnew (list (Texinfo-nodename-de-escape
+ (buffer-substring-no-properties
+ (point) (progn (skip-chars-forward "^\r\n,")
+ (skip-chars-backward "[:blank:]")
+ (point)))))
+ nodes :test #'equal)))
+ nodes)
+
(defun Texinfo-insert-node ()
"Insert a Texinfo node in the current buffer.
That means, insert the string address@hidden' and prompt for current,
@@ -299,26 +343,20 @@ a comment on the following line indicating the order of
arguments
for @node."
(interactive)
(let ((active-mark (and (TeX-active-mark) (not (eq (mark) (point)))))
- nodes node-name next-node previous-node up-node)
- ;; Build list of nodes in current buffer.
- ;; (What about using `imenu--index-alist'?)
- ;; FIXME: Support multi-file documents.
- (save-excursion
- (goto-char (point-min))
- (while (re-search-forward "address@hidden" nil t)
- (skip-chars-forward " \t")
- (pushnew (list (buffer-substring-no-properties
- (point) (progn (skip-chars-forward "^,")
- (point))))
- nodes :test #'equal)))
+ (nodes (Texinfo-make-node-list))
+ node-name next-node previous-node up-node)
(unless active-mark
- (setq node-name (TeX-read-string "Node name: ")))
+ (setq node-name (Texinfo-nodename-escape
+ (TeX-read-string "Node name: "))))
;; FIXME: What if key binding for `minibuffer-complete' was changed?
;; `substitute-command-keys' doesn't return the correct value.
- (setq next-node (completing-read "Next node (TAB completes): " nodes))
+ (setq next-node (Texinfo-nodename-escape
+ (completing-read "Next node (TAB completes): " nodes)))
(setq previous-node
- (completing-read "Previous node (TAB completes): " nodes))
- (setq up-node (completing-read "Upper node (TAB completes): " nodes))
+ (Texinfo-nodename-escape
+ (completing-read "Previous node (TAB completes): " nodes)))
+ (setq up-node (Texinfo-nodename-escape
+ (completing-read "Upper node (TAB completes): " nodes)))
(when (and active-mark
(< (mark) (point)))
(exchange-point-and-mark))
@@ -344,6 +382,18 @@ for @node."
(progn (skip-chars-forward "^,") (forward-char 2))
(throw 'break nil)))))))
+(defun Texinfo-arg-nodename (optional &optional prompt definition)
+ "Prompt for a node name completing with known node names.
+OPTIONAL is ignored.
+Use PROMPT as the prompt string.
+If DEFINITION is non-nil, then chosen node name is a node name to be
+added to the list of defined node names. Current implementation
+ignored DEFINITION as the full document is scanned for node names at
+each invocation."
+ (let ((node-name (completing-read (TeX-argument-prompt optional prompt "Key")
+ (Texinfo-make-node-list))))
+ (insert "{" (Texinfo-nodename-escape node-name) "}" )))
+
;; Silence the byte-compiler from warnings for variables and functions declared
;; in reftex.
(defvar reftex-section-levels-all)
@@ -664,7 +714,10 @@ value of `Texinfo-mode-hook'."
'("findex" (TeX-arg-literal " ") (TeX-arg-free "Entry"))
'("footnote" "Text of footnote")
'("footnotestyle" (TeX-arg-literal " ") (TeX-arg-free "Style"))
- '("group")
+ '("guillemetleft")
+ '("guillemetright")
+ '("guilsinglleft")
+ '("guilsinglright")
'("heading" (TeX-arg-literal " ") (TeX-arg-free "Title"))
;; XXX: Would be nice with completion.
'("headings" (TeX-arg-literal " ") (TeX-arg-free "On off single double"))
@@ -695,10 +748,12 @@ value of `Texinfo-mode-hook'."
'("point" nil)
'("print")
'("printindex" (TeX-arg-literal " ") (TeX-arg-free "Index name"))
- '("pxref" "Node name")
+ '("pxref" (Texinfo-arg-nodename "Node name"))
+ '("quotedblbase")
+ '("quotesinglbase")
'("r" "Text")
'("raisesections" 0)
- '("ref" "Node name")
+ '("ref" (Texinfo-arg-nodename "Node name"))
'("refill")
'("result")
'("samp" "Text")
@@ -745,7 +800,7 @@ value of `Texinfo-mode-hook'."
'("vindex" (TeX-arg-literal " ") (TeX-arg-free "Entry"))
'("vskip" (TeX-arg-literal " ") (TeX-arg-free "Amount"))
'("w" "Text")
- '("xref" "Node name"))
+ '("xref" (Texinfo-arg-nodename "Node name")))
;; RefTeX plugging
(add-hook 'reftex-mode-hook 'Texinfo-reftex-hook)
- [elpa] externals/auctex updated (35a4cfc -> 7363de1), Tassilo Horn, 2015/11/13
- [elpa] externals/auctex b10ca71 01/26: Fix docstring., Tassilo Horn, 2015/11/13
- [elpa] externals/auctex 90ea1a0 02/26: Remove SmallCaps font declaration command., Tassilo Horn, 2015/11/13
- [elpa] externals/auctex dbeb71f 04/26: Improve style., Tassilo Horn, 2015/11/13
- [elpa] externals/auctex b4f95f9 07/26: Disable special filling of math constructs, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex 6351078 09/26: Use LaTeX-style-list for default classes completion., Tassilo Horn, 2015/11/13
- [elpa] externals/auctex 9dba8fd 15/26: Make View command work no matter how emacs started, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex c39c63f 13/26: Add new style hologo.el., Tassilo Horn, 2015/11/13
- [elpa] externals/auctex d56502e 05/26: Support node name completion in texinfo,
Tassilo Horn <=
- [elpa] externals/auctex a2f8bc6 08/26: Fix Texinfo-make-node-list, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex 52275f9 03/26: Improve style., Tassilo Horn, 2015/11/13
- [elpa] externals/auctex b3153ec 16/26: Add function for reverting document buffer, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex 4527e8a 10/26: Update documentation., Tassilo Horn, 2015/11/13
- [elpa] externals/auctex f52479b 11/26: Improve checking of a TeX distribution and make it optional, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex fb09c26 06/26: Warn about duplicate texinfo nodes, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex a4c6a19 21/26: Update release-related Makefile rules, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex cb4e33e 12/26: Set output extension for Texinfo files, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex d465076 22/26: Update for upcoming release, Tassilo Horn, 2015/11/13
- [elpa] externals/auctex 5179308 18/26: Change default value of LaTeX-fill-break-at-separators, Tassilo Horn, 2015/11/13