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. 6c155cce834313a2b9a75


From: Tassilo Horn
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 6c155cce834313a2b9a7529c9c89fd4f44d6c1f8
Date: Wed, 4 Jan 2017 09:21:25 +0000 (UTC)

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  6c155cce834313a2b9a7529c9c89fd4f44d6c1f8 (commit)
      from  377a97a2434fab69bf9e91457de94ad33c09b548 (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 6c155cce834313a2b9a7529c9c89fd4f44d6c1f8
Author: Tassilo Horn <address@hidden>
Date:   Wed Jan 4 10:20:14 2017 +0100

    Refactor normal completion and completion at point a bit
    
    * tex.el (TeX--complete-find-entry): New function.
    (TeX-complete-symbol,TeX--completion-at-point): Use it.

diff --git a/tex.el b/tex.el
index 894e076..2eb8536 100644
--- a/tex.el
+++ b/tex.el
@@ -3155,81 +3155,80 @@ Or alternatively:
 0. Regexp matching the preceding text.
 1. Function to do the actual completion.")
 
-(defun TeX-complete-symbol ()
-  "Perform completion on TeX/LaTeX symbol preceding point."
-  (interactive "*")
+(defun TeX--complete-find-entry ()
+  "Return the first applicable entry of `TeX-complete-list'."
   (let ((list TeX-complete-list)
        entry)
     (while list
       (setq entry (car list)
            list (cdr list))
-      (if (if (functionp (car entry))
-             (funcall (car entry))
-           (TeX-looking-at-backward (car entry) 250))
-         (setq list nil)))
-    (if (numberp (nth 1 entry))
-       (let* ((sub (nth 1 entry))
-              (close (nth 3 entry))
-              (begin (match-beginning sub))
-              (end (match-end sub))
-              (pattern (TeX-match-buffer 0))
-              (symbol (buffer-substring begin end))
-              (list (funcall (nth 2 entry)))
-              (completion (try-completion symbol list))
-              (buf-name "*Completions*"))
-         (cond ((eq completion t)
-                (and close
-                     (not (looking-at (regexp-quote close)))
-                     (insert close))
-                (let ((window (get-buffer-window buf-name)))
-                  (when window (delete-window window))))
-               ((null completion)
-                (error "Can't find completion for \"%s\"" pattern))
-               ((not (string-equal symbol completion))
-                (delete-region begin end)
-                (insert completion)
-                (and close
-                     (eq (try-completion completion list) t)
-                     (not (looking-at (regexp-quote close)))
-                     (insert close))
-                (let ((window (get-buffer-window buf-name)))
-                  (when window (delete-window window))))
-               (t
-                (if (fboundp 'completion-in-region)
-                    (completion-in-region begin end
-                                          (all-completions symbol list nil))
-                  (message "Making completion list...")
-                  (let ((list (all-completions symbol list nil)))
-                    (with-output-to-temp-buffer buf-name
-                      (display-completion-list list)))
-                  (set-window-dedicated-p (get-buffer-window buf-name) 'soft)
-                  (message "Making completion list...done")))))
-      (funcall (nth 1 entry)))))
+      (when (if (functionp (car entry))
+               (funcall (car entry))
+             (TeX-looking-at-backward (car entry) 250))
+       (setq list nil)))
+    entry))
+
+(defun TeX-complete-symbol ()
+  "Perform completion on TeX/LaTeX symbol preceding point."
+  (interactive "*")
+  (let ((entry (TeX--complete-find-entry)))
+    (when entry
+      (if (numberp (nth 1 entry))
+         (let* ((sub (nth 1 entry))
+                (close (nth 3 entry))
+                (begin (match-beginning sub))
+                (end (match-end sub))
+                (pattern (TeX-match-buffer 0))
+                (symbol (buffer-substring begin end))
+                (list (funcall (nth 2 entry)))
+                (completion (try-completion symbol list))
+                (buf-name "*Completions*"))
+           (cond ((eq completion t)
+                  (and close
+                       (not (looking-at (regexp-quote close)))
+                       (insert close))
+                  (let ((window (get-buffer-window buf-name)))
+                    (when window (delete-window window))))
+                 ((null completion)
+                  (error "Can't find completion for \"%s\"" pattern))
+                 ((not (string-equal symbol completion))
+                  (delete-region begin end)
+                  (insert completion)
+                  (and close
+                       (eq (try-completion completion list) t)
+                       (not (looking-at (regexp-quote close)))
+                       (insert close))
+                  (let ((window (get-buffer-window buf-name)))
+                    (when window (delete-window window))))
+                 (t
+                  (if (fboundp 'completion-in-region)
+                      (completion-in-region begin end
+                                            (all-completions symbol list nil))
+                    (message "Making completion list...")
+                    (let ((list (all-completions symbol list nil)))
+                      (with-output-to-temp-buffer buf-name
+                        (display-completion-list list)))
+                    (set-window-dedicated-p (get-buffer-window buf-name) 'soft)
+                    (message "Making completion list...done")))))
+       (funcall (nth 1 entry))))))
 
 (defun TeX--completion-at-point ()
   "(La)TeX completion at point function.
 See `completion-at-point-functions'."
-  (let ((list TeX-complete-list)
-       entry)
-    (while list
-      (setq entry (car list)
-           list (cdr list))
-      (if (if (functionp (car entry))
-             (funcall (car entry))
-           (TeX-looking-at-backward (car entry) 250))
-         (setq list nil)))
-    (if (numberp (nth 1 entry))
-       (let* ((sub (nth 1 entry))
-              (begin (match-beginning sub))
-              (end (match-end sub))
-              (symbol (buffer-substring-no-properties begin end))
-              (list (funcall (nth 2 entry))))
-         (list begin end (all-completions symbol list)))
-      ;; We intentionally don't call the fallback completion functions because
-      ;; they do completion on their own and don't work too well with things
-      ;; like company-mode.  And the default function `ispell-complete-word'
-      ;; isn't so useful anyway.
-      nil)))
+  (let ((entry (TeX--complete-find-entry)))
+    (when entry
+      (if (numberp (nth 1 entry))
+         (let* ((sub (nth 1 entry))
+                (begin (match-beginning sub))
+                (end (match-end sub))
+                (symbol (buffer-substring-no-properties begin end))
+                (list (funcall (nth 2 entry))))
+           (list begin end (all-completions symbol list)))
+       ;; We intentionally don't call the fallback completion functions because
+       ;; they do completion on their own and don't work too well with things
+       ;; like company-mode.  And the default function `ispell-complete-word'
+       ;; isn't so useful anyway.
+       nil))))
 
 (defcustom TeX-default-macro "ref"
   "*The default macro when creating new ones with `TeX-insert-macro'."

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

Summary of changes:
 tex.el |  131 ++++++++++++++++++++++++++++++++--------------------------------
 1 file changed, 65 insertions(+), 66 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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