Discussion:
beamer: completion for \usetheme and \usecolortheme
Reiner Steib
2005-03-01 21:32:26 UTC
Permalink
Hi,

unless there is objection, I intent to commit completion for \usetheme
and \usecolortheme to `style/beamer.el' (TeX-arg-beamer-*theme) and
`latex.el' (the variables `LaTeX-beamer-*themes') tomorrow. Below
you'll find a draft version (I will convert the defvars into
defcustoms later).

I guess there is no way to create the list of themes via
`TeX-search-files' (the LaTeX files are called beamertheme*.sty and
beamercolortheme*.sty). Or am I missing something?

(defvar LaTeX-beamer-themes '("Antibes"
"Bergen"
[...]
"Szeged"
"Warsaw"
"boxes"
"default")
"Beamer themes.")

(defvar LaTeX-beamer-colorthemes '("albatross"
"beetle"
[...]
"structure"
"whale")
"Beamer color themes.")

(defun TeX-arg-beamer-theme (optional &optional prompt)
"Prompt for beamer theme with completion."
(TeX-argument-insert
(completing-read
(TeX-argument-prompt optional prompt "Theme")
(mapcar 'list LaTeX-beamer-themes)
nil nil nil)
optional))

(defun TeX-arg-beamer-colortheme (optional &optional prompt)
"Prompt for beamer color theme with completion."
(TeX-argument-insert
(completing-read
(TeX-argument-prompt optional prompt "Theme")
(mapcar 'list LaTeX-beamer-colorthemes)
nil nil nil)
optional))

Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
Masayuki Ataka
2005-03-01 23:37:55 UTC
Permalink
From: Reiner Steib <reinersteib+***@imap.cc>
Subject: beamer: completion for \usetheme and \usecolortheme
Date: Tue, 01 Mar 2005 22:32:26 +0100

Hi, I love beamer, too.
Post by Reiner Steib
unless there is objection, I intent to commit completion for \usetheme
and \usecolortheme to `style/beamer.el' (TeX-arg-beamer-*theme) and
`latex.el' (the variables `LaTeX-beamer-*themes') tomorrow. Below
you'll find a draft version (I will convert the defvars into
defcustoms later).
I guess there is no way to create the list of themes via
`TeX-search-files' (the LaTeX files are called beamertheme*.sty and
beamercolortheme*.sty). Or am I missing something?
This is a quick hack, but we can get the list of beamer's theme name.

(delete nil
(mapcar (lambda (file) (and (numberp (string-match "^beamertheme" file))
(substring file (string-width "beamertheme"))))
(TeX-search-files nil '("tex" "sty") t t)))

We can get beamercolotheme*, beamerfonttheme*, beameroutertheme*, and so forth.
(Maybe, we should remove themes which start small letter
from list of themes, because they are still available only
for backward compatibility.)


If "beamer.cls" is in `/ush/share/texmf/tex/latex/beamer/base/',
then beamer theme files would be in "../themes/theme"
(relative path from `beamer.cls').

So, if we know where "beamer.cls" is, we can specify
second optional argument of `TeX-search-files'.
For example,

(let ((dir (Foo-search-class-file "beamer.cls")))
(setq dir (expand-file-name "../" (file-name-directory dir)))
(TeX-search-files dir '("tex" "sty") t t))

Oh, I don't know Foo-search-class-file is exist Xp

best,
---
email: ***@milk.freemail.ne.jp
Name:: Masayuki Ataka // (Japan)
Reiner Steib
2005-03-03 15:52:20 UTC
Permalink
Post by Masayuki Ataka
This is a quick hack, but we can get the list of beamer's theme name.
[...]

Thanks. Below[1] is my version `LaTeX-beamer-search-themes' based on
your suggestion.
Post by Masayuki Ataka
We can get beamercolotheme*, beamerfonttheme*, beameroutertheme*,
and so forth. (Maybe, we should remove themes which start small
letter from list of themes, because they are still available only
for backward compatibility.)
ACK. See the results[2] of calling `LaTeX-beamer-search-themes' with
various arguments.
Post by Masayuki Ataka
If "beamer.cls" is in `/ush/share/texmf/tex/latex/beamer/base/',
then beamer theme files would be in "../themes/theme"
(relative path from `beamer.cls').
I think the user can also put his on beamer*theme.sty files in his
texmf tree (or in TEXINPUTS).

When I added completion for \includegraphics{}, some people complained
that such a completion function is too slow for them. Therefore I'd
like to make the completion customizable:

(defcustom LaTeX-beamer-themes 'LaTeX-beamer-search-themes
"Presentation themes for the LaTeX beamer package.
It can be a list of themes or a function. If it is the symbol
`once' search only once per Emacs session."
:group 'LaTeX-macro
:type '(choice (const :tag "TeX search" LaTeX-beamer-search-themes)
(const :tag "Search once per session" 'once)
(function :tag "Other function")
(list (set :inline t
(const "Antibes")
(const "Bergen")
;; [...]
(const "Szeged")
(const "Warsaw"))
(repeat :inline t
:tag "Other"
(string)))))

But when I choose "List" from the value menu in customize, I get:
"invalid ((nil nil))". What am I doing wrong?

Bye, Reiner.

[1]
(defun LaTeX-beamer-search-themes (&optional regexp extensions length)
"Search for beamer themes matching REGEXP with EXTENSIONS.
The function removes the first LENGTH characters and the
extension of the file and returns a list of strings. LENGTH may
also be a string. Then the length of the string is used."
(let* ((match (or regexp "^beamertheme[A-Z]"))
(exts (or extensions '("tex" "sty")))
(chars (cond ((integerp length)
length)
((stringp length)
(string-width length))
;; Try some DWIM magic...
((and (not length)
(string-match "beamer[A-Za-z0-9]*theme" match))
(- (match-end 0) (match-beginning 0)))
(t (error "Invalid length")))))
;; (message "match=`%s' chars=`%s'" match chars)
(TeX-delete-duplicate-strings
(delete nil
(mapcar
(lambda (file)
(let ((case-fold-search nil))
(and (numberp (string-match match file))
(substring file chars))))
(TeX-search-files nil exts t t))))))

[2]
ELISP> (LaTeX-beamer-search-themes "^beamertheme[A-Z]")
("Antibes" "Bergen" "Berkeley" "Berlin" "Boadilla" "Copenhagen"
"Darmstadt" "Dresden" "Frankfurt" "Goettingen" "Hannover" "Ilmenau"
"JuanLesPins" "Luebeck" "Madrid" "Malmoe" "Marburg" "Montpellier"
"PaloAlto" "Pittsburgh" "Rochester" "Singapore" "Szeged" "Warsaw")

ELISP> (LaTeX-beamer-search-themes)
[ the same ]

ELISP> (LaTeX-beamer-search-themes "^beamerinnertheme")
("circles" "default" "inmargin" "rectangles" "rounded")

ELISP> (LaTeX-beamer-search-themes "^beameroutertheme")
("default" "infolines" "miniframes" "shadow" "sidebar" "smoothbars"
"smoothtree" "split" "tree")

ELISP> (LaTeX-beamer-search-themes "^beamercolortheme")
("albatross" "beetle" "crane" "default" "dolphin" "dove" "fly" "lily"
"orchid" "rose" "seagull" "seahorse" "sidebartab" "structure" "whale")

ELISP> (LaTeX-beamer-search-themes "^beamerfonttheme")
("default" "professionalfonts" "serif" "structurebold"
"structureitalicserif" "structuresmallcapsserif")
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
Ralf Angeli
2005-03-03 16:42:07 UTC
Permalink
Post by Reiner Steib
When I added completion for \includegraphics{}, some people complained
that such a completion function is too slow for them. Therefore I'd
(defcustom LaTeX-beamer-themes 'LaTeX-beamer-search-themes
[...]
Post by Reiner Steib
"invalid ((nil nil))". What am I doing wrong?
Does the following definition do what you want?

(defcustom LaTeX-beamer-themes 'LaTeX-beamer-search-themes
"Presentation themes for the LaTeX beamer package.
It can be a list of themes or a function. If it is the symbol
`once' search only once per Emacs session."
:group 'LaTeX-macro
:type '(choice (const :tag "TeX search" LaTeX-beamer-search-themes)
(const :tag "Search once per session" 'once)
(function :tag "Other function")
(repeat :tag "List"
:value ("Antibes" "Bergen" "Szeged" "Warsaw")
(string))))
--
Ralf
Reiner Steib
2005-03-03 19:12:26 UTC
Permalink
Post by Ralf Angeli
Does the following definition do what you want?
[...]
Post by Ralf Angeli
(repeat :tag "List"
:value ("Antibes" "Bergen" "Szeged" "Warsaw")
(string))))
It doesn't offer the nice check-boxes:

,----
| LaTeX-beamer-themes: Hide Value Value Menu List:
| Set:
| [X] Antibes
| [X] Bergen
| [X] Szeged
| [X] Warsaw
| Other:
|[...]
`----

Hm, it works when selecting "List" two times in a row (both in Emacs
CVS and in 21.4). Looks like a bug in customize, doesn't it? To
reproduce:

(1) Create a file /tmp/cus-test.el:

--8<---------------cut here---------------start------------->8---
(defcustom my-test 'foo-bar
"Foo bar"
:group 'LaTeX-macro
:type '(choice (const :tag "TeX search" foo-bar)
(function :tag "Other function")
(list (set :inline t
(const "Antibes")
(const "Warsaw"))
(repeat :inline t
:tag "Other"
(string)))))
(customize-variable 'my-test)
--8<---------------cut here---------------end--------------->8---

(2) emacs -q -no-site-file -l /tmp/cus-test.el

(3) Select "Value menu" -> "List":

,----
| My Test: Hide Value Value Menu invalid ((nil nil))
| State: EDITED, shown value does not take effect until you set or save it.
|
| Foo bar
| Parent groups: Latex Macro
`----

(4) Select "Value menu" -> "List" again:

,----
| My Test: Hide Value Value Menu List:
| Set:
| [ ] Antibes
| [ ] Warsaw
| Other:
| INS
| State: EDITED, shown value does not take effect until you set or save it.
|
| Foo bar
| Parent groups: Latex Macro
`----

I'll file a bug report.

Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
Masayuki Ataka
2005-03-04 01:48:44 UTC
Permalink
From: Reiner Steib <reinersteib+***@imap.cc>
Subject: Re: beamer: completion for \usetheme and \usecolortheme
Date: Thu, 03 Mar 2005 16:52:20 +0100
Post by Reiner Steib
Post by Masayuki Ataka
This is a quick hack, but we can get the list of beamer's theme name.
[...]
Thanks. Below[1] is my version `LaTeX-beamer-search-themes' based on
your suggestion.
Brilliant!
Post by Reiner Steib
Post by Masayuki Ataka
We can get beamercolotheme*, beamerfonttheme*, beameroutertheme*,
and so forth. (Maybe, we should remove themes which start small
letter from list of themes, because they are still available only
for backward compatibility.)
ACK. See the results[2] of calling `LaTeX-beamer-search-themes' with
various arguments.
Of course, you would prepare variables
`LaTeX-beamer-colortheme', etc...?
Post by Reiner Steib
Post by Masayuki Ataka
If "beamer.cls" is in `/ush/share/texmf/tex/latex/beamer/base/',
then beamer theme files would be in "../themes/theme"
(relative path from `beamer.cls').
I think the user can also put his on beamer*theme.sty files in his
texmf tree (or in TEXINPUTS).
Yes, you are right. And when the beamer's path structure is
changed, such a relative path will confuse the user (and even us).
It's a bad idea. Forget it.
Post by Reiner Steib
When I added completion for \includegraphics{}, some people complained
that such a completion function is too slow for them. Therefore I'd
I felt it slow, too ;)

---
email: ***@milk.freemail.ne.jp
Name:: Masayuki Ataka // (Japan)
Reiner Steib
2005-03-04 09:07:51 UTC
Permalink
[...]
Post by Reiner Steib
See the results[2] of calling `LaTeX-beamer-search-themes' with
various arguments.
Of course, you would prepare variables `LaTeX-beamer-colortheme',
etc...?
Yes. Probably first only for \usetheme and \usecolortheme then (after
checking this in and some testing) for the other \use*theme macros.

Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
Reiner Steib
2005-03-04 18:12:42 UTC
Permalink
Post by Reiner Steib
Of course, you would prepare variables `LaTeX-beamer-colortheme',
etc...?
Yes. Probably first only for \usetheme and \usecolortheme then (after
checking this in and some testing) for the other \use*theme macros.
I checked in completion for \usetheme. Feedback welcome.

If it is okay, we can add similar support for
\use{inner,outer,color,font}theme.

Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
Davide G. M. Salvetti
2005-03-02 11:31:56 UTC
Permalink
RS == Reiner Steib [2005-3-1]
RS> Hi, unless there is objection, I intent to commit completion for
RS> \usetheme and \usecolortheme to `style/beamer.el'
RS> (TeX-arg-beamer-*theme) and `latex.el' (the variables
RS> `LaTeX-beamer-*themes') tomorrow. Below you'll find a draft version
RS> (I will convert the defvars into defcustoms later).

I don't know how easy is to fix it, but perhaps you might want to
consider this user request, while you are at it:
<http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=290635>.

Of course I'm far from pushing for you to do this work, I just thought
that a reminder about this request could be useful to people working on
"sytle/beamer.el".
--
Thanks, Davide
Loading...