auctex-devel
[Top][All Lists]
Advanced

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

Query for environment to include in `LaTeX-env-figure'


From: Arash Esbati
Subject: Query for environment to include in `LaTeX-env-figure'
Date: Sun, 19 Dec 2021 23:07:04 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50

Hi all,

when inserting a table environment with 'C-c C-e table RET',
`LaTeX-env-figure' inserts the floating environment 'table' and then
inserts the tabular environment stored in
`LaTeX-default-tabular-environment' (the relevant part starts here[1]).

I like the idea, but `LaTeX-default-tabular-environment' is notoriously
the one I currently don't want.  Should we change this part a little in
order to give users a chance to pick up what they want?  I'm thinking
about a change like this:

--8<---------------cut here---------------start------------->8---
diff --git a/latex.el b/latex.el
index 6d255591..beb65b91 100644
--- a/latex.el
+++ b/latex.el
@@ -1253,7 +1253,22 @@ If SHORT-CAPTION is non-nil pass it as an optional 
argument to
                ;; Suppose an existing tabular environment should just
                ;; be wrapped into a table if there is an active region.
                (not active-mark))
-      (LaTeX-environment-menu LaTeX-default-tabular-environment))))
+      (LaTeX-environment-menu
+       (completing-read
+        (TeX-argument-prompt nil nil
+                             (concat
+                              "Tabular environment to insert (default "
+                              LaTeX-default-tabular-environment
+                              ")"))
+        (let (result)
+          (dolist (env (mapcar #'car (LaTeX-environment-list)) result)
+            (when (string-match (concat
+                                 "\\`tabular"
+                                 "\\|"
+                                 "\\(tabular\\|[a-zA-Z]+tables?\\)\\*?\\'")
+                                env)
+              (push env result))))
+        nil nil nil nil LaTeX-default-tabular-environment)))))
--8<---------------cut here---------------end--------------->8---

Over the time, we have to adjust the regexp, but it should get us
started.  Any comments welcome.

Best, Arash

Footnotes:
[1]  http://git.savannah.gnu.org/cgit/auctex.git/tree/latex.el#n1252



reply via email to

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