Hi Uwe and all,
2014-11-27 11:39 GMT+01:00 Uwe Brauer <[email protected]>:
>>> "Mos" == Mos <Mos> writes:
>
> >> - ""))))
> >> + ""))
> >> + ((nullp type)
> >> + "")))
> > ^^^^
>
> > Sorry, I meant nil instead of ""
>
> Hi
>
> I modified (hopefully correctly) your patch, applied it
> then used my old definitions such as
> (defun LaTeX-rem-insert (environment) ;Version:1.20
> (if (y-or-n-p
> (format "Do you want a title "))
> (let ((title (read-input " Title: ")))
> (LaTeX-insert-environment "rem" (concat "[" title "]"))
> (and (LaTeX-label environment)
> (newline-and-indent)))
> (LaTeX-insert-environment "rem")
> (and (LaTeX-label environment)
> (newline-and-indent))))
>
> and got an error. I attach the modified patch, and the error
I hope it's clear I wrote those messages in a hurry, just to give the idea.
I changed my mind. I propose the attached patch which restores (full)
compatibility with the old version of LaTeX-label: the optioanl `type'
argument select the look up table to be used for the default prefix of
the label, if it's nil (or absent) you are always prompted for a
label. AUCTeX code always uses the appropriate value for the type
argument, but users will also be able to force the insertion of the
label (or continue to use the old syntax of the function).
Bye,
Mosè
diff --git a/latex.el b/latex.el
index 80d2761..571f010 100644
--- a/latex.el
+++ b/latex.el
@@ -933,7 +933,14 @@ If nil, act like the empty string is given, but do not prompt."
("eqnarray" . LaTeX-eqnarray-label))
"Lookup prefixes for labels.
An alist where the CAR is the environment name, and the CDR
-either the prefix or a symbol referring to one."
+either the prefix or a symbol referring to one.
+
+If the name is not found, or if the CDR is nil, no label is
+automatically inserted for that environment.
+
+If you want to automatically insert a label for a environment but
+with an empty prefix, use the empty string \"\" as the CDR of the
+corresponding entry."
:group 'LaTeX-label
:type '(repeat (cons (string :tag "Environment")
(choice (string :tag "Label prefix")
@@ -941,10 +948,16 @@ either the prefix or a symbol referring to one."
(make-variable-buffer-local 'LaTeX-label-alist)
-(defun LaTeX-label (name type)
+(defun LaTeX-label (name &optional type)
"Insert a label for NAME at point.
-TYPE can be either environment or section. If
-`LaTeX-label-function' is a valid function, LaTeX label will
+The optional TYPE argument can be either environment or section:
+in the former case this function looks up `LaTeX-label-alist' to
+choose which prefix to use for the label, in the latter case
+`LaTeX-section-label' will be looked up instead. If TYPE is nil,
+you will be always prompted for a label, with an empty default
+prefix.
+
+If `LaTeX-label-function' is a valid function, LaTeX label will
transfer the job to this function."
(let ((prefix (cond
((eq type 'environment)
@@ -955,7 +968,9 @@ transfer the job to this function."
LaTeX-section-label
(and (listp LaTeX-section-label)
(cdr (assoc name LaTeX-section-label))))
- ""))))
+ ""))
+ ((null type)
+ "")))
label)
(when (symbolp prefix)
(setq prefix (symbol-value prefix)))
_______________________________________________
bug-auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-auctex