Re: Bug#290635: auctex: Should allow customizeation of LaTeX-item-beamer

"Dr. Thomas Baumann" <[email protected]>
Newsgroups gmane.emacs.auc-tex
Organization TUM
Message-ID <[email protected]>
> >> I don't think this makes sense.  Typing C-u before the command
> >> certainly is more effort than just typing RET as an answer to the
> >> prompt.
> >
> > I see the point in a customization of the default behaviour for
> > people not working with overlays at all. And, as Ralf said, in this
> > case C-u can help adding an overlay spec ocasionally.
> 
> Ah, ok.  But then I would not let C-u invert, but rather always give
> the prompt, in order not to cause completely inconsistent behavior.
> What we can do is to not prompt for negative or zero arguments, and
> always prompt for explicit positive arguments.
> 

I guess I'll like to stay with the following solution:

We're introducing a customizable variable LaTeX-beamer-item-overlay-flag
which, if non-nil, will enable the prompt for the overlay. Additionally
calling LaTeX-item-beamer with any prefix argument will prompt for the
overlay unconditionally. Having different prefix arguments for such a
simple function does not make sense to me and it seems to be 
easier to insert the overlay spec manually instead of typing C-u 1
M-RET...

Code and documentation changed in the attached patch.

> >> However, the context sensitivity could save typing indeed, at least
> >> by offering a sensible default: if the previous item in the current
> >> environment is without beamer tag, offer an empty string for
> >> completion, if it is of the form <a-b>, offer <b+1-> as completion,
> >> if it is of the form <a->, offer <a+1->.  Something like that.
> >
> > Cool idea, but I think this will require more than the usual three
> > lines of code... I'll put it on the ToDo-list and I'll appreciate
> > hints and comments.
> 
> Well, you'd first have to use (LaTeX-find-matching-begin) to get the
> search limit.  Then you'd search backward for "\\item" with that
> limit.  For other functions, it might be appropriate to skip every
> \item that has not the same LaTeX-find-matching-begin location, so
> that we refer just to items at the current level.  With beamer, it is
> more likely that the <x-> items continue in the same manner across
> environments.  So strictly speaking, we should probably rather not
> start with LaTeX-find-matching-begin in the first place, but rather
> with LaTeX-beamer-find-startofslide.  Cough, cough.
> 
> Once we have \\item, we can match with
> (looking-at "<\\([0-9]+\\)?\\(-\\([0-9]+\\)?\\)>")
> and then construct the default replacement according to
> (match-beginning 0)... (match-beginning 2) being non-nil or nil.
> 

Ok, I see how this can look like. If it hasn't to be ready by tomorrow
I'll take care of it.

Thomas
beamer.patch (application/octet-stream, 1.5 KB)
--- beamer.el	2005-01-12 17:26:33.000000000 +0100
+++ /home/tb/src/lisp/beamer.el	2005-01-18 19:13:56.873566697 +0100
@@ -18,12 +18,18 @@
 
 ;;; Code:
 
+(defvar LaTeX-beamer-section-labels-flag nil
+  "If non-nil section labels are added")
+
+(defcustom LaTeX-beamer-item-overlay-flag t
+  "If non-nil do prompt for an overlay in itemize-like environments."
+  :type 'boolean
+  :group 'LaTeX-macro)
+
 (TeX-add-style-hook
  "beamer"
  (lambda ()
-   (defvar beamer-use-section-labels-flag nil
-     "Controls whether section labels are added")
-   (unless beamer-use-section-labels-flag
+   (unless LaTeX-beamer-section-labels-flag
      (make-local-variable 'LaTeX-section-hook)
      (setq LaTeX-section-hook
 	   '(LaTeX-section-heading
@@ -130,10 +136,18 @@
       (insert TeX-grop TeX-grcl))))
 
 (defun LaTeX-item-beamer ()
-  "Insert a new item with an optional overlay argument."
+  "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")
   (delete-horizontal-space)
-  (TeX-arg-beamer-overlay-spec 0)
+  (if (or current-prefix-arg LaTeX-beamer-item-overlay-flag)
+      (TeX-arg-beamer-overlay-spec 0))
   (insert " ")
   (indent-according-to-mode))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.