emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] 83/299: provide completion for options in `TeX-arg-document'


From: Stefan Monnier
Subject: [elpa] 83/299: provide completion for options in `TeX-arg-document'
Date: Sun, 02 Nov 2014 03:10:29 +0000

monnier pushed a commit to branch externals/auctex
in repository elpa.

commit be3c2744de6c0d2c6fdd7d43e310c567f62ba9e5
Author: Mosè Giordano <address@hidden>
Date:   Fri Apr 5 16:31:47 2013 +0200

    provide completion for options in `TeX-arg-document'
    
    * latex.el (LaTeX-global-class-files): New variable.
    (TeX-arg-document): Provide completion for class options, based on
    `LaTeX-arg-usepackage'.  Use `LaTeX-global-class-files'.
    (LaTeX-style-list): Mention that if `TeX-arg-input-file-search' is
    set to `t' this variable will be ignored.
    
    * tex.el (TeX-normal-mode): Reset `LaTeX-global-class-files' when
    ARG is non-nil.
    
    * style/article.el (LaTeX-article-class-options): New variable.
    
    * style/book.el (LaTeX-book-class-options): New variable.
    
    * style/report.el (LaTeX-report-class-options): New variable.
---
 ChangeLog        |   17 ++++++++++++++
 latex.el         |   63 ++++++++++++++++++++++++++++++++++++++---------------
 style/article.el |    6 +++++
 style/book.el    |    7 ++++++
 style/report.el  |    7 ++++++
 tex.el           |    3 +-
 6 files changed, 84 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3ab0320..75ea747 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2013-04-05  Mos� Giordano  <address@hidden>
+
+       * latex.el (LaTeX-global-class-files): New variable.
+       (TeX-arg-document): Provide completion for class options, based on
+       `LaTeX-arg-usepackage'.  Use `LaTeX-global-class-files'.
+       (LaTeX-style-list): Mention that if `TeX-arg-input-file-search' is
+       set to `t' this variable will be ignored.
+
+       * tex.el (TeX-normal-mode): Reset `LaTeX-global-class-files' when
+       ARG is non-nil.
+
+       * style/article.el (LaTeX-article-class-options): New variable.
+
+       * style/book.el (LaTeX-book-class-options): New variable.
+
+       * style/report.el (LaTeX-report-class-options): New variable.
+
 2013-04-03  Mos� Giordano  <address@hidden>
 
        * latex.el (LaTeX-provided-class-options): New buffer-local
diff --git a/latex.el b/latex.el
index a91d5f2..2ebddef 100644
--- a/latex.el
+++ b/latex.el
@@ -1770,34 +1770,61 @@ string."
                              ("scrlttr2")
                              ("scrreprt")
                              ("slides"))
-  "List of document classes offered when inserting a document environment."
+  "List of document classes offered when inserting a document class.
+
+If `TeX-arg-input-file-search' is set to `t', you will get
+completion with all LaTeX classes available in your distribution
+and this variable will be ignored."
   :group 'LaTeX-environment
   :type '(repeat (group (string :format "%v"))))
 
+(defvar LaTeX-global-class-files nil
+  "List of the LaTeX class files.
+Initialized once at the first time you prompt for a LaTeX class.
+May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.")
+
 (defun TeX-arg-document (optional &optional ignore)
   "Insert arguments to documentclass.
 OPTIONAL and IGNORE are ignored."
   (let* ((TeX-file-extensions '("cls"))
-        (search (if (eq TeX-arg-input-file-search 'ask)
-                    (not (y-or-n-p "Find class yourself? "))
-                  TeX-arg-input-file-search))
-        (LaTeX-style-list
-         (if search
-             (mapcar 'identity (TeX-search-files-by-type 'texinputs 'global t 
t))
-           LaTeX-style-list))
-        (style (completing-read
+        (crm-separator ",")
+        style var options)
+    (unless LaTeX-global-class-files
+      (if (if (eq TeX-arg-input-file-search 'ask)
+             (not (y-or-n-p "Find class yourself? "))
+           TeX-arg-input-file-search)
+         (progn
+           (message "Searching for LaTeX classes...")
+           (setq LaTeX-global-class-files
+                 (mapcar 'identity (TeX-search-files-by-type 'texinputs 
'global t t))))
+       LaTeX-style-list))
+    (setq style (completing-read
                 (concat "Document class: (default " LaTeX-default-style ") ")
-                LaTeX-style-list))
-        (options (read-string "Options: "
-                              (if (stringp LaTeX-default-options)
-                                  LaTeX-default-options
-                                (mapconcat 'identity
-                                           LaTeX-default-options
-                                           ",")))))
+                LaTeX-global-class-files))
     (if (zerop (length style))
        (setq style LaTeX-default-style))
-    (if (not (zerop (length options)))
-       (insert LaTeX-optop options LaTeX-optcl))
+    (TeX-run-style-hooks style)
+    (setq var (intern (format "LaTeX-%s-class-options" style)))
+    (if (or (and (boundp var)
+                (listp (symbol-value var)))
+           (fboundp var))
+       (if (functionp var)
+           (setq options (funcall var))
+         (when (symbol-value var)
+           (setq options
+                 (mapconcat 'identity
+                            (TeX-completing-read-multiple
+                             "Options: " (mapcar 'list (symbol-value var)) nil 
nil
+                             (if (stringp LaTeX-default-options)
+                                 LaTeX-default-options
+                               (mapconcat 'identity LaTeX-default-options 
",")))
+                            ","))))
+      (setq options (read-string "Options: ")))
+    (unless (zerop (length options))
+      (insert LaTeX-optop options LaTeX-optcl)
+      (let ((opts (LaTeX-listify-package-options options)))
+       (TeX-add-to-alist 'LaTeX-provided-class-options
+                         (list (cons style opts)))))
     (insert TeX-grop style TeX-grcl))
 
   ;; remove old information
diff --git a/style/article.el b/style/article.el
index 3b3c06f..420dde6 100644
--- a/style/article.el
+++ b/style/article.el
@@ -2,6 +2,12 @@
 
 ;;; Code:
 
+(defvar LaTeX-article-class-options
+  '("a4paper" "a5paper" "b5paper" "letterpaper" "legalpaper" "executivepaper"
+    "landscape" "10pt" "11pt" "12pt" "oneside" "twoside" "draft" "final"
+    "titlepage" "notitlepage" "onecolumn" "twocolumn" "leqno" "fleqn" 
"openbib")
+  "Package options for the article class.")
+
 (TeX-add-style-hook
  "article"
  (lambda ()
diff --git a/style/book.el b/style/book.el
index 8527989..0f84cc9 100644
--- a/style/book.el
+++ b/style/book.el
@@ -2,6 +2,13 @@
 
 ;;; Code:
 
+(defvar LaTeX-book-class-options
+  '("a4paper" "a5paper" "b5paper" "letterpaper" "legalpaper" "executivepaper"
+    "landscape" "10pt" "11pt" "12pt" "oneside" "twoside" "draft" "final"
+    "titlepage" "notitlepage" "openright" "openany" "onecolumn" "twocolumn"
+    "leqno" "fleqn" "openbib")
+  "Package options for the book class.")
+
 (TeX-add-style-hook
  "book"
  (lambda () 
diff --git a/style/report.el b/style/report.el
index 900ddf2..9ea26c8 100644
--- a/style/report.el
+++ b/style/report.el
@@ -2,6 +2,13 @@
 
 ;;; Code:
 
+(defvar LaTeX-report-class-options
+  '("a4paper" "a5paper" "b5paper" "letterpaper" "legalpaper" "executivepaper"
+    "landscape" "10pt" "11pt" "12pt" "oneside" "twoside" "draft" "final"
+    "titlepage" "notitlepage" "openright" "openany" "onecolumn" "twocolumn"
+    "leqno" "fleqn" "openbib")
+  "Package options for the report class.")
+
 (TeX-add-style-hook
  "report"
  (lambda () 
diff --git a/tex.el b/tex.el
index 6881509..8a90e83 100644
--- a/tex.el
+++ b/tex.el
@@ -5262,7 +5262,8 @@ With optional argument ARG, also reload the style hooks."
            BibTeX-global-files nil
            BibLaTeX-global-style-files nil
            TeX-Biber-global-files nil
-           TeX-global-input-files nil))
+           TeX-global-input-files nil
+           LaTeX-global-class-files nil))
   (let ((TeX-auto-save t))
     (if (buffer-modified-p)
        (save-buffer)



reply via email to

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