auctex-devel
[Top][All Lists]
Advanced

[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: Wed, 12 Oct 2005 12:14:53 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

David Kastrup <address@hidden> writes:

> Ralf Angeli <address@hidden> writes:
>
>> * Arne Jørgensen (2005-10-11) writes:
>>
>>> Reiner Steib <address@hidden> writes:
>>>
>>>> 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.
>>
>> In my opinion this is unnecessary.  If we think the new behavior is
>> favorable let's just do that and don't look back to the old one which
>> I always found awkward.
>
> Agreed.

OK. I was just testing an idea from Reiner.

> Alone because of the ugliness of the option name.  "intelligent" is
> not descriptive.

Definetely a bad name, but the best I could come up with last
night. Feel free to come up with a better name if that can make you
change your mind.

>>> +  (if (null LaTeX-usepackage-intelligent-behaviour-p)
>
>> That should be `not' instead of `null' for clarity.
>
> For clarity, it should be
>
>   (unless LaTeX-usepackage-intelligent-behaviour-p
>
> but I don't the the old behavior warrants keeping.

`unless' on has then part, not and else part like `if'.

Ralf, thanks for the advice about -p/-flag and not/null.

I removed the variable and the test again.

Peoples opinions seem to stabilize now so I'll commit the change in an
hour or so unless someone complains. Then real world testing will
probably give some comments.

Kind regards,

     /arne
-- 
Arne Jørgensen <http://arnested.dk/>

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      12 Oct 2005 10:12:50 -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 
hist)))
+
 ;;; 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    12 Oct 2005 10:12:53 -0000
@@ -1553,6 +1553,31 @@ 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-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 +4994,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]