all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Reza Nikoopour <rnikoopour@gmail.com>
To: emacs-devel@gnu.org
Subject: Help with Fontification
Date: Tue, 2 Nov 2021 21:00:40 -0700	[thread overview]
Message-ID: <CAKesZq2n1M2SKUyxEggHWKzPocN=WV=QM0YBurFr8Lcnuo41jA@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1076 bytes --]

Hello All,

I'm working on refactoring terraform mode and I've stumbled across
a fontification issue I cannot figure out how to solve.

[image: image.png]

A resource can be broken down into the three parts:
The keyword "resource", the resource type (green in the image), and the
resource
name (pink in the image).

The resource name and type are string literals so I
used the override flag for the regex when setting font-lock-defaults:
(defvar terraform-font-lock-keywords
  ;; other code
  (,terraform--block-builtins-with-type-and-name--type-highlight-regexp 2
'terraform--resource-type t)
  (,terraform--block-builtins-with-type-and-name--name-highlight-regexp 3
'terraform--resource-name t)))

(define-derived-mode terraform-mode prog-mode "Terraform"
  ;; other code
  (setq font-lock-defaults '((terraform-font-lock-keywords))))

However, this is causing the issue above where the search based
highlighting is
overriding the comment highlighting.

Is there a way to only have search based fontification only override
strings but
keep comments unaltered?

Cheers,
Reza

[-- Attachment #1.2: Type: text/html, Size: 1383 bytes --]

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 7516 bytes --]

             reply	other threads:[~2021-11-03  4:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03  4:00 Reza Nikoopour [this message]
2021-11-03 11:56 ` Help with Fontification Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKesZq2n1M2SKUyxEggHWKzPocN=WV=QM0YBurFr8Lcnuo41jA@mail.gmail.com' \
    --to=rnikoopour@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.