auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. d56502e7dcba118c62d38


From: Tassilo Horn
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. d56502e7dcba118c62d38f6fe2f5a855834e6816
Date: Mon, 26 Oct 2015 08:24:40 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  d56502e7dcba118c62d38f6fe2f5a855834e6816 (commit)
      from  dbeb71fcb1c1922819cfc7671dc3e9522939796a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d56502e7dcba118c62d38f6fe2f5a855834e6816
Author: Vincent Belaïche <address@hidden>
Date:   Mon Oct 26 09:21:49 2015 +0100

    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>

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)

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog   |   20 ++++++++++++
 tex-info.el |   95 ++++++++++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 95 insertions(+), 20 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

[Prev in Thread] Current Thread [Next in Thread]