[Top][All Lists]

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

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

From: Arne Jørgensen
Subject: [AUCTeX-devel] Re: Make TeX-insert-macro behave intelligently on \usepackage
Date: Tue, 11 Oct 2005 23:12:41 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Reiner Steib <address@hidden> writes:

>> At least for future XEmacs'.
> If they put it in some package (this is what I'd suggest), the user
> may upgrade this packages if he want this AUCTeX functionality.
>> It does (except that it mangles the prompt a bit). Is riece part of
>> an XEmacs release? 
> AFAICS, it's in the package "riece".  In SuSE 9.2 it is in
> xemacs-packages-20040202.  AFAIK, the packages are independent of
> XEmacs' version number.

Fine. I'm not familiar with the XEmacs way of doing things. In
Debian/sid riece is in xemacs21-basesupport.

>> (and should we require an IRC client).
> I don't think so.

The answer was almost written in the question :-)

> In <address@hidden> you wrote:
>> 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 think we should provide an option to get the current behavior back.
> Things like these might be in the finger-memory of users. 

I've made a variable `LaTeX-usepackage-intelligent-behavior-p' that
will give the old behavior if set to nil.

> If we have this option, it could default to "intelligent" (using
> TeX-arg-usepackage with `crm.el') when `completing-read-multiple' is
> available and to the old style otherwise.

It just defaults to t. (wrt `completing-read-multiple' see below).

> I wouldn't spend too much time trying to provide a better fallback for
> Emacsen without `completing-read-multiple'.  YMMV.

I already have a fallback to multi-prompt so no time wasted.

> I've send a mail to xemacs-beta suggesting to add `crm.el'.[1]

I noticed. Let's see if they pick it up.

> BTW, when suggesting patches, I'd prefer if you post them on the list
> (unless they are really big; you could attach a zipped patch) instead
> of only providing an URL.

My first attempt at attaching patches on the list failed so I assumed
they were strip off by the mailing list software.

I'll try again with this mail. Attached should be the patch.

Kind regards,

Arne Jørgensen <>

Index: tex.el
RCS file: /cvsroot/auctex/auctex/tex.el,v
retrieving revision 5.539
diff -u -p -r5.539 tex.el
--- tex.el      6 Oct 2005 20:35:39 -0000       5.539
+++ tex.el      11 Oct 2005 21:02:35 -0000
@@ -693,6 +693,15 @@ overlays."
             (+ (/ (- outer-priority inner-priority) 2) inner-priority))
            (t TeX-overlay-priority-step)))) )
+(if (fboundp 'completing-read-multiple)
+    (defalias 'TeX-completing-read-multiple 'completing-read-multiple)
+  (defun TeX-completing-read-multiple
+    (prompt table &optional predicate require-match initial-input
+           hist def inherit-input-method)
+    "Poor mans implementation of Emacs' `completing-read-multiple' for XEmacs."
+    (multi-prompt "," nil prompt table predicate require-match initial-input 
 ;;; Special support for GNU Emacs
 (unless (featurep 'xemacs)
Index: latex.el
RCS file: /cvsroot/auctex/auctex/latex.el,v
retrieving revision 5.386
diff -u -p -r5.386 latex.el
--- latex.el    10 Oct 2005 18:52:15 -0000      5.386
+++ latex.el    11 Oct 2005 21:02:39 -0000
@@ -1553,6 +1553,42 @@ ELSE as an argument list."
   ;; defined in individual style hooks
+(defcustom LaTeX-usepackage-intelligent-behaviour-p t
+  "*If non-nil, tries to ask intelligent questions about package options."
+  :type 'boolean
+  :group 'LaTeX-macro)
+(defun TeX-arg-usepackage (optional)
+  "Insert arguments to usepackage."
+  (if (null LaTeX-usepackage-intelligent-behaviour-p)
+      (progn
+       (let ((TeX-arg-opening-brace LaTeX-optop)
+             (TeX-arg-closing-brace LaTeX-optcl))
+         (TeX-argument-insert (read-string (TeX-argument-prompt nil "Options" 
nil)) t))
+       (TeX-arg-input-file nil "Package"))
+    (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-package-options" package)))
+              (crm-separator ",")
+              (TeX-arg-opening-brace LaTeX-optop)
+              (TeX-arg-closing-brace LaTeX-optcl)
+              options)
+         (if (or (and (boundp var)
+                      (listp (symbol-value var)))
+                 (fboundp var))
+             (if (functionp var)
+                 (setq options (funcall var))
+               (setq options
+                     (mapconcat 'identity 
+                                (TeX-completing-read-multiple 
+                                 "Options: " (mapcar 'list (symbol-value var)))
+                                ",")))
+           (setq options (read-string "Options: ")))
+         (TeX-argument-insert options t))))))
 (defvar TeX-global-input-files nil
   "List of the non-local TeX input files.
@@ -4969,7 +5005,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"

reply via email to

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