branch: externals/auctex commit 971becefd27858aac2bef8306e5069ae9bfd6d94 Author: Arash Esbati <ar...@gnu.org> Commit: Arash Esbati <ar...@gnu.org>
Update style/csquotes.el to package version 5.2j * style/csquotes.el: Track changes in package version 5.2j. Remove deprecated macros, improve query for language argument. Add keyval query of package options. (LaTeX-csquotes-insert-environment): Remove function and use `LaTeX-env-args' instead. --- style/csquotes.el | 470 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 304 insertions(+), 166 deletions(-) diff --git a/style/csquotes.el b/style/csquotes.el index a34a775..8f64627 100644 --- a/style/csquotes.el +++ b/style/csquotes.el @@ -1,6 +1,6 @@ -;;; csquotes.el --- AUCTeX style for `csquotes.sty' +;;; csquotes.el --- AUCTeX style for `csquotes.sty' (v5.2j) -;; Copyright (C) 2004, 2005, 2006, 2014, 2018 Free Software Foundation, Inc. +;; Copyright (C) 2004, 2005, 2006, 2014, 2018, 2020 Free Software Foundation, Inc. ;; Author: Ralf Angeli <ang...@caeruleus.net> ;; Maintainer: auctex-de...@gnu.org @@ -26,7 +26,8 @@ ;;; Commentary: -;; This file adds support for `csquotes.sty', version 3.7. +;; This file adds support for `csquotes.sty', version 5.2j from +;; 2019/12/06. ;;; Code: @@ -35,109 +36,165 @@ "font-latex" (keywords class)) -;; FIXME: It would be nice to be able to dump this function in favor -;; of a generalized handling of additional arguments for environments -;; specified via `LaTeX-add-environments'. `TeX-parse-arguments' and -;; friends would be the functions to be used for that, but those -;; functions currently insert text directly into the buffer. There -;; would either have to be a way of preventing this and letting them -;; return a string, or the insertion could happen in a temporary buffer -;; and the buffer content be returned. -(defun LaTeX-csquotes-insert-environment (env &rest args) - "Insert environment ENV considering optional arguments ARGS. - -This is basically a variant of `LaTeX-environment-menu' -specialized for csquotes.el. ARGS can be made up of strings and -vectors containing single strings. Plain strings will be used as -prompts for mandatory arguments and strings in vectors as prompts -for optional arguments of the environment to be inserted. - -That means, in contrast to `LaTeX-environment-menu' it supports -the insertion of optional arguments." - (let (env-extra prompt optional user-input) - (dolist (elt args) - (if (vectorp elt) - (setq prompt (aref elt 0) - optional t) - (setq prompt elt - optional nil)) - (setq user-input (TeX-read-string (TeX-argument-prompt optional prompt nil))) - (unless (and optional (zerop (length user-input))) - (setq env-extra (concat env-extra - (if optional LaTeX-optop TeX-grop) - user-input - (if optional LaTeX-optcl TeX-grcl))))) - (LaTeX-insert-environment env env-extra))) +(defun LaTeX-csquotes-read-language (optional &optional prompt) + "Read and return a language for csquotes macros. +If OPTIONAL is non-nil, indicate it in minibuffer while reading +user input. PROMPT replaces the standard one \"Language\". This +function checks if the functions `LaTeX-babel-active-languages' +or `LaTeX-polyglossia-active-languages' are bound and use them to +retrieve the active languages. If none available, user is +requested to enter a language." + (cond ((and (fboundp 'LaTeX-babel-active-languages) + (LaTeX-babel-active-languages)) + (completing-read + (TeX-argument-prompt optional prompt "Language") + (LaTeX-babel-active-languages))) + ((and (fboundp 'LaTeX-polyglossia-active-languages) + (LaTeX-polyglossia-active-languages)) + (completing-read + (TeX-argument-prompt optional prompt "Language") + (LaTeX-polyglossia-active-languages))) + (t + (TeX-read-string + (TeX-argument-prompt optional prompt "Language"))))) + +(defun LaTeX-arg-csquotes-language (optional &optional prompt) + "Insert a language for csquotes macros. +If OPTIONAL is non-nil, insert the language in square brackets. +PROMPT replaces the standard one \"Language\"." + (TeX-argument-insert + (LaTeX-csquotes-read-language optional prompt) + optional)) (TeX-add-style-hook "csquotes" (lambda () - (let ((quote-style-variant-list '(("quotes") ("guillemets") ("american") - ("british") ("oldstyle") ("imprimerie") - ("swiss"))) - (quote-style-name-list '(("danish") ("dutch") ("english") ("finnish") - ("french") ("german") ("italian") - ("norwegian") ("swedish")))) + (let ((quote-style-variant-list '(("american") ("brazilian") + ("british") ("german") + ("guillemets") ("guillemets*") + ("mexican") ("portuguese") + ("quotes") ("quotes*") + ("spanish") ("swiss"))) + (quote-style-name-list '(("austrian") ("croatian") ("czech") + ("danish") ("dutch") ("english") + ("finnish") ("french") ("german") + ("greek") ("italian") ("norwegian") + ("portuguese") ("russian") ("serbian") + ("spanish") ("swedish")))) ;; New symbols (TeX-add-symbols + + ;; 3.1 Quoting Regular Text '("enquote" 1) '("enquote*" 1) - '("foreignquote" 2) - '("foreignquote*" 2) - '("hyphenquote" 2) - '("hyphenquote*" 2) - '("textquote" ["Citation"] ["Punctuation"] t) + + ;; 3.2 Quoting Text in a Foreign Language + '("foreignquote" LaTeX-arg-csquotes-language 1) + '("foreignquote*" LaTeX-arg-csquotes-language 1) + '("hyphenquote" LaTeX-arg-csquotes-language 1) + '("hyphenquote*" LaTeX-arg-csquotes-language 1) + + ;; 3.3 Formal Quoting of Regular Text + '("textquote" ["Citation"] ["Punctuation"] t) '("textquote*" ["Citation"] ["Punctuation"] t) - '("foreigntextquote" "Language" ["Citation"] ["Punctuation"] t) - '("foreigntextquote*" "Language" ["Citation"] ["Punctuation"] t) - '("hyphentextquote" "Language" ["Citation"] ["Punctuation"] t) - '("hyphentextquote*" "Language" ["Citation"] ["Punctuation"] t) + + ;; 3.4 Formal Quoting of Text in a Foreign Language + '("foreigntextquote" + LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t) + '("foreigntextquote*" + LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t) + '("hyphentextquote" + LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t) + '("hyphentextquote*" + LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t) + + ;; 3.5 Block Quoting of Regular Text '("blockquote" ["Citation"] ["Punctuation"] t) - '("foreignblockquote" "Language" ["Citation"] ["Punctuation"] t) - '("hyphenblockquote" "Language" ["Citation"] ["Punctuation"] t) + + ;; 3.6 Block Quoting of Text in a Foreign Language + '("foreignblockquote" + LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t) + '("hyphenblockquote" + LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t) + '("hybridblockquote" + LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t) + + ;; 3.7 Selecting Quote Styles `("setquotestyle" [ (TeX-arg-eval completing-read "Quote style variant: " ',quote-style-variant-list) ] (TeX-arg-eval completing-read "Quote style name or alias: " ',quote-style-name-list)) "setquotestyle*" + + ;; 4.1 Quoting Regular Text '("MakeInnerQuote" "Character") '("MakeOuterQuote" "Character") - '("MakeAutoQuote" "Opening quotation mark" "Closing quotation mark") + '("MakeAutoQuote" "Opening quotation mark" "Closing quotation mark") '("MakeAutoQuote*" "Opening quotation mark" "Closing quotation mark") - '("MakeForeignQuote" "Babel's language name" + + ;; 4.2 Quoting Text in a Foreign Language + '("MakeForeignQuote" LaTeX-arg-csquotes-language "Opening quotation mark" "Closing quotation mark") - '("MakeForeignQuote*" "Babel's language name" + '("MakeForeignQuote*" LaTeX-arg-csquotes-language "Opening quotation mark" "Closing quotation mark") - '("MakeHyphenQuote" "Babel's language name" + + '("MakeHyphenQuote" LaTeX-arg-csquotes-language "Opening quotation mark" "Closing quotation mark") - '("MakeHyphenQuote" "Babel's language name" + '("MakeHyphenQuote" LaTeX-arg-csquotes-language "Opening quotation mark" "Closing quotation mark") + + ;; 4.3 Block Quoting of Regular Text '("MakeBlockQuote" "Opening quotation mark" "Delimiter for citation" "Closing quotation mark") - '("MakeForeignBlockQuote" "Language" "Opening quotation mark" - "Delimiter for citation" "Closing quotation mark") - '("MakeHyphenBlockQuote" "Language" "Opening quotation mark" - "Delimiter for citation" "Closing quotation mark") + + ;; 4.4 Block Quoting of Text in a Foreign Language + '("MakeForeignBlockQuote" LaTeX-arg-csquotes-language + "Opening quotation mark" "Delimiter for citation" "Closing quotation mark") + '("MakeHyphenBlockQuote" LaTeX-arg-csquotes-language + "Opening quotation mark" "Delimiter for citation" "Closing quotation mark") + '("MakeHybridBlockQuote" LaTeX-arg-csquotes-language + "Opening quotation mark" "Delimiter for citation" "Closing quotation mark") + + ;; 4.5 Controlling Active Quotes "EnableQuotes" "DisableQuotes" "VerbatimQuotes" "DeleteQuotes" - '("textcquote" ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t) + + ;; 5.1 Formal Quoting of Regular Text + '("textcquote" ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t) '("textcquote*" ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t) - '("foreigntextcquote" "Language" ["Pre-note"] ["Post-note"] "Key" - ["Punctuation"] t) - '("foreigntextcquote*" "Language" ["Pre-note"] ["Post-note"] "Key" - ["Punctuation"] t) - '("hyphentextcquote" "Language" ["Pre-note"] ["Post-note"] "Key" - ["Punctuation"] t) - '("hyphentextcquote*" "Language" ["Pre-note"] ["Post-note"] "Key" - ["Punctuation"] t) + + ;; 5.2 Formal Quoting of Text in a Foreign Language + '("foreigntextcquote" LaTeX-arg-csquotes-language + ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t) + '("foreigntextcquote*" LaTeX-arg-csquotes-language + ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t) + '("hyphentextcquote" LaTeX-arg-csquotes-language + ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t) + '("hyphentextcquote*" LaTeX-arg-csquotes-language + ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t) + + ;; 5.3 Block Quoting of Regular Text '("blockcquote" ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t) - '("foreignblockcquote" "Language" ["Pre-note"] ["Post-note"] "Key" - ["Punctuation"] t) - '("hyphenblockcquote" "Language" ["Pre-note"] ["Post-note"] "Key" - ["Punctuation"] t) + + ;; 5.4 Block Quoting of Text in a Foreign Language + '("foreignblockcquote" LaTeX-arg-csquotes-language + ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t) + '("hyphenblockcquote" LaTeX-arg-csquotes-language + ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t) + '("hybridblockcquote" LaTeX-arg-csquotes-language + ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t) + + ;; 7 Auxiliary Commands + '("textelp" 1) + '("textelp*" 1) + '("textins" 1) + '("textins*" 1) + '("textdel" 1) + + ;; 8.1 Defining Quote Styles `("DeclareQuoteStyle" [ (TeX-arg-eval completing-read "Quote style variant: " ',quote-style-variant-list) ] @@ -154,97 +211,178 @@ the insertion of optional arguments." (TeX-arg-eval completing-read "Quote style name: " ',quote-style-name-list) "Alias name") - '("DeclareQuoteOption" 1) - '("ExecuteQuoteOptions" 1) - '("DeclarePlainStyle" "Opening outer quotation mark" - "Closing outer quotation mark" "Opening inner quotation mark" - "Closing inner quotation mark") - '("SetBlockThreshold" "Number of lines") - '("SetBlockEnvironment" "Environment") - '("SetCiteCommand" "Command") - "mkcitation" - "mkccitation" - "mkpreblockpunct" - "mkmidblockpunct" - "mkfinblockpunct" - "mkpretextpunct" - "mkmidtextpunct" - "mkfintextpunct" - "mkpredisppunct" - "mkmiddisppunct" - "mkfindisppunct" - '("ifblockquote" 2) - '("ifquotepunct" 2) - '("ifquoteterm" 2) - '("ifquoteperiod" 2) - '("ifquotecomma" 2) - '("ifquotesemicolon" 2) - '("ifquotecolon" 2) - '("ifquoteexclam" 2) - '("ifquotequestion" 2) - '("ifstringblank" 2) - '("BlockquoteDisable" 1)) - ;; New environments - (LaTeX-add-environments - "quoteblock" - "quotetext" - '("displayquote" LaTeX-csquotes-insert-environment ["Citation"] - ["Punctuation"]) - '("foreigndisplayquote" LaTeX-csquotes-insert-environment "Language" - ["Citation"] ["Punctuation"]) - '("hyphendisplayquote" LaTeX-csquotes-insert-environment "Language" - ["Citation"] ["Punctuation"]) - '("displaycquote" LaTeX-csquotes-insert-environment - ["Pre-note"] ["Post-note"] "Key" ["Punctuation"]) - '("foreigndisplaycquote" LaTeX-csquotes-insert-environment - "Language" ["Pre-note"] ["Post-note"] "Key" ["Punctuation"]) - '("hyphendisplaycquote" LaTeX-csquotes-insert-environment - "Language" ["Pre-note"] ["Post-note"] "Key" ["Punctuation"])) - ;; Quotation marks - (when (and (> (length LaTeX-csquotes-open-quote) 0) - (> (length LaTeX-csquotes-close-quote) 0)) - (setq TeX-quote-language - `(override ,LaTeX-csquotes-open-quote ,LaTeX-csquotes-close-quote - ,LaTeX-csquotes-quote-after-quote))) - ;; Fontification - (when (and (featurep 'font-latex) - (eq TeX-install-font-lock 'font-latex-setup)) - (font-latex-add-keywords '(("DisableQuotes" "") - ("RestoreQuotes" "")) - 'function) - (font-latex-add-keywords '(("enquote" "*{") - ("foreignquote" "*{{") - ("hyphenquote" "*{{") - ("textcquote" "*[[{[{") - ("foreigntextcquote" "*{[[{[{") - ("hyphentextcquote" "*{[[{[{") - ("textquote" "*[[{") - ("foreigntextquote" "*{[[{") - ("hyphentextquote" "*{[[{") - ("blockquote" "[[{") - ("foreignblockquote" "{[[{") - ("hyphenblockquote" "{[[{") - ("blockcquote" "[[{[{") - ("foreignblockcquote" "{[[{[{") - ("hyphenblockcquote" "{[[{[{")) - 'textual) - (font-latex-add-keywords '(("setquotestyle" "[{") - ("MakeOuterQuote" "{") - ("MakeInnerQuote" "{") - ("MakeAutoQuote" "*{{") - ("MakeForeignQuote" "*{{{") - ("MakeHyphenQuote" "*{{{") - ("MakeBlockQuote" "{{{") - ("MakeForeignBlockQuote" "{{{{") - ("MakeHyphenBlockQuote" "{{{{") - ("DeclareQuoteStyle" "[{[[{[{[{[{") - ("DeclareQuoteAlias" "[{{") - ("DeclareQuoteOption" "{") - ("DeclarePlainStyle" "{{{{") - ("SetBlockThreshold" "{") - ("SetBlockEnvironment" "{") - ("SetCiteCommand" "{")) - 'variable)))) + '("DeclareQuoteOption" 1) + '("ExecuteQuoteOptions" 1) + '("DeclarePlainStyle" "Opening outer quotation mark" + "Closing outer quotation mark" "Opening inner quotation mark" + "Closing inner quotation mark") + '("SetBlockThreshold" "Number of lines") + '("SetBlockEnvironment" "Environment") + '("SetCiteCommand" "Command") + + ;; 8.7 Hooks for Quotations and Citations + "mkcitation" + "mkccitation" + "mktextquote" + "mkblockquote" + "mkbegdispquote" + "mkenddispquote" + + ;; 8.8 Additional Tests in Quotation Hooks + '("ifpunctmark" "Character" 2) + '("ifpunct" 2) + '("ifterm" 2) + '("iftextpunctmark" 4) + '("iftextpunct" 3) + '("iftextterm" 3) + '("ifblockquote" 2) + '("ifblank" 3) + "unspace" + + ;; 8.9 Configuring Punctuation Look-Ahead + '("DeclareAutoPunct" "Characters")) + + ;; New environments + (LaTeX-add-environments + + ;; 6.1 Basic Display Environments + '("displayquote" LaTeX-env-args + ["Citation"] ["Punctuation"]) + + '("foreigndisplayquote" LaTeX-env-args + LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"]) + + '("hyphendisplayquote" LaTeX-env-args + LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"]) + + ;; 6.2 Integrated Display Environments + '("displaycquote" LaTeX-env-args + ["Pre-note"] ["Post-note"] "Key" ["Punctuation"]) + + '("foreigndisplaycquote" LaTeX-env-args + LaTeX-arg-csquotes-language["Pre-note"] ["Post-note"] "Key" ["Punctuation"]) + + '("hyphendisplaycquote" LaTeX-env-args + LaTeX-arg-csquotes-language["Pre-note"] ["Post-note"] "Key" ["Punctuation"])) + + ;; Quotation marks + (when (and (> (length LaTeX-csquotes-open-quote) 0) + (> (length LaTeX-csquotes-close-quote) 0)) + (setq TeX-quote-language + `(override ,LaTeX-csquotes-open-quote ,LaTeX-csquotes-close-quote + ,LaTeX-csquotes-quote-after-quote))) + ;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("EnableQuotes" "") + ("DisableQuotes" "") + ("VerbatimQuotes" "") + ("DeleteQuotes" "")) + 'function) + (font-latex-add-keywords '(("enquote" "*{") + ("foreignquote" "*{{") + ("hyphenquote" "*{{") + ("textquote" "*[[{") + ("foreigntextquote" "*{[[{") + ("hyphentextquote" "*{[[{") + ("blockquote" "[[{") + ("foreignblockquote" "{[[{") + ("hyphenblockquote" "{[[{") + ("hybridblockquote" "{[[{") + ("textcquote" "*[[{[{") + ("foreigntextcquote" "*{[[{[{") + ("hyphentextcquote" "*{[[{[{") + ("blockcquote" "[[{[{") + ("foreignblockcquote" "{[[{[{") + ("hyphenblockcquote" "{[[{[{") + ("hybridblockcquote" "{[[{[{")) + 'textual) + (font-latex-add-keywords '(("setquotestyle" "[{") + ("MakeOuterQuote" "{") + ("MakeInnerQuote" "{") + ("MakeAutoQuote" "*{{") + ("MakeForeignQuote" "*{{{") + ("MakeHyphenQuote" "*{{{") + ("MakeBlockQuote" "{{{") + ("MakeForeignBlockQuote" "{{{{") + ("MakeHyphenBlockQuote" "{{{{") + ("DeclareQuoteStyle" "[{[[{[{[{[{") + ("DeclareQuoteAlias" "[{{") + ("DeclareQuoteOption" "{") + ("DeclarePlainStyle" "{{{{") + ("SetBlockThreshold" "{") + ("SetBlockEnvironment" "{") + ("SetCiteCommand" "{")) + 'variable)))) LaTeX-dialect) +(defun LaTeX-csquotes-package-options () + "Prompt for package options for the csquotes package." + (TeX-read-key-val t '(("strict" ("true" "false")) + ("style" ("american" + "australian" + "austrian" + "brazil" + "brazilian" + "british" + "canadian" + "croatian" + "czech" + "danish" + "dutch" + "english" + "finnish" + "french" + "german" + "greek" + "italian" + "mexican" + "naustrian" + "newzealand" + "ngerman" + "norsk" + "norwegian" + "nswissgerman" + "nynorsk" + "portuges" + "portuguese" + "russian" + "serbian" + "spanish" + "swedish" + "swiss" + "swissgerman" + "UKenglish" + "USenglish")) + ("autostyle" ("true" "false" "try" "once" "tryonce")) + ("austrian" ("quotes" "guillemets")) + ("croatian" ("quotes" "guillemets" "guillemets*")) + ("czech" ("quotes" "guillemets")) + ("danish" ("quotes" "guillemets" "topquotes")) + ("english" ("american" "british")) + ("estonian") + ("french" ("quotes" "quotes*" "guillemets" "guillemets*")) + ("galician" ("quotes" "guillemets")) + ("german" ("quotes" "guillemets" "swiss")) + ("hungarian") + ("italian" ("guillemets" "quotes")) + ("latvian") + ("norwegian" ("guillemets" "quotes")) + ("polish" ("guillemets" "guillemets*")) + ("portuguese" ("portuguese" "brazilian")) + ("serbian" ("quotes" "guillemets" "german")) + ("spanish" ("spanish" "mexican")) + ("swedish" ("quotes" "guillemets" "guillemets*")) + ("maxlevel") + ("autopunct" ("true" "false")) + ("threshold") + ("thresholdtype" ("lines" "words")) + ("parthreshold" ("true" "false")) + ("splitcomp" ("true" "false")) + ("csdisplay" ("true" "false")) + ("debug" ("true" "false")) + ;; "babel" key is deprecated, replaced by "autostyle": + ;; ("babel" ("true" "false" "try" "once" "tryonce")) + ("version" ("4.4" "3.6" "3.0"))))) + ;;; csquotes.el ends here