auctex-devel
[Top][All Lists]
Advanced

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

latex.el: completing-read and REQUIRE-MATCH


From: Arash Esbati
Subject: latex.el: completing-read and REQUIRE-MATCH
Date: Fri, 14 Jul 2023 23:08:02 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Hi all,

I see 3 functions in latex.el where the 4th argument of
`completing-read' REQUIRE-MATCH is set to t:

--8<---------------cut here---------------start------------->8---
(defun TeX-arg-corner (optional &optional prompt)
  "Prompt for a LaTeX side or corner position with completion.
If OPTIONAL is non-nil, insert the resulting value as an optional
argument, otherwise as a mandatory one.  Use PROMPT as the prompt
string."
  (TeX-argument-insert
   (completing-read (TeX-argument-prompt optional prompt "Position")
                    '("l" "r" "t" "b" "tl" "tr" "bl" "br")
                    nil t)
   optional))

(defun TeX-arg-lr (optional &optional prompt)
  "Prompt for a LaTeX side with completion.
If OPTIONAL is non-nil, insert the resulting value as an optional
argument, otherwise as a mandatory one.  Use PROMPT as the prompt
string."
  (TeX-argument-insert
   (completing-read (TeX-argument-prompt optional prompt "Position")
                    '("l" "r")
                    nil t)
   optional))

(defun TeX-arg-tb (optional &optional prompt poslist)
  "Prompt for a LaTeX side with completion.
If OPTIONAL is non-nil, insert the resulting value as an optional
argument, otherwise as a mandatory one.  Use PROMPT as the prompt
string.  POSLIST contains the positioning characters offered for
completion.  It can be the symbols `center', `stretch' or nil
with the following completion list:
  center   t, b, c
  stretch  t, b, c, s
  nil      t, b"
  (TeX-argument-insert
   (completing-read (TeX-argument-prompt optional prompt "Position")
                    (cond ((eq poslist 'center)
                           '("t" "b" "c"))
                          ((eq poslist 'stretch)
                           '("t" "b" "c" "s"))
                          (t
                           '("t" "b")))
                    nil t)
   optional))
--8<---------------cut here---------------end--------------->8---

This is uncommon compared to other functions we have and also is
annoying if you're using vertico.el for instance: vertico obeys the
REQUIRE-MATCH arg and selects the first elements of the COLLECTION
automatically.  If you're used to hit RET, then this element is also
selected and inserted into the buffer, regardless if it is an optional
one.  One could circumvent this by hitting 'M-RET' in the minibuffer,
but it is still annoying.  Any complaints if we remove the 'nil t' part
in the functions above?

Best, Arash

P.S. There is a typo in the docstring of `TeX-arg-tb' which I will fix.
'POSLIST contains' should read 'POSLIST controls'



reply via email to

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