auctex-devel
[Top][All Lists]
Advanced

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

`y-or-n-p' in `TeX-arg-conditional' during in-buffer completion


From: Arash Esbati
Subject: `y-or-n-p' in `TeX-arg-conditional' during in-buffer completion
Date: Thu, 22 Dec 2022 21:18:58 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50

Hi all,

some AUCTeX styles use `y-or-n-p' with `TeX-arg-conditional' to ask if
they should add more optional arguments, see titlesec.el for example.
When applying in-buffer completion, this query is also evaluated.  I'd
like to add this piece of code to `LaTeX-completion-parse-args' which
silences this, but also fails for hyperref.el.  Any comments?

--8<---------------cut here---------------start------------->8---
diff --git a/latex.el b/latex.el
index 81db2e76..3676e59d 100644
--- a/latex.el
+++ b/latex.el
@@ -7565,17 +7565,22 @@ or `LaTeX-environment-list' and returns it."
       (pop arg-list))

     ;; Check for `TeX-arg-conditional' here and change `arg-list'
-    ;; accordingly
+    ;; accordingly.
+    ;; FIXME: Turn `y-or-n-p' into `always' otherwise there will be a
+    ;; query during in-buffer completion.  This will work for most
+    ;; cases, but will also fail for example in hyperref.el.  This
+    ;; decision should revisited at a later stage:
     (when (assq 'TeX-arg-conditional arg-list)
-      (while (and arg-list
-                  (setq arg (car arg-list)))
-        (if (and (listp arg) (eq (car arg) 'TeX-arg-conditional))
-            (setq result (append (reverse (if (eval (nth 1 arg) t)
-                                              (nth 2 arg)
-                                            (nth 3 arg)))
-                                 result))
-          (push arg result))
-        (pop arg-list))
+      (cl-letf (((symbol-function 'y-or-n-p) #'always))
+        (while (and arg-list
+                    (setq arg (car arg-list)))
+          (if (and (listp arg) (eq (car arg) 'TeX-arg-conditional))
+              (setq result (append (reverse (if (eval (nth 1 arg) t)
+                                                (nth 2 arg)
+                                              (nth 3 arg)))
+                                   result))
+            (push arg result))
+          (pop arg-list)))
       (setq arg-list (nreverse result)))

     ;; Now parse the `arg-list':
--8<---------------cut here---------------end--------------->8---

Best, Arash



reply via email to

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