[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [AUCTeX-devel] Completion for saveboxes
From: |
Mosè Giordano |
Subject: |
Re: [AUCTeX-devel] Completion for saveboxes |
Date: |
Wed, 16 Jan 2013 10:13:38 +0100 |
Hi Mads,
there are some errors in your patch.
> +;; `sbox' is just a short form of `savebox'
> +(defvar LaTeX-auto-savebox-regexp-list
> + '(("\\\\newsavebox *{\\([A-Za-z]+\\)}" 1 LaTeX-auto-savebox))
> + "List of regular expressions matching LaTeX saveboxes and
> +sboxes only.")
This regexep wouldn't match any savebox because saveboxes are macros,
so their name starts with a backslash. I suggest to use the following
regexp
---------------------------------------------------------------------
(defvar LaTeX-auto-savebox-regexp-list
'(("\\\\newsavebox *{?\\\\\\([A-Za-z]+\\)}?" 1 LaTeX-auto-savebox))
---------------------------------------------------------------------
> +(TeX-auto-add-type "savebox" "LaTeX")
You have to specify the plural of the type if it's not formed just
appending an "s":
-------------------------------------------------
(TeX-auto-add-type "savebox" "LaTeX" "saveboxes")
-------------------------------------------------
> -;; Why is DEFINITION unused?
> (defun TeX-arg-savebox (optional &optional prompt definition)
> "Prompt for a LaTeX savebox.
> If OPTIONAL is non-nil, insert the resulting value as an optional
> argument, otherwise as a mandatory one. Use PROMPT as the prompt
> -string. DEFINITION is unused."
> - ;; Completion not implemented yet.
> - (TeX-argument-insert
> - (read-string (TeX-argument-prompt optional prompt
> - (concat "Savebox: " TeX-esc)
> - t))
> - optional TeX-esc))
> +string. If definition is non-nil, the savebox is added to the
> +list of defined saveboxes."
> + (let ((savebox ((completing-read (TeX-argument-prompt optional prompt
> + "Savebox")
> + (LaTeX-savebox-list)))))
> + (if (add definition (not (zerop (length savebox))))
> + (LaTeX-add-saveboxes savebox))
> + (TeX-argument-insert savebox optional)))
> +
Completing-read function is malformed, there one extra pair of
parentheses, moreover `TeX-argument-insert' should add also a
`TeX-esc':
--------------------------------------------------------------------------
(defun TeX-arg-savebox (optional &optional prompt definition)
"Prompt for a LaTeX savebox.
If OPTIONAL is non-nil, insert the resulting value as an optional
argument, otherwise as a mandatory one. Use PROMPT as the prompt
string. If definition is non-nil, the savebox is added to the
list of defined saveboxes."
(let ((savebox (completing-read (TeX-argument-prompt optional prompt
(concat "Savebox: "
TeX-esc) t)
(LaTeX-savebox-list))))
(if (and definition (not (zerop (length savebox))))
(LaTeX-add-saveboxes savebox))
(TeX-argument-insert savebox optional TeX-esc)))
--------------------------------------------------------------------------
Bye,
Mosè Giordano