[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Updating xparse.el
From: |
Arash Esbati |
Subject: |
Re: Updating xparse.el |
Date: |
Wed, 09 Sep 2020 22:37:10 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 |
Hi Florent,
Florent Rougon <f.rougon@free.fr> writes:
> Arash Esbati <arash@gnu.org> wrote:
>
>> I don't think it is a big deal to provide a custom variable, say,
>> `font-latex-fontify-code-arguments' and then apply a conditional to the
>> style files in the fontification section.
>>
>> What do others think? Any idea for a better variable name?
>
> That would be a great improvement, IMHO. Of course, by “not fontifying
> code arguments,” what I really mean is “fontify them as if they were not
> macro arguments.” IOW, I'm happy with little things being fontified
> inside the “replacement text” argument of a command. What I don't like
> is when the whole code is forcibly colored in blue, which kills the
> finer fontification one would have if the same code were outside a macro
> argument. Example of what I like (my setup):
>
> https://imgur.com/a/7ADVb5e
>
> As you can see, the #1 and #2 inside the code arguments are not in the
> same face as the rest of said arguments, and that's quite fine with me.
Sorry for my late response. I had a second thought on this and came up
with the name `font-latex-fontify-replacement-text'. A patch to
xparse.el can look like this:
--8<---------------cut here---------------start------------->8---
diff --git a/style/xparse.el b/style/xparse.el
index 79ab6042..fdab749e 100644
--- a/style/xparse.el
+++ b/style/xparse.el
@@ -287,21 +287,35 @@ TYPE is one of the symobols mac or env."
;; Fontification
(when (and (featurep 'font-latex)
(eq TeX-install-font-lock 'font-latex-setup))
- (font-latex-add-keywords '(("DeclareDocumentCommand" "|{\\{{")
- ("NewDocumentCommand" "|{\\{{")
- ("ProvideDocumentCommand" "|{\\{{")
- ("RenewDocumentCommand" "|{\\{{")
- ;;
- ("DeclareExpandableDocumentCommand" "|{\\{{")
- ("NewExpandableDocumentCommand" "|{\\{{")
- ("ProvideExpandableDocumentCommand" "|{\\{{")
- ("RenewExpandableDocumentCommand" "|{\\{{")
- ;;
- ("DeclareDocumentEnvironment" "{{{{")
- ("NewDocumentEnvironment" "{{{{")
- ("ProvideDocumentEnvironment" "{{{{")
- ("RenewDocumentEnvironment" "{{{{"))
- 'function)))
+ (defcustom font-latex-fontify-replacement-text t
+ "Non-nil means fontify replacement text of macros.
+This option is mainly relevant for .dtx or .sty file writers."
+ :group 'font-latex
+ :type 'boolean)
+ (put 'font-latex-fontify-replacement-text
+ 'safe-local-variable
+ #'booleanp)
+ (let ((macs (if font-latex-fontify-replacement-text
+ "|{\\{{"
+ "|{\\{"))
+ (envs (if font-latex-fontify-replacement-text
+ "{{{{"
+ "{{")))
+ (font-latex-add-keywords `(("DeclareDocumentCommand" ,macs)
+ ("NewDocumentCommand" ,macs)
+ ("ProvideDocumentCommand" ,macs)
+ ("RenewDocumentCommand" ,macs)
+ ;;
+ ("DeclareExpandableDocumentCommand" ,macs)
+ ("NewExpandableDocumentCommand" ,macs)
+ ("ProvideExpandableDocumentCommand" ,macs)
+ ("RenewExpandableDocumentCommand" ,macs)
+ ;;
+ ("DeclareDocumentEnvironment" ,envs)
+ ("NewDocumentEnvironment" ,envs)
+ ("ProvideDocumentEnvironment" ,envs)
+ ("RenewDocumentEnvironment" ,envs))
+ 'function))))
LaTeX-dialect)
(defun LaTeX-xparse-package-options ()
--8<---------------cut here---------------end--------------->8---
The variable will eventually land in font-latex.el, I put it in
xparse.el for testing purposes. The style file is attached, do you want
to give it a roll?
> Thanks for your great work; AUCTeX is truly a very well maintained
> project!
Thank you for your kind words, enjoy!
Best, Arash
xparse.el.gz
Description: Binary data
- Re: Updating xparse.el,
Arash Esbati <=