[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 8e13306 66/71: Update style/url.el to package ve
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 8e13306 66/71: Update style/url.el to package version 3.4 |
Date: |
Fri, 17 Dec 2021 15:00:38 -0500 (EST) |
branch: externals/auctex
commit 8e133062a06726e58f4d13d338ad339db00f1512
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Update style/url.el to package version 3.4
* style/url.el: Add parsing abilities for the macros \urldef and
\DeclareUrlCommand.
(TeX-arg-url-urlstyle): New function renamed from
`TeX-arg-urlstyle'.
(TeX-arg-url-DeclareUrlCommand, TeX-arg-url-urldef): New
functions.
("url"): Remove macros for setting new styles, linebreaks
etc. from fontification. Move '\urlstyle' to function class.
(LaTeX-url-package-options): Update package options.
---
style/url.el | 181 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 147 insertions(+), 34 deletions(-)
diff --git a/style/url.el b/style/url.el
index eafbd90..8c186cf 100644
--- a/style/url.el
+++ b/style/url.el
@@ -26,7 +26,7 @@
;;; Commentary:
-;; This file adds support for `url.sty'.
+;; This file adds support for `url.sty' v3.4 dated 2013-09-16.
;;; Code:
@@ -41,11 +41,131 @@
(declare-function font-latex-set-syntactic-keywords
"font-latex")
+;; Setup for \DeclareUrlCommand:
+(TeX-auto-add-type "url-DeclareUrlCommand" "LaTeX")
+
+(defvar LaTeX-url-DeclareUrlCommand-regexp
+ `(,(concat
+ "\\\\DeclareUrlCommand"
+ "[ \n\r\t]*"
+ "{?"
+ "\\\\\\([a-zA-Z]+\\)"
+ "}?")
+ 1 LaTeX-auto-url-DeclareUrlCommand)
+ "Matches the argument of `\\DeclareUrlCommand' from `url' package.")
+
+(defun LaTeX-url-DeclareUrlCommand-prepare ()
+ "Process macros parsed from `\\DeclareUrlCommand'."
+ ;; \DeclareUrlCommand\abc{settings}: makes \abc{ } like \url{ } with
+ ;; settings.
+ (when (LaTeX-url-DeclareUrlCommand-list)
+ (dolist (cmd (mapcar #'car (LaTeX-url-DeclareUrlCommand-list)))
+ (TeX-add-symbols `(,cmd TeX-arg-verb-delim-or-brace))
+ (add-to-list 'LaTeX-verbatim-macros-with-delims-local cmd)
+ (add-to-list 'LaTeX-verbatim-macros-with-braces-local cmd))
+ ;; Fontification
+ (when (and (fboundp 'font-latex-add-keywords)
+ (fboundp 'font-latex-set-syntactic-keywords)
+ (eq TeX-install-font-lock 'font-latex-setup))
+ (font-latex-add-keywords
+ (mapcar (lambda (cmd)
+ (list cmd ""))
+ (mapcar #'car (LaTeX-url-DeclareUrlCommand-list)))
+ 'reference)
+ ;; Tell font-lock about the update.
+ (font-latex-set-syntactic-keywords))))
+
+;; Setup for \urldef:
+(TeX-auto-add-type "url-urldef" "LaTeX")
+
+(defvar LaTeX-url-urldef-regexp
+ `(,(concat
+ "\\\\urldef"
+ "[ \n\r\t]*"
+ "{?"
+ "\\\\\\([a-zA-Z]+\\)"
+ "}?")
+ 1 LaTeX-auto-url-urldef)
+ "Matches the argument of `\\urldef' from `url' package.")
+
+(defun LaTeX-url-urldef-prepare ()
+ "Process macros parsed from `\\urldef'."
+ (when (LaTeX-url-urldef-list)
+ (mapc #'TeX-add-symbols (mapcar #'car (LaTeX-url-urldef-list)))
+ ;; Fontification
+ (when (and (fboundp 'font-latex-add-keywords)
+ (eq TeX-install-font-lock 'font-latex-setup))
+ (font-latex-add-keywords
+ (mapcar (lambda (cmd)
+ (list cmd ""))
+ (mapcar #'car (LaTeX-url-urldef-list)))
+ 'reference))))
+
+(defun LaTeX-url-auto-prepare ()
+ "Clear `LaTeX-auto-url-*' before parsing."
+ (setq LaTeX-auto-url-DeclareUrlCommand nil
+ LaTeX-auto-url-urldef nil))
+
+(defun LaTeX-url-auto-cleanup ()
+ "Process parsed elements from url.sty."
+ (LaTeX-url-DeclareUrlCommand-prepare)
+ (LaTeX-url-urldef-prepare))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-url-auto-prepare t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-url-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
+(defun TeX-arg-url-urlstyle (optional &optional prompt)
+ "Prompt for style used in \\urlstyle with completion.
+If OPTIONAL is non-nil, indicate it in the minibuffer during the
+query and insert the result in brackets. PROMPT replaces the
+standard one."
+ (TeX-argument-insert
+ (completing-read (TeX-argument-prompt optional prompt "Style")
+ '("rm" "same" "sf" "tt"))
+ optional))
+
+(defun TeX-arg-url-DeclareUrlCommand (optional &optional prompt)
+ "Prompt for arguments of \\DeclareUrlCommand with completion.
+If OPTIONAL is non-nil, indicate it in the minibuffer during the
+query and insert the result in brackets. PROMPT replaces the
+standard one."
+ (let ((cmd (TeX-read-string
+ (TeX-argument-prompt optional prompt "Command: \\" t)))
+ (style (completing-read
+ (TeX-argument-prompt optional prompt "Style")
+ '("rm" "same" "sf" "tt"))))
+ (insert TeX-esc cmd TeX-grop)
+ (when (and style (not (string= style "")))
+ (insert TeX-esc "urlstyle" TeX-grop style TeX-grcl))
+ (insert TeX-grcl)
+ (LaTeX-add-url-DeclareUrlCommands cmd)
+ (LaTeX-url-DeclareUrlCommand-prepare)))
+
+(defun TeX-arg-url-urldef (optional &optional prompt)
+ "Prompt for arguments of \\urldef with completion."
+ (let ((cmd (TeX-read-string
+ (TeX-argument-prompt optional prompt "Command: \\" t))))
+ (TeX-argument-insert cmd optional TeX-esc)
+ (LaTeX-add-url-urldefs cmd)
+ (LaTeX-url-urldef-prepare))
+ (TeX-insert-macro
+ (completing-read
+ (TeX-argument-prompt optional prompt "Macro: \\" t)
+ (append (mapcar #'car (LaTeX-url-DeclareUrlCommand-list))
+ '("url")))))
+
(TeX-add-style-hook
"url"
(lambda ()
+
+ ;; Add url to the parser
+ (TeX-auto-add-regexp LaTeX-url-DeclareUrlCommand-regexp)
+ (TeX-auto-add-regexp LaTeX-url-urldef-regexp)
+
;; New symbols
(TeX-add-symbols
+ ;; Macros for defining new styles, changing font, linebreaks etc.
"Url"
"UrlBigBreakPenalty"
"UrlBigBreaks"
@@ -57,56 +177,49 @@
"UrlOrds"
"UrlRight"
"UrlSpecials"
- '("path" (TeX-arg-verb-delim-or-brace "Path"))
+
;; "hyperref" redefines \url so that the argument is only in
;; braces. We check here if hyperref is loaded:
'("url" (TeX-arg-conditional (member "hyperref" (TeX-style-list))
("Url")
((TeX-arg-verb-delim-or-brace "Url"))))
- "urldef"
- '("urlstyle" TeX-arg-urlstyle))
- (add-to-list 'LaTeX-verbatim-macros-with-delims-local "path")
- ;; hyperref.el has some code to remove "url" from
- ;; `LaTeX-verbatim-macros-with-delims-local', but we check here as
- ;; well if "hyperref" is already loaded:
+ '("urldef" TeX-arg-url-urldef)
+
+ '("urlstyle" TeX-arg-url-urlstyle))
+
+ ;; For '\path', use the facilities provided by this style. Also
+ ;; don't add "path" for fontification below since
+ ;; `LaTeX-url-urldef-prepare' takes care of it.
+ (LaTeX-add-url-DeclareUrlCommands "path")
+ (LaTeX-url-urldef-prepare)
+
+ ;; Don't do the same for '\url' because hyperref.el has some code
+ ;; to remove "url" from `LaTeX-verbatim-macros-with-delims-local',
+ ;; but we check here as well if "hyperref" is already loaded:
(unless (member "hyperref" (TeX-style-list))
(add-to-list 'LaTeX-verbatim-macros-with-delims-local "url"))
- (add-to-list 'LaTeX-verbatim-macros-with-braces-local "path")
(add-to-list 'LaTeX-verbatim-macros-with-braces-local "url")
;; Fontification
(when (and (fboundp 'font-latex-add-keywords)
(eq TeX-install-font-lock 'font-latex-setup))
- (font-latex-add-keywords '(("path" "") ("url" "")) 'reference)
- (font-latex-add-keywords '(("Url" "")
- ("UrlBigBreakPenalty" "")
- ("UrlBigBreaks" "")
- ("UrlBreakPenalty" "")
- ("UrlBreaks" "")
- ("UrlFont" "")
- ("UrlLeft" "")
- ("UrlNoBreaks" "")
- ("UrlOrds" "")
- ("UrlRight" "")
- ("UrlSpecials" "")
- ("urldef" "")
- ("urlstyle" "{"))
- 'variable)
+ (font-latex-add-keywords '(("url" ""))
+ 'reference)
+ ;; Don't fontify the second argument of 'DeclareUrlCommand' since
+ ;; it gets the `font-latex-verbatim-face' from the first
+ ;; argument. Same applies also to '\urldef' where we don't
+ ;; fontify any arguments:
+ (font-latex-add-keywords '(("DeclareUrlCommand" "\\")
+ ("urldef" "")
+ ("urlstyle" "{"))
+ 'function)
;; Tell font-lock about the update.
(font-latex-set-syntactic-keywords)))
TeX-dialect)
-(defun TeX-arg-urlstyle (optional &optional prompt)
- "Prompt for style used in \\urlstyle with completion."
- (TeX-argument-insert
- (completing-read (TeX-argument-prompt optional prompt "Style")
- '("rm" "same" "sf" "tt")
- nil t)
- optional))
-
-(defvar LaTeX-url-package-options '("hyphens" "obeyspaces" "spaces" "LY1"
- "T1" "allowmove")
+(defvar LaTeX-url-package-options '("hyphens" "obeyspaces" "spaces"
+ "allowmove" "lowtilde")
"Package options for the url package.")
;;; url.el ends here
- [elpa] externals/auctex 380bc4a 06/71: Handle optional embellishment arguments correctly, (continued)
- [elpa] externals/auctex 380bc4a 06/71: Handle optional embellishment arguments correctly, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex bd723c7 24/71: Cater for corner case when dealing with TeX error, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 6433dc3 30/71: Extend `TeX-read-key-val' to accept a function call, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex df69443 26/71: ; Silence the compiler, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 8e0fb65 47/71: Improve handling of key=vals in style/listings.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 0419539 37/71: Improve style/babel.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex d62d8f3 34/71: Update style/fontspec.el to package version 2.7i, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex b9545c8 45/71: Improve handling of key=vals in style/fancyvrb.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 9e97edc 49/71: Fix wrong logic of the previous commit, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 8c50665 62/71: Add new style/unicodefonttable.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 8e13306 66/71: Update style/url.el to package version 3.4,
Tassilo Horn <=
- [elpa] externals/auctex 25c8d0f 12/71: Add NEWS for two commands available in Texinfo mode, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 2e26d49 61/71: Update style/siunitx.el to package version 3, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex ee37db3 33/71: Supplement doc string, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex d77f49e 54/71: Fontify \tabularnewline macro, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 7c4147b 57/71: Improve handling of key=vals in style/tcolorbox.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex c6350aa 07/71: Track standardized generic hook names in LaTeX kernel, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 2db5e3c 40/71: Improve handling of key=vals style/newfloat.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 2e968b6 36/71: ; Fix escapings, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 0376fd2 32/71: ; Fix doc strings, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex df0545f 39/71: Improve handling of key=vals in style/empheq.el, Tassilo Horn, 2021/12/17