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

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

[elpa] externals/auctex 066cf5a 36/78: Create Italian style file for pol


From: Tassilo Horn
Subject: [elpa] externals/auctex 066cf5a 36/78: Create Italian style file for polyglossia.
Date: Mon, 19 Oct 2015 09:10:52 +0000

branch: externals/auctex
commit 066cf5aa198969206e1cfdc58e3ea71f0e69d2f6
Author: Mosè Giordano <address@hidden>
Commit: Mosè Giordano <address@hidden>

    Create Italian style file for polyglossia.
    
    * style/polyglossia.el: Remove
    `LaTeX-polyglossia-italian-options-list', moved to
    gloss-italian.el.
    (LaTeX-polyglossia-setkeys-regexp): Fix regexp.
    (LaTeX-polyglossia-cleanup): Remove useless let-bound variables
    and set `LaTeX-polyglossia-lang-list'.
    (LaTeX-polyglossia-active-languages)
    (LaTeX-polyglossia-lang-option-member): Use
    `LaTeX-polyglossia-lang-list' variable instead of function.
    (LaTeX-polyglossia-load-languages): New function.
    ("polyglossia"): Use it.
    
    * style/gloss-italian.el: New style file.
    
    * Makefile.in (STYLESRC): Activate it.
---
 ChangeLog              |   16 +++++++++++
 Makefile.in            |    3 +-
 style/gloss-italian.el |   67 ++++++++++++++++++++++++++++++++++++++++++++++++
 style/polyglossia.el   |   51 +++++++++++++++++++-----------------
 4 files changed, 112 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cb5f7de..9e474fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2015-09-09  Mos� Giordano  <address@hidden>
 
+       * style/polyglossia.el: Remove
+       `LaTeX-polyglossia-italian-options-list', moved to
+       gloss-italian.el.
+       (LaTeX-polyglossia-setkeys-regexp): Fix regexp.
+       (LaTeX-polyglossia-cleanup): Remove useless let-bound variables
+       and set `LaTeX-polyglossia-lang-list'.
+       (LaTeX-polyglossia-active-languages)
+       (LaTeX-polyglossia-lang-option-member): Use
+       `LaTeX-polyglossia-lang-list' variable instead of function.
+       (LaTeX-polyglossia-load-languages): New function.
+       ("polyglossia"): Use it.
+
+       * style/gloss-italian.el: New style file.
+
+       * Makefile.in (STYLESRC): Activate it.
+
        * style/polyglossia.el: New style file.
 
        * Makefile.in (STYLESRC): Activate it.
diff --git a/Makefile.in b/Makefile.in
index d080257..68b785a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -150,7 +150,8 @@ STYLESRC = style/prosper.el \
           style/mn2e.el      style/colortbl.el  style/attachfile.el \
           style/newpxtext.el style/newpxmath.el style/pdfpages.el \
           style/mnras.el     style/environ.el   style/polyglossia.el \
-          style/vwcol.el     style/textpos.el   style/transparent.el
+          style/vwcol.el     style/textpos.el   style/transparent.el \
+          style/gloss-italian.el
 
 STYLEELC = $(STYLESRC:.el=.elc)
 
diff --git a/style/gloss-italian.el b/style/gloss-italian.el
new file mode 100644
index 0000000..a93049a
--- /dev/null
+++ b/style/gloss-italian.el
@@ -0,0 +1,67 @@
+;;; gloss-italian.el --- Italian support for polyglossia package.
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; Maintainer: address@hidden
+;; Author: Mosè Giordano <address@hidden>
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This is based on italian.el style file, adapted to polyglossia package.
+
+;;; Code:
+
+(defvar TeX-language-it-hook nil
+  "Hook run for Italian texts.")
+
+(TeX-add-style-hook
+ "gloss-italian"
+ (lambda ()
+   (TeX-add-symbols
+    '("textitalian" [TeX-arg-key-val LaTeX-polyglossia-italian-options-list]))
+   (LaTeX-add-environments
+    '("italian" [TeX-arg-key-val LaTeX-polyglossia-italian-options-list]))
+
+   (when (or (LaTeX-polyglossia-lang-option-member "italian" 
"babelshorthands=true")
+            (LaTeX-polyglossia-lang-option-member "italian" "babelshorthands"))
+     (unless (eq (car TeX-quote-language) 'override)
+       (let ((open-quote (if (and (boundp 'LaTeX-italian-open-quote)
+                                 LaTeX-italian-open-quote)
+                            LaTeX-italian-open-quote
+                          "\"<"))
+            (close-quote (if (and (boundp 'LaTeX-italian-close-quote)
+                                  LaTeX-italian-close-quote)
+                             LaTeX-italian-close-quote
+                           "\">")))
+        (setq TeX-quote-language
+              `("italian" ,open-quote ,close-quote ,TeX-quote-after-quote))))
+
+     ;; Fontification of quotation marks.
+     (when (fboundp 'font-latex-add-quotes)
+       (font-latex-add-quotes '("\"<" "\">" french))))
+   (run-hooks 'TeX-language-it-hook))
+ LaTeX-dialect)
+
+(defvar LaTeX-polyglossia-italian-options-list
+  '(("babelshorthands" ("true" "false")))
+  "Italian language options for the polyglossia package.")
+
+;;; gloss-italian.el ends here
diff --git a/style/polyglossia.el b/style/polyglossia.el
index 20249f0..1254f28 100644
--- a/style/polyglossia.el
+++ b/style/polyglossia.el
@@ -29,9 +29,11 @@
 
 ;;; TODO:
 
-;; Create language specific styles with names `gloss-<lang>.el'.  They should
-;; add `text<lang>' macros, `<lang>' environments (`Arabic' for `arabic'
-;; language), and the others language-specific commands.
+;;  -- Create language specific styles with names `gloss-<lang>.el'.  They
+;;     should add `text<lang>' macros, `<lang>' environments (`Arabic' for
+;;     `arabic' language), and the others language-specific commands.
+;;
+;;  -- Make autoloading of these style files really work.
 
 ;;; Code:
 
@@ -47,7 +49,7 @@
 
 (defvar LaTeX-polyglossia-setkeys-regexp
   (concat "\\\\setkeys"
-         "[ \t\n\r]*{\\([A-Za-z]+\\)}[ \t\n\r]*{\\([^}]\\)}")
+         "[ \t\n\r]*{\\([A-Za-z]+\\)}[ \t\n\r]*{\\([^}]*\\)}")
   "Matches polyglossia languages options set using \"\setkeys\".")
 
 (defvar LaTeX-auto-polyglossia-lang nil
@@ -81,7 +83,8 @@
   ;; In each element of the alist, the key is the language, the second value is
   ;; the polyglossia command which set the language, the rest of values is the
   ;; list of options given to the language.
-  (let (tmp newelt opts otheropts)
+  (let (opts otheropts)
+    (setq LaTeX-polyglossia-lang-list nil)
     (mapc
      (lambda (elt)
        (mapc
@@ -93,17 +96,15 @@
          ;; "\setkeys".
          (setq otheropts
                (car (cdr (assoc language LaTeX-auto-polyglossia-setkeys))))
-         (setq newelt
-               (append
-                (list language) (list (nth 1 elt))
-                (unless (equal opts '(""))
-                  (LaTeX-listify-package-options (car opts)))
-                (if otheropts (LaTeX-listify-package-options otheropts))))
-         (add-to-list 'LaTeX-polyglossia-lang-list newelt t)
-         (add-to-list 'tmp newelt t))
+         (add-to-list
+          'LaTeX-polyglossia-lang-list
+          (append
+           (list language) (list (nth 1 elt))
+           (unless (equal opts '(""))
+             (LaTeX-listify-package-options (car opts)))
+           (if otheropts (LaTeX-listify-package-options otheropts))) t))
        (LaTeX-listify-package-options (car elt))))
-     LaTeX-auto-polyglossia-lang)
-    (setq LaTeX-auto-polyglossia-lang tmp)))
+     LaTeX-auto-polyglossia-lang)))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-polyglossia-prepare)
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-polyglossia-cleanup)
@@ -133,13 +134,13 @@ The last language is the default one."
                         (string-equal "mainlanguage" (nth 1 elt))))
        ;; Append the language to the list if it's the default one.
        (add-to-list 'active-languages (car elt) default))
-     (LaTeX-polyglossia-lang-list))
+     LaTeX-polyglossia-lang-list)
     active-languages))
 
 (defun LaTeX-polyglossia-lang-option-member (language option)
   "Return non-nil if OPTION has been given to polyglossia LANGUAGE.
 The value is actually the tail of the list of options given to LANGUAGE."
-  (member option (cdr (cdr (assoc language (LaTeX-polyglossia-lang-list))))))
+  (member option (cdr (cdr (assoc language LaTeX-polyglossia-lang-list)))))
 
 (defun LaTeX-arg-polyglossia-lang (_optional default multiple setkeys)
   "Prompt for language and its options with completion and insert them
@@ -216,6 +217,11 @@ argument, otherwise as a mandatory one."
                     ;; ("localnumber")
                     )))
 
+(defun LaTeX-polyglossia-load-languages ()
+  "Load style files of babel active languages."
+  (mapc (lambda (elt) (TeX-run-style-hooks (concat "gloss-" elt)))
+       (LaTeX-polyglossia-active-languages)))
+
 (TeX-add-style-hook
  "polyglossia"
  (lambda ()
@@ -224,9 +230,10 @@ argument, otherwise as a mandatory one."
     `(,LaTeX-polyglossia-lang-regexp (3 1 2) LaTeX-auto-polyglossia-lang))
    (TeX-auto-add-regexp
     `(,LaTeX-polyglossia-setkeys-regexp (1 2) LaTeX-auto-polyglossia-setkeys))
-   ;; Run style hooks for every active language.
-   (mapc (lambda (elt) (TeX-run-style-hooks (concat "gloss-" elt)))
-        (LaTeX-polyglossia-active-languages))
+   ;; Run style hooks for every active language.  FIXME: actually
+   ;; `LaTeX-polyglossia-active-languages' returns nil here, so no style hook 
is
+   ;; automatically loaded.
+   (LaTeX-polyglossia-load-languages)
    (TeX-run-style-hooks "etoolbox" "makecmds" "xkeyval" "fontspec")
    (TeX-add-symbols
     '("setdefaultlanguage" (LaTeX-arg-polyglossia-lang  t  nil nil))
@@ -319,10 +326,6 @@ argument, otherwise as a mandatory one."
   '(("numerals" ("Western" "Devanagari")))
   "Hindi language options for the polyglossia package.")
 
-(defvar LaTeX-polyglossia-italian-options-list
-  '(("babelshorthands" ("true" "false")))
-  "Italian language options for the polyglossia package.")
-
 (defvar LaTeX-polyglossia-lao-options-list
   '(("numerals" ("lao" "arabic")))
   "Lao language options for the polyglossia package.")



reply via email to

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