auctex-devel
[Top][All Lists]
Advanced

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

Re: [AUCTeX-devel] Re: Make TeX-insert-macro behave intelligently on \us


From: Ralf Angeli
Subject: Re: [AUCTeX-devel] Re: Make TeX-insert-macro behave intelligently on \usepackage
Date: Mon, 10 Oct 2005 19:19:26 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

* Arne Jørgensen (2005-10-10) writes:

> First of all it would be nice if we could agree whether the general
> idea is good or not. That is do we want to be asked "intelligent"
> questions when we insert a \usepackage command?
>
> I'm pretty sure we can agree on that (since nobody complained yet) and
> otherwise we could add a variable to disable it.

I am wondering if inserting independent arguments first and depending
ones later should become a general rule.  If we do this differently
for every macro the resulting inconsistency in the user interface
might confuse the user.  But maybe I am taking this too far again.

> The next thing is how to implement it (is there a better way than what
> I did). Let me just revive in a few words what my implementation does:
[...]
> I have been thinking about more flexibel, beautiful and powerful ways
> to do this. Could we use alist's for storing keyval options and their
> values? and stuff like that. but none of them seems to be more
> flexible, beautiful or powerful.

I'd appreciate it if we could at least parse this stuff.  But this can
get kinda tricky with things like
\foo[bar,baz={Some%
  random crap.}]{blu}

> An extension of the functionality would be to have the
> `TeX-auto-generate'[1] stuff scan for \DeclareOption and put those
> options into a list in the auto generated style file. This won't cover
> all cases but it is most likely the best we can do in an automatic
> process.

Unfortunately the style system currently is missing ways to
distinguish between different types of styles, like "regular" input
files, packages, classes, or options for them.  That's an interesting
field for overhaul/reimplementation. (c;

I have some comments regarding the implementation (I've only looked at
the patch to latex.el):

| --- latex.el    26 Aug 2005 16:26:26 -0000      5.382
| +++ latex.el    25 Sep 2005 22:40:34 -0000
| @@ -1537,6 +1537,27 @@ ELSE as an argument list."
|    ;; defined in individual style hooks
|    (TeX-update-style))
|  
| +(defun TeX-arg-usepackage (optional)
| +  "Insert arguments to usepackage."
| +  (let ((TeX-file-extensions '("sty")))
| +    (TeX-arg-input-file nil "Package")
| +    (save-excursion
| +      (search-backward-regexp "{\\(.*\\)}")
| +      (let* ((package (match-string 1))
| +            (var (intern (format "LaTeX-%s-options" package)))

This scares me a bit.  I think we mostly try to stick with
`LaTeX-<package>' prefixes for functions and variables in style files,
but I don't know if we can be strict enough to have this as a
mandatory convention.  Other than that it looks like a pragmatic
solution as long as the style system cannot handle package options.

| +            (crm-separator ",")
| +            (TeX-arg-opening-brace LaTeX-optop)
| +            (TeX-arg-closing-brace LaTeX-optcl)
| +            options)
| +       (if (or (and (boundp var)
| +                    (listp var))
| +               (fboundp var))
| +           (if (functionp var)
| +               (setq options (funcall var))
| +             (setq options (mapconcat 'identity (completing-read-multiple 
"Options: " (symbol-value var)) ",")))

AFAICS `completing-read-multiple' is not avaible on XEmacs.  Can you
code around that?

| +         (setq options (read-string "Options: ")))
| +       (TeX-argument-insert options t)))))
| +
|  (defvar TeX-global-input-files nil
|    "List of the non-local TeX input files.
|  
| @@ -4869,7 +4890,7 @@ runs the hooks in `docTeX-mode-hook'."
|         [ "Number of arguments" ] [ "Default value for first argument" ] t)
|       '("renewcommand*" TeX-arg-macro
|         [ "Number of arguments" ] [ "Default value for first argument" ] t)
| -     '("usepackage" [ "Options" ] (TeX-arg-input-file "Package"))
| +     '("usepackage" TeX-arg-usepackage)
|       '("documentclass" TeX-arg-document)))
|  
|    (TeX-add-style-hook "latex2e"

-- 
Ralf




reply via email to

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