Hi all,

I think I'm almost done with updating beamer.el. The current state is
attached as a patch. Any comments and suggestions are welcome.

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine

>From 9c63c6d64099c25301975c36f7c044fdcb1ee6db Mon Sep 17 00:00:00 2001
From: Ikumi Keita <[email protected]>
Date: Thu, 8 Sep 2022 14:38:12 +0900
Subject: [PATCH] Enhance beamer support

* style/beamer.el (LaTeX-beamer-after-insert-env): Use `member'
instead of `TeX-member'.
Add comment.
(TeX-arg-beamer-overlay-spec): Simplify by feature implemented
recently in `TeX-arg-string'.
(TeX-arg-beamer-frametitle,TeX-arg-beamer-note): Delete.
(LaTeX-item-beamer): Accept optional argument for bibitem.
Simplify.
(LaTeX-bibitem-beamer): New function to use `LaTeX-item-beamer'.
(LaTeX-beamer-search-themes): Use `length' instead of `string-width'.
Use `substring-no-properties' instead of `substring'.
(LaTeX-beamer-env-frame): Factor out former lambda form into an
individual function.
(LaTeX-beamer-section): New function to insert section commands as
well as asking for their optional arguments.
("beamer"): Update support of section commands with the above new
function.
Add and improve input support for many macros and environments.
Highlight \institute and \framesubtitle commands.
(LaTeX-beamer-class-options): Update class options for current
beamer.
* style/beamerarticle.el ("beamerarticle"): Allow (sub)paragraph
commands.
---
 style/beamer.el        | 430 ++++++++++++++++++++++++++++++-----------
 style/beamerarticle.el |   6 +-
 2 files changed, 318 insertions(+), 118 deletions(-)

diff --git a/style/beamer.el b/style/beamer.el
index 589a26ad..6e1866e5 100644
--- a/style/beamer.el
+++ b/style/beamer.el
@@ -1,8 +1,9 @@
 ;;; beamer.el --- AUCTeX style for the latex-beamer class  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2003-2021  Free Software Foundation, Inc.
+;; Copyright (C) 2003-2022  Free Software Foundation, Inc.
 
 ;; Author: Thomas Baumann <[email protected]>
+;; Maintainer: [email protected]
 ;; Created: 2003-12-20
 ;; Keywords: tex
 
@@ -41,7 +42,7 @@
   "Do beamer-specific stuff after the insertion of an environment."
   ;; Add `fragile' as an optional argument to the frame environment if
   ;; a verbatim environment is inserted.
-  (when (and (TeX-member env (LaTeX-verbatim-environments) #'string-equal)
+  (when (and (member env (LaTeX-verbatim-environments))
              (save-excursion
                (goto-char start)
                (string-equal (LaTeX-current-environment) "frame")))
@@ -49,6 +50,7 @@
       (when (re-search-backward "\\\\begin[ \t]*{frame}" nil t)
         (let ((end-of-begin (match-end 0)))
           (goto-char end-of-begin)
+          ;; FIXME: Add support for skipping over overlay specs.
           (while (forward-comment 1))
           (if (eq (char-after) (string-to-char LaTeX-optop))
               (progn
@@ -70,16 +72,26 @@
    (TeX-run-style-hooks "amsmath" "amssymb" "amsthm" "color" "geometry"
                         "hyperref" "inputenc" "translator" "xcolor")
 
-   (unless LaTeX-beamer-section-labels-flag
-     (make-local-variable 'LaTeX-section-hook)
-     (setq LaTeX-section-hook
-           '(LaTeX-section-heading
-             LaTeX-section-title
-             LaTeX-section-section)))
+   (LaTeX-section-list-add-locally
+    '(("part" 0)
+      ("section" 1)
+      ("subsection" 2)
+      ("subsubsection" 3))
+    t)
+   (LaTeX-largest-level-set "part")
+   (make-local-variable 'LaTeX-section-hook)
+   (setq LaTeX-section-hook
+         '(LaTeX-section-heading
+           LaTeX-section-title
+           LaTeX-beamer-section))
+   (if LaTeX-beamer-section-labels-flag
+       (setq LaTeX-section-hook
+             (append LaTeX-section-hook '(LaTeX-section-label))))
 
    (setq LaTeX-item-list
          (append '(("itemize" . LaTeX-item-beamer)
-                   ("enumerate" . LaTeX-item-beamer))
+                   ("enumerate" . LaTeX-item-beamer)
+                   ("thebibliography" . LaTeX-bibitem-beamer))
                  LaTeX-item-list))
 
    (setq LaTeX-default-document-environment "frame")
@@ -87,96 +99,229 @@
    (LaTeX-paragraph-commands-add-locally "frametitle")
 
    (TeX-add-symbols
+    '("AtBeginSection" ["Special star text"] t)
+    '("AtBeginSubsection" ["Special star text"] t)
+    '("AtBeginSubsubsection" ["Special star text"] t)
+    '("AtBeginPart" t)
+    '("AtBeginLecture" t)
+    '("AtBeginNote" t)
+    '("AtEndNote" t)
+    '("action" [ TeX-arg-beamer-overlay-spec "Action spec" ] t)
+    '("againframe" [ TeX-arg-beamer-overlay-spec ]
+      ;; XXX: default overlay spec must be in "[...]".
+      ;; [ TeX-arg-beamer-overlay-spec "Default overlay" ]
+      ["Options"] "Frame label")
     '("alert" [ TeX-arg-beamer-overlay-spec ] 1)
-    '("alt" [ TeX-arg-beamer-overlay-spec ] 2)
+    '("alt" TeX-arg-beamer-overlay-spec "Text on specified slides"
+      "Text on other slides")
+    '("appendix" [ TeX-arg-beamer-overlay-spec "Mode spec"])
+    '("author" [ LaTeX-arg-author "Short author names" ] LaTeX-arg-author)
+    '("beamerdefaultoverlayspecification" (TeX-arg-literal "{")
+      (TeX-arg-beamer-overlay-spec "Default overlay")
+      (TeX-arg-literal "}"))
     '("beamerbutton" 1)
     '("beamergotobutton" 1)
     '("beamerreturnbutton" 1)
     '("beamerskipbutton" 1)
-    '("frame" TeX-arg-beamer-frametitle)
+    '("column" [ TeX-arg-beamer-overlay-spec ] ["Placement(t,T,c,b)"]
+      (TeX-arg-length "Column width"))
+    '("date" [ TeX-arg-date "Short date" ] TeX-arg-date)
+    ;; Beamer frame macro is obsolete, and standard LaTeX frame macro
+    ;; is available in frame environment.
+    ;; '("frame" TeX-arg-beamer-frametitle)
+    '("framelatex" t)
     '("frametitle"
-      (TeX-arg-eval TeX-read-string "Title: " nil 'LaTeX-beamer-frametitle-history))
-    '("hyperlink" [ TeX-arg-beamer-overlay-spec ] 2)
+      [ TeX-arg-beamer-overlay-spec ] ["Short title"]
+      (TeX-arg-string "Title" nil LaTeX-beamer-frametitle-history))
+    '("framesubtitle" [ TeX-arg-beamer-overlay-spec ] "Subtitle")
+    '("framezoom" (TeX-arg-beamer-overlay-spec "Overlay having button")
+      (TeX-arg-beamer-overlay-spec "Zoomed overlay") ["Options"]
+      (TeX-arg-pair "Upper left X" "Upper left Y")
+      (TeX-arg-pair "Zoom area width" "Zoom area depth"))
+    '("hyperlink" [ TeX-arg-beamer-overlay-spec ] "Target name" t)
     '("hyperlinkslideprev" [ TeX-arg-beamer-overlay-spec ] 1)
     '("hyperlinkslidenext" [ TeX-arg-beamer-overlay-spec ] 1)
     '("hyperlinkframestart" [ TeX-arg-beamer-overlay-spec ] 1)
     '("hyperlinkframeend" [ TeX-arg-beamer-overlay-spec ] 1)
     '("hyperlinkframestartnext" [ TeX-arg-beamer-overlay-spec ] 1)
     '("hyperlinkframeendprev" [ TeX-arg-beamer-overlay-spec ] 1)
+    '("hyperlinksectionstart" [ TeX-arg-beamer-overlay-spec ] 1)
+    '("hyperlinksectionend" [ TeX-arg-beamer-overlay-spec ] 1)
+    '("hyperlinksectionstartnext" [ TeX-arg-beamer-overlay-spec ] 1)
+    '("hyperlinksectionendprev" [ TeX-arg-beamer-overlay-spec ] 1)
+    '("hyperlinksubsectionstart" [ TeX-arg-beamer-overlay-spec ] 1)
+    '("hyperlinksubsectionend" [ TeX-arg-beamer-overlay-spec ] 1)
+    '("hyperlinksubsectionstartnext" [ TeX-arg-beamer-overlay-spec ] 1)
+    '("hyperlinksubsectionendprev" [ TeX-arg-beamer-overlay-spec ] 1)
     '("hyperlinkpresentationstart" [ TeX-arg-beamer-overlay-spec ] 1)
     '("hyperlinkpresentationend" [ TeX-arg-beamer-overlay-spec ] 1)
     '("hyperlinkappendixstart" [ TeX-arg-beamer-overlay-spec ] 1)
     '("hyperlinkappendixend" [ TeX-arg-beamer-overlay-spec ] 1)
     '("hyperlinkdocumentstart" [ TeX-arg-beamer-overlay-spec ] 1)
     '("hyperlinkdocumentend" [ TeX-arg-beamer-overlay-spec ] 1)
-    '("hypertarget" [ TeX-arg-beamer-overlay-spec ] 2)
-    '("institute" 1)
+    '("hypertarget" [ TeX-arg-beamer-overlay-spec ] "Target name" t)
+    '("includegraphics" [ TeX-arg-beamer-overlay-spec ]
+      [ LaTeX-arg-graphicx-includegraphics-key-val ] LaTeX-arg-includegraphics)
+    '("includeonlyframes" "Frame label(s)")
+    '("includeonlylecture" "Lecture label")
+    '("includeslide" ["Options"] "Label")
+    '("institute" ["Short institute name"] t)
     '("invisible" [ TeX-arg-beamer-overlay-spec ] 1)
-    '("label" [ TeX-arg-beamer-overlay-spec ] 1)
+    '("keywords" t)
+    '("label" [ TeX-arg-beamer-overlay-spec ] TeX-arg-label)
+    '("lecture" ["Short lecture name"] "Lecture name" "Lecture label")
     '("logo" 1)
-    '("note" TeX-arg-beamer-note 1)
+    '("mode" [ TeX-arg-beamer-overlay-spec "Mode" ] t)
+    "mode*"
+
+    ;; Adapted copies from latex.el
+    '("newcommand<>" TeX-arg-define-macro [ TeX-arg-define-macro-arguments ] t)
+    '("renewcommand<>" TeX-arg-macro [ TeX-arg-define-macro-arguments ] t)
+    '("newenvironment<>" TeX-arg-define-environment
+      [ TeX-arg-define-macro-arguments ] 2)
+    '("renewenvironment<>" TeX-arg-environment
+      [ TeX-arg-define-macro-arguments ] 2)
+
+    ;; TODO: Support the case \note is used outside frame env.
+    '("note" [ TeX-arg-beamer-overlay-spec ] ["Options"] t)
     '("only" [ TeX-arg-beamer-overlay-spec ] 1)
     '("onslide" [ TeX-arg-beamer-overlay-spec ])
-    '("partpage")
+    "partpage"
     '("pause" ["Slide number"])
+    '("resetcounteronoverlays" TeX-arg-counter)
+    "sectionpage"
+    '("setbeameroption" t)
+    '("setbeamersize" t)
+    '("setjobnamebeamerversion" "Filename without extension")
     '("structure" [ TeX-arg-beamer-overlay-spec ] 1)
-    '("temporal" [ TeX-arg-beamer-overlay-spec ] 3)
-    '("titlepage")
+    "subsectionpage"
+    '("subtitle" ["Short subtitle"] t)
+    '("subject" t)
+    '("tableofcontents" ["Options"])
+    '("temporal" TeX-arg-beamer-overlay-spec
+      "Before slide text" "Default text" "After slide text")
+    "titlepage"
+    '("title" ["Short title"] t)
     '("titlegraphic" 1)
-    '("uncover" [ TeX-arg-beamer-overlay-spec ] 1)
-    '("usetheme" LaTeX-arg-beamer-theme)
-    '("useinnertheme" LaTeX-arg-beamer-inner-theme)
-    '("useoutertheme" LaTeX-arg-beamer-outer-theme)
-    '("usecolortheme" LaTeX-arg-beamer-color-theme)
-    '("usefonttheme" LaTeX-arg-beamer-font-theme)
-    '("usetheme" LaTeX-arg-beamer-theme)
+
+    '("transblindshorizontal" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transblindsvertical" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transboxin" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transboxout" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transcover" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transdissolve" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transfade" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transfly" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transglitter" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transpush" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transreplace" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transsplitverticalin" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transsplitverticalout" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transsplithorizontalin" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transsplithorizontalout" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transwipe" [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    '("transduration" [ TeX-arg-beamer-overlay-spec ] "Seconds")
+
+    '("uncover" [ TeX-arg-beamer-overlay-spec ] t)
+    '("usetheme" ["Options"] LaTeX-arg-beamer-theme)
+    '("useinnertheme" ["Options"] LaTeX-arg-beamer-inner-theme)
+    '("useoutertheme" ["Options"] LaTeX-arg-beamer-outer-theme)
+    '("usecolortheme" ["Options"] LaTeX-arg-beamer-color-theme)
+    '("usefonttheme" ["Options"] LaTeX-arg-beamer-font-theme)
+    '("setbeamercolor" "Beamer color" "Color specification")
+    '("setbeamercolor*" "Beamer color" "Color specification")
+    '("usebeamercolor" ["fg or bg"] "Beamer color")
+    '("usebeamercolor*" ["fg or bg"] "Beamer color")
+    '("setbeamerfont" "Beamer font" "Font attributes")
+    '("setbeamerfont*" "Beamer font" "Font attributes")
+    '("usebeamerfont" "Beamer font")
+    '("usebeamerfont*" "Beamer font")
+    '("setbeamertemplate" "Element" ["Predefined option"] t)
+    '("addtobeamertemplate" "Element" "Pre text" "Post test")
+    '("defbeamertemplate" [ TeX-arg-beamer-overlay-spec "Mode spec" ]
+      "Element" "Predefined option" [ TeX-arg-define-macro-arguments ] t)
+    '("defbeamertemplatealias" "Element" "New predefined option"
+      "Existing predefined option")
+    '("defbeamertemplateparent" "Parent template name"
+      ["Predefined option"] "Child template list"
+      [ TeX-arg-define-macro-arguments ] t)
+    '("ifbeamercolorempty" ["fg or bg"] "Beamer color name"
+      "If undefined" "If defined")
+    '("setbeamercovered" "Options")
+    '("opaqueness" [ TeX-arg-beamer-overlay-spec ] "Opaqueness (in %)")
+
     '("visible" [ TeX-arg-beamer-overlay-spec ] 1))
 
+   ;; TODO: Font commands accept overlay specs.
+   ;; Support commands to manipulate templates?
+
    (LaTeX-add-environments
-    '("actionenv")
-    '("alertblock" 1)
-    '("beamerboxesrounded" 1)
-    '("block" (lambda (env &rest ignore)
-                (LaTeX-insert-environment
-                 env (format "{%s}" (TeX-read-string "Title: ")))))
-    '("column" "Width")
-    "columns"
-    "columnsonlytextwidth"
-    '("exampleblock" 1)
-    '("frame"  (lambda (env &rest ignore)
-                 (let ((title (TeX-read-string "(Optional) Title: " nil
-                                               'LaTeX-beamer-frametitle-history)))
-                   (LaTeX-insert-environment env)
-                   (unless (zerop (length title))
-                     (save-excursion
-                       (LaTeX-find-matching-begin)
-                       (end-of-line)
-                       (LaTeX-newline)
-                       ;; Indent the next macro insertion and don't
-                       ;; rely on the fill-function to do it:
-                       (indent-according-to-mode)
-                       (insert (format "\\frametitle{%s}" title))
-                       ;; This works because \frametitle is a
-                       ;; paragraph command.
-                       (when auto-fill-function
-                         (backward-char)
-                         (LaTeX-fill-paragraph)))))))
-    '("onlyenv" (lambda (env &rest ignore)
-                  (LaTeX-insert-environment
-                   env
-                   (let ((overlay (TeX-read-string "(Optional) Overlay: ")))
-                     (unless (zerop (length overlay))
-                       (format "<%s>" overlay))))))
-    '("overlayarea" "Area width" "Area height")
-    '("overprint"  (lambda (env &rest ignore)
-                     (LaTeX-insert-environment
-                      env
-                      (let ((width (TeX-read-string "(Optional) Area width: ")))
-                        (unless (zerop (length width))
-                          (format "[%s]" width))))))
-    "semiverbatim")
-
-   (LaTeX-largest-level-set "section")
+    '("abstract" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ])
+    '("actionenv" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ])
+    '("alertblock" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ] "Title")
+    '("beamerboxesrounded" ["Options"] "Header")
+    '("beamercolorbox" ["Options"] "Beamer color")
+    '("block" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ] "Title")
+    '("column" LaTeX-env-args [ TeX-arg-beamer-overlay-spec ]
+      ["Placement(t,T,c,b)"] (TeX-arg-length "Width"))
+    '("columns" LaTeX-env-args [ TeX-arg-beamer-overlay-spec ] ["Options"])
+    ;; FIXME: Not on user reference.
+    ;; "columnsonlytextwidth"
+    '("exampleblock" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ] "Title")
+    '("frame" LaTeX-env-args [ TeX-arg-beamer-overlay-spec ]
+      ;; XXX: default overlay spec must be in "[...]".
+      ;; [ TeX-arg-beamer-overlay-spec "Default overlay" ]
+      ["Options"] LaTeX-beamer-env-frame)
+
+    '("onlyenv" LaTeX-env-args [ TeX-arg-beamer-overlay-spec ])
+    '("altenv" LaTeX-env-args [ TeX-arg-beamer-overlay-spec ]
+      "Begin text" "End text" "Alternate begin text" "Alternate end text")
+    '("visibleenv" LaTeX-env-args [ TeX-arg-beamer-overlay-spec ])
+    '("uncoverenv" LaTeX-env-args [ TeX-arg-beamer-overlay-spec ])
+    '("invisibleenv" LaTeX-env-args [ TeX-arg-beamer-overlay-spec ])
+
+    '("structureenv" LaTeX-env-args [ TeX-arg-beamer-overlay-spec ])
+    '("alertenv" LaTeX-env-args [ TeX-arg-beamer-overlay-spec ])
+
+    '("theorem" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ] ["Additional text"])
+    '("corollary" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ] ["Additional text"])
+    '("definition" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ] ["Additional text"])
+    '("definitions" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ] ["Additional text"])
+    '("fact" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ] ["Additional text"])
+    '("lemma" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ] ["Additional text"])
+    '("example" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ] ["Additional text"])
+    '("examples" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ] ["Additional text"])
+    '("proof" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ] ["Proof name"])
+
+    '("overlayarea" LaTeX-env-args
+      (TeX-arg-length "Area width") (TeX-arg-length "Area height"))
+    '("overprint" LaTeX-env-args [ TeX-arg-length "Area width" ])
+    "semiverbatim"
+
+    '("verse" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ])
+    '("quotation" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ])
+    '("quote" LaTeX-env-args
+      [ TeX-arg-beamer-overlay-spec "Action spec" ]))
+
+   ;; TODO: itemize, enumerate and description envs accept default
+   ;; overlay spec as optional argument.
+
    (LaTeX-add-counters "lecture" "part" "section" "subsection" "subsubsection"
                        "subsectionslide" "framenumber" "figure" "table"
                        "beamerpauses")
@@ -192,7 +337,17 @@
                                 ("subtitle" "[{")
                                 ("author" "[{")
                                 ("date" "[{")
-                                ("frametitle" "<[{")) 'slide-title)))
+                                ("institute" "[{")
+                                ("frametitle" "<[{")
+                                ("framesubtitle" "<[{"))
+                              'slide-title))
+   ;; TODO: Adjust section commands to accept <> option.
+   ;;       \hyperlink, \label and \newcommand<> commands as well.
+
+   ;; Additional intermediate files
+   ;; XXX: Add to latex.el instead?
+   (add-to-list (make-local-variable 'LaTeX-clean-intermediate-suffixes)
+                "\\.vrb"))
  TeX-dialect)
 
 (defun TeX-arg-beamer-overlay-spec (optional &optional prompt)
@@ -200,47 +355,38 @@
 If OPTIONAL is non-nil, insert the specification only if
 non-empty and enclosed in \"<>\".  PROMPT replaces the standard
 one."
-  (let ((TeX-arg-opening-brace "<")
-        (TeX-arg-closing-brace ">"))
-    (TeX-argument-insert
-     (TeX-read-string
-      (TeX-argument-prompt optional prompt "Overlay"))
-     optional)
-    (indent-according-to-mode)))
-
-(defun TeX-arg-beamer-frametitle (_optional &optional _prompt)
-  "Prompt for the frametitle."
-  (let ((title (TeX-read-string "Title: " nil 'LaTeX-beamer-frametitle-history)))
-    (if (not (zerop (length title)))
-        (insert TeX-grop TeX-esc "frametitle" TeX-grop
-                title TeX-grcl TeX-grcl)
-      (insert TeX-grop TeX-grcl))))
-
-(defun LaTeX-item-beamer ()
-  "Insert a new item with an optional overlay argument. You
-can turn off the prompt for the overlay argument by setting
-`LaTeX-beamer-item-overlay-flag' to nil. Calling the function
+  (TeX-arg-string optional (or prompt "Overlay") nil nil nil "<" ">")
+  (indent-according-to-mode))
+
+;; (defun TeX-arg-beamer-frametitle (_optional &optional _prompt)
+;;   "Prompt for the frametitle."
+;;   (let ((title (TeX-read-string "Title: " nil 'LaTeX-beamer-frametitle-history)))
+;;     (if (not (zerop (length title)))
+;;         (insert TeX-grop TeX-esc "frametitle" TeX-grop
+;;                 title TeX-grcl TeX-grcl)
+;;       (insert TeX-grop TeX-grcl))))
+
+(defun LaTeX-item-beamer (&optional macro)
+  "Insert a new item with an optional overlay argument.
+You can turn off the prompt for the overlay argument by setting
+`LaTeX-beamer-item-overlay-flag' to nil.  Calling the function
 with a prefix argument prompts for the overlay specification
-unconditionally."
-  (if (listp current-prefix-arg)
-      (setq current-prefix-arg (car current-prefix-arg))
-    current-prefix-arg)
-  (TeX-insert-macro "item")
+unconditionally.
+
+Optional MACRO can be, for example, \"bibitem\"."
+  (TeX-insert-macro (or macro "item"))
   (delete-horizontal-space)
   (if (or current-prefix-arg LaTeX-beamer-item-overlay-flag)
-      (TeX-arg-beamer-overlay-spec 0))
-  (insert " ")
-  (indent-according-to-mode))
+      (TeX-arg-beamer-overlay-spec t))
+  (insert " "))
 
-(defun TeX-arg-beamer-note (_optional &optional _prompt)
-  "Prompt for overlay specification and optional argument."
-  (let ((overlay (TeX-read-string "(Optional) Overlay: "))
-        (options (TeX-read-string "(Optional) Options: ")))
-    (unless (zerop (length overlay))
-      (insert "<" overlay ">"))
-    (unless (zerop (length options))
-      (insert "[" options "]"))
-    (indent-according-to-mode)))
+(defun LaTeX-bibitem-beamer ()
+  "Insert a new bibitem with an optional overlay argument.
+You can turn off the prompt for the overlay argument by setting
+`LaTeX-beamer-item-overlay-flag' to nil.  Calling the function
+with a prefix argument prompts for the overlay specification
+unconditionally."
+  (LaTeX-item-beamer "bibitem"))
 
 (defun LaTeX-beamer-search-themes (&optional regexp extensions length)
   "Search for beamer themes matching REGEXP with EXTENSIONS.
@@ -252,7 +398,7 @@ also be a string.  Then the length of the string is used."
          (chars (cond ((integerp length)
                        length)
                       ((stringp length)
-                       (string-width length))
+                       (length length))
                       ;; Try some DWIM magic...
                       ((and (not length)
                             (string-match "beamer[A-Za-z0-9]*theme" match))
@@ -265,7 +411,7 @@ also be a string.  Then the length of the string is used."
               (lambda (file)
                 (let ((case-fold-search nil))
                   (and (numberp (string-match match file))
-                       (substring file chars))))
+                       (substring-no-properties file chars))))
               (TeX-search-files nil exts t t))))))
 
 (defun LaTeX-arg-beamer-theme (&rest _ignore)
@@ -363,19 +509,69 @@ also be a string.  Then the length of the string is used."
     nil nil nil)
    t))
 
+(defun LaTeX-beamer-env-frame (_ignored)
+  "Insert beamer frame environment title."
+  (let ((title (TeX-read-string "(Optional) Title: " nil
+                                'LaTeX-beamer-frametitle-history)))
+    (unless (zerop (length title))
+      (save-excursion
+        (LaTeX-newline)
+        ;; Indent the next macro insertion and don't rely on the
+        ;; fill-function to do it:
+        (indent-according-to-mode)
+        (insert (format "\\frametitle{%s}" title))
+        ;; This works because \frametitle is a paragraph command.
+        (when auto-fill-function
+          (backward-char)
+          (LaTeX-fill-paragraph))))))
+
+(defun LaTeX-beamer-section ()
+  "Hook to prompt for beamer section and insert it."
+  (let ((star (string-suffix-p "*" LaTeX-name))
+        mode-spec short-title)
+    (when (and LaTeX-level (< LaTeX-level 4))
+      (setq mode-spec (TeX-read-string "(Optional) Mode spec: ")
+            short-title (unless star
+                            (TeX-read-string "(Optional) Short title: "))))
+    ;; The rest of this function is adapted copy of
+    ;; `LaTeX-section-section'.
+    (unless (save-excursion
+              (re-search-backward
+               (concat "^\\s-*\n\\s-*\\=\\|^\\s-*" (regexp-quote TeX-esc)
+                       "begin")
+               (line-beginning-position 0) t))
+      (LaTeX-newline))
+    (insert TeX-esc (if star
+                        (substring-no-properties LaTeX-name 0 -1)
+                      LaTeX-name))
+    (if (< 0 (length mode-spec))
+        (insert "<" mode-spec ">"))
+    (if star (insert "*"))
+    (if (< 0 (length short-title))
+        (insert LaTeX-optop short-title LaTeX-optcl))
+    (insert TeX-grop)
+    (if (zerop (length LaTeX-title))
+        (set-marker LaTeX-done-mark (point)))
+    (insert LaTeX-title TeX-grcl)
+    (LaTeX-newline)
+    ;; If RefTeX is available, tell it that we've just made a new section
+    (and (fboundp 'reftex-notice-new-section)
+         (reftex-notice-new-section))))
+
 (defun LaTeX-beamer-class-options ()
   "Read the beamer class options from the user."
-  (TeX-load-style "hyperref")
+  (TeX-load-style "hyperref" "color" "xcolor")
   (TeX-read-key-val t '(("usepdftitle" ("false")) ("envcountsect")
                         ("notheorems") ("noamsthm") ("compress") ("t") ("c")
-                        ("leqno") ("fleqn") ("handout") ("trans") ("pdftex")
-                        ("nativepdf") ("pdfmark") ("dvips") ("dviwindo")
-                        ("dvipsone") ("vtex") ("ps2pdf") ("ignorenonframetext")
+                        ("leqno") ("fleqn") ("handout") ("trans")
+                        ("ignorenonframetext") ("onlytextwidth")
                         ("noamssymb") ("bigger") ("smaller") ("8pt") ("9pt")
                         ("10pt") ("11pt") ("12pt") ("14pt") ("17pt") ("20pt")
                         ("draft") ("CJK") ("cjk") ("pgf")
                         ("hyperref" LaTeX-hyperref-package-options-list)
-                        ("color") ("xcolor") ("ucs") ("utf8x") ("utf8")
-                        ("aspectratio" ("1610" "169" "149" "54" "43" "32")))))
+                        ("color" LaTeX-color-package-options)
+                        ("xcolor" LaTeX-xcolor-package-options)
+                        ("ucs") ("utf8x") ("utf8")
+                        ("aspectratio" ("2013" "1610" "169" "149" "141" "54" "43" "32")))))
 
 ;;; beamer.el ends here
diff --git a/style/beamerarticle.el b/style/beamerarticle.el
index 136947ac..09d58163 100644
--- a/style/beamerarticle.el
+++ b/style/beamerarticle.el
@@ -32,4 +32,8 @@
 (TeX-add-style-hook
  "beamerarticle"
  (lambda ()
-   (TeX-run-style-hooks "beamer")))
+   (TeX-run-style-hooks "beamer")
+
+   (LaTeX-section-list-add-locally
+    '(("paragraph" 4)
+      ("subparagraph" 5)))))
-- 
2.38.1

Reply via email to