[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 207/299: Add font name completion in fontspec.el.
From: |
Stefan Monnier |
Subject: |
[elpa] 207/299: Add font name completion in fontspec.el. |
Date: |
Sun, 02 Nov 2014 03:11:28 +0000 |
monnier pushed a commit to branch externals/auctex
in repository elpa.
commit 68d2559f1672d9992fb70a5a35e2b3e2e78ff88e
Author: Mosè Giordano <address@hidden>
Date: Tue Dec 24 17:33:19 2013 +0100
Add font name completion in fontspec.el.
* tex-style.el (LaTeX-fontspec-arg-font-search): New customizable
variable.
(LaTeX-fontspec-font-list-default): Ditto.
* style/fontspec.el (LaTeX-fontspec-arg-font): New function.
("fontspec"): Use it.
* doc/changes.texi: Mention `LaTeX-fontspec-arg-font-search' and
`LaTeX-fontspec-font-list-default'.
---
ChangeLog | 12 ++++++++++++
doc/changes.texi | 5 +++--
style/fontspec.el | 46 +++++++++++++++++++++++++++++++++++++++-------
tex-style.el | 25 +++++++++++++++++++++++++
4 files changed, 79 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 63945c8..0c376c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2013-12-24 Mos� Giordano <address@hidden>
+
+ * tex-style.el (LaTeX-fontspec-arg-font-search): New customizable
+ variable.
+ (LaTeX-fontspec-font-list-default): Ditto.
+
+ * style/fontspec.el (LaTeX-fontspec-arg-font): New function.
+ ("fontspec"): Use it.
+
+ * doc/changes.texi: Mention `LaTeX-fontspec-arg-font-search' and
+ `LaTeX-fontspec-font-list-default'.
+
2013-12-20 Mos� Giordano <address@hidden>
* style/imakeidx.el ("imakeidx"): Move addition of options to
diff --git a/doc/changes.texi b/doc/changes.texi
index a6147fb..bd7d782 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -39,8 +39,9 @@ Completion for class options of the standard @LaTeX{} classes
is
provided as well.
@item
-New user options @code{LaTeX-default-author} and
address@hidden A new possible value
+New user options @code{LaTeX-default-author},
address@hidden, @code{LaTeX-fontspec-arg-font-search},
+and @code{LaTeX-fontspec-font-list-default}. A new possible value
(@code{show-all-optional-args}) for
@code{TeX-insert-macro-default-style} was added.
diff --git a/style/fontspec.el b/style/fontspec.el
index 90286b5..f9137fb 100644
--- a/style/fontspec.el
+++ b/style/fontspec.el
@@ -131,6 +131,38 @@
("Vertical" ("RotatedGlyphs")))
"Font features options for macros of the fontspec package.")
+(defvar LaTeX-fontspec-font-list nil
+ "List of the fonts accessible to fontspec.")
+
+(defun LaTeX-fontspec-arg-font (optional &optional prompt)
+ "Prompt for a font name with completion.
+If OPTIONAL is non-nil, insert the resulting value as an optional
+argument, otherwise as a mandatory one. Use PROMPT as the prompt
+string.
+
+Customize `LaTeX-fontspec-arg-font-search' in order to decide how
+to retrieve the list of fonts."
+ (unless LaTeX-fontspec-font-list
+ (when (if (eq LaTeX-fontspec-arg-font-search 'ask)
+ (not (y-or-n-p "Find font yourself? "))
+ LaTeX-fontspec-arg-font-search)
+ (message "Searching for fonts...")
+ (with-temp-buffer
+ (shell-command "luaotfload-tool --list=basename" t)
+ ;; Search for the font base names and full names, and add them to
+ ;; `LaTeX-fontspec-font-list'. The list is in the form
+ ;; <base name><TAB><full name><TAB><version>
+ (while
+ (re-search-forward "^\\([^\n\r\t]*\\)\t\\([^\n\r\t]*\\)\t.*$" nil t)
+ (add-to-list 'LaTeX-fontspec-font-list (match-string-no-properties 1))
+ (add-to-list 'LaTeX-fontspec-font-list
+ (match-string-no-properties 2))))))
+ (TeX-argument-insert
+ (completing-read
+ (TeX-argument-prompt optional prompt "Font name")
+ (or LaTeX-fontspec-font-list LaTeX-fontspec-font-list-default))
+ optional))
+
(TeX-add-style-hook
"fontspec"
(lambda ()
@@ -138,24 +170,24 @@
(TeX-add-symbols
;; Font selection
'("fontspec" [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
- "Font name")
+ LaTeX-fontspec-arg-font)
;; Default font families
'("setmainfont"
[TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
- "Main font name")
+ (LaTeX-fontspec-arg-font "Main font name"))
'("setsansfont"
[TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
- "Sans font name")
+ (LaTeX-fontspec-arg-font "Sans font name"))
'("setmonofont"
[TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
- "Mono font name")
+ (LaTeX-fontspec-arg-font "Mono font name"))
;; New commands to select font families
'("newfontfamily" TeX-arg-define-macro
[TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
- "Font name")
+ LaTeX-fontspec-arg-font)
'("newfontface" TeX-arg-define-macro
[TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
- "Font name")
+ LaTeX-fontspec-arg-font)
;; Math(s) fonts
'("setmathrm" [ "Font features" ] "Font name")
'("setmathsf" [ "Font features" ] "Font name")
@@ -165,7 +197,7 @@
"emshape"
"eminnershape"
;; Default settings
- '("defaultfontfeatures" [ "Font name" ]
+ '("defaultfontfeatures" [ LaTeX-fontspec-arg-font ]
(TeX-arg-key-val LaTeX-fontspec-font-features "Font features"))
;; Changing the currently selected features
'("addfontfeatures"
diff --git a/tex-style.el b/tex-style.el
index 05a706e..b403db1 100644
--- a/tex-style.el
+++ b/tex-style.el
@@ -254,6 +254,31 @@ produced by emp.sty and then re-LaTeX the document."
:type 'boolean
:group 'LaTeX-style)
+;; style/fontspec.el
+
+(defcustom LaTeX-fontspec-arg-font-search t
+ "If `LaTeX-fontspec-arg-font' should search for fonts.
+If the value is t, fonts are retrieved automatically and provided
+for completion. If the value is nil,
+`LaTeX-fontspec-font-list-default' is used for completion. If
+the value is `ask', you are asked for the method to use every
+time `LaTeX-fontspec-arg-font' is called.
+
+`LaTeX-fontspec-arg-font' calls `luaotf-load --list=basename' to
+automatically get the list of fonts. This requires
+`luaotfload-tool' version 2.3 or higher in order to work."
+ :group 'LaTeX-style
+ :type '(choice
+ (const :tag "Search automatically" t)
+ (const :tag "Use default font list" nil)
+ (const :tag "Ask what to do" ask)))
+
+(defcustom LaTeX-fontspec-font-list-default nil
+ "List of default fonts to be used as completion for
+`LaTeX-fontspec-arg-font'."
+ :group 'LaTeX-style
+ :type '(repeat (string :tag "Font")))
+
;; style/graphicx.el
(defcustom LaTeX-includegraphics-extensions
- [elpa] 198/299: Declare expert macros and envs in biblatex style file., (continued)
- [elpa] 198/299: Declare expert macros and envs in biblatex style file., Stefan Monnier, 2014/11/01
- [elpa] 194/299: Distinguish normal and expert macros/envs., Stefan Monnier, 2014/11/01
- [elpa] 196/299: * bib-cite.el (bib-highlight-mouse): Change regexp to cope with multiple optional arguments of a macro., Stefan Monnier, 2014/11/01
- [elpa] 192/299: Revert "Distinguish common and advanced macros/envs.", Stefan Monnier, 2014/11/01
- [elpa] 197/299: Fix C-x ` (next-error) for compile commands., Stefan Monnier, 2014/11/01
- [elpa] 200/299: Fix of the fix, my fault., Stefan Monnier, 2014/11/01
- [elpa] 195/299: Better signature of expert declaration functions., Stefan Monnier, 2014/11/01
- [elpa] 204/299: Revert "Skip comment or file in parens in output.", Stefan Monnier, 2014/11/01
- [elpa] 201/299: Disable electric-pair-mode., Stefan Monnier, 2014/11/01
- [elpa] 191/299: Distinguish common and advanced macros/envs., Stefan Monnier, 2014/11/01
- [elpa] 207/299: Add font name completion in fontspec.el.,
Stefan Monnier <=
- [elpa] 202/299: Disable electric-pair-mode conditionally., Stefan Monnier, 2014/11/01
- [elpa] 205/299: Handle package messages with parenthesized text., Stefan Monnier, 2014/11/01
- [elpa] 208/299: Use TeX-electric-math in LaTeX-math-insert/cal., Stefan Monnier, 2014/11/01
- [elpa] 199/299: Fix bindings of narrowing functions., Stefan Monnier, 2014/11/01
- [elpa] 209/299: Fix a bug with reftex where tex-info and LaTeX interferred., Stefan Monnier, 2014/11/01
- [elpa] 206/299: New style files and a fix to imakeidx.el., Stefan Monnier, 2014/11/01
- [elpa] 203/299: Skip comment or file in parens in output., Stefan Monnier, 2014/11/01
- [elpa] 211/299: Adapt style/babel.el to babel 3.9., Stefan Monnier, 2014/11/01
- [elpa] 210/299: Make search for \begin and \end case sensitive., Stefan Monnier, 2014/11/01
- [elpa] 214/299: Fix syntactic fontification., Stefan Monnier, 2014/11/01