Stefan Monnier <[email protected]> writes:

> I can't see any relevant change in the last 10 years, so I don't
> understand either.
> But given the behavior I see from your function, the "new" behavior
> looks right to me, so it may be the result of a bug fix somewhere.

Thanks, so I should adapt AUCTeX to it.  My current solution looks like
this: We recognize the backlash as boundary with

  (skip-chars-forward "^a-zA-Z0-9\\\\" end)

and add ":exclusive no" to the returned list.  So if
`LaTeX--arguments-completion-at-point' fails, it will pass the job to
`TeX--completion-at-point'.  Simple test case is (* indicates point):

  \setlength{\textwidth}{3\*}

--8<---------------cut here---------------start------------->8---
diff --git a/latex.el b/latex.el
index 9973c1a4..e8e47357 100644
--- a/latex.el
+++ b/latex.el
@@ -7622,8 +7622,8 @@ See its doc string for detail.")
 ;; completion at point when inside a macro or environment argument.
 ;; The general idea is:
 ;;
-;; - Find out in which argument of macro/env the point is; this is
-;; done by the function `LaTeX-what-macro'.
+;; - Find out in which argument of macro/env point is; this is done by
+;; the function `LaTeX-what-macro'.
 ;;
 ;; - Match the result against the information available in
 ;; `TeX-symbol-list' or `LaTeX-environment-list' by the function
@@ -7656,14 +7656,11 @@ If the optional WHICH is the symbol `open', return the 
car's of
 each element in the variable `LaTeX-completion-macro-delimiters'.
 If it is the symbol `close', return the cdr's.  If omitted or
 nil, return all elements."
-  (cond ((eq which 'open)
-         (mapcar #'car LaTeX-completion-macro-delimiters))
-        ((eq which 'close)
-         (mapcar #'cdr LaTeX-completion-macro-delimiters))
-        (t
-         (append
-          (mapcar #'car LaTeX-completion-macro-delimiters)
-          (mapcar #'cdr LaTeX-completion-macro-delimiters)))))
+  (pcase which
+    ('open  (mapcar #'car LaTeX-completion-macro-delimiters))
+    ('close (mapcar #'cdr LaTeX-completion-macro-delimiters))
+    (_      (append (mapcar #'car LaTeX-completion-macro-delimiters)
+                    (mapcar #'cdr LaTeX-completion-macro-delimiters)))))

 (defun LaTeX-move-to-previous-arg (&optional bound)
   "Move backward to the closing parenthesis of the previous argument.
@@ -7859,11 +7856,9 @@ COLLECTION is an list of strings."
                                 (LaTeX-completion-macro-delimiters))
         (up-list -1))
       (forward-char)
-      (skip-chars-forward "^a-zA-Z0-9" end)
+      (skip-chars-forward "^a-zA-Z0-9\\\\" end)
       (setq beg (point)))
-    (list beg end (completion-table-dynamic
-                   (lambda (_)
-                     collection)))))
+    (list beg end collection :exclusive 'no)))

 (defun LaTeX-completion-documentclass-usepackage (entry)
   "Return completion candidates for \\usepackage and \\documentclass arguments.
@@ -8163,7 +8158,7 @@ taken."
 (defun LaTeX--arguments-completion-at-point ()
   "Capf for arguments of LaTeX macros and environments.
 Completion for macros starting with `\\' is provided by the
-function `TeX--completion-at-point' which should come first in
+function `TeX--completion-at-point' which should come later in
 `completion-at-point-functions'."
   ;; Exit if not inside an argument or in a comment:
   (when (and (LaTeX-completion-find-argument-boundaries)
@@ -8539,10 +8534,10 @@ function would return non-nil and `(match-string 1)' 
would return
   ;; Moved after `run-mode-hooks'. (bug#65750)
   ;; (LaTeX-indent-commands-regexp-make)

-  ;; Standard Emacs completion-at-point support.  We append the entry
-  ;; in order to let `TeX--completion-at-point' be first in the list:
+  ;; Standard Emacs completion-at-point support.  We prepend the entry
+  ;; in order to let `TeX--completion-at-point' be next in the list:
   (add-hook 'completion-at-point-functions
-            #'LaTeX--arguments-completion-at-point 5 t)
+            #'LaTeX--arguments-completion-at-point nil t)

   (setq-local LaTeX-item-list '(("description" . LaTeX-item-argument)
                                 ("thebibliography" . LaTeX-item-bib)
--8<---------------cut here---------------end--------------->8---

Best, Arash

Reply via email to