[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] [elpa] externals/auctex 6c155cc 33/57: Refactor normal co
From: |
Tassilo Horn |
Subject: |
[AUCTeX-diffs] [elpa] externals/auctex 6c155cc 33/57: Refactor normal completion and completion at point a bit |
Date: |
Wed, 11 Jan 2017 18:01:40 +0000 (UTC) |
branch: externals/auctex
commit 6c155cce834313a2b9a7529c9c89fd4f44d6c1f8
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>
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.
---
tex.el | 131 ++++++++++++++++++++++++++++++++--------------------------------
1 file changed, 65 insertions(+), 66 deletions(-)
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'."
- [AUCTeX-diffs] [elpa] externals/auctex c541d75 20/57: Fix the names also in expert macros, (continued)
- [AUCTeX-diffs] [elpa] externals/auctex c541d75 20/57: Fix the names also in expert macros, Tassilo Horn, 2017/01/11
- [AUCTeX-diffs] [elpa] externals/auctex 377a97a 32/57: Completion for math macros, Tassilo Horn, 2017/01/11
- [AUCTeX-diffs] [elpa] externals/auctex 3a5ed08 38/57: Support biblatex cite format in all Emacsen, Tassilo Horn, 2017/01/11
- [AUCTeX-diffs] [elpa] externals/auctex 4c59f77 42/57: Adapt Makefile to new ChangeLog file name, Tassilo Horn, 2017/01/11
- [AUCTeX-diffs] [elpa] externals/auctex d185bcb 49/57: * Makefile.in (release-commit): Fix name of preview ChangeLog., Tassilo Horn, 2017/01/11
- [AUCTeX-diffs] [elpa] externals/auctex 74c5ac9 09/57: Update style/tcolorbox.el to package v3.96, Tassilo Horn, 2017/01/11
- [AUCTeX-diffs] [elpa] externals/auctex 501b0de 47/57: Use RefTeX for multiple references in cleveref, Tassilo Horn, 2017/01/11
- [AUCTeX-diffs] [elpa] externals/auctex fb6333b 45/57: ; * doc/install.texi (Installation): Guard reference in "@ifclear rawfile"., Tassilo Horn, 2017/01/11
- [AUCTeX-diffs] [elpa] externals/auctex 826f17a 54/57: Release_11.90, Tassilo Horn, 2017/01/11
- [AUCTeX-diffs] [elpa] externals/auctex 7209776 46/57: Skip macros and environments from tcolorbox and raster library, Tassilo Horn, 2017/01/11
- [AUCTeX-diffs] [elpa] externals/auctex 6c155cc 33/57: Refactor normal completion and completion at point a bit,
Tassilo Horn <=
- [AUCTeX-diffs] [elpa] externals/auctex a9ec6ba 01/57: Update style/minted.el to package version 2.4.1., Tassilo Horn, 2017/01/11
- [AUCTeX-diffs] [elpa] externals/auctex 67c081d 53/57: ; make change-history-commit, Tassilo Horn, 2017/01/11