emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Add font-lock rule for inline export snippets
@ 2021-03-31 15:57 Timothy
  2021-04-28  7:23 ` Timothy
  2021-05-01 10:02 ` Bastien
  0 siblings, 2 replies; 3+ messages in thread
From: Timothy @ 2021-03-31 15:57 UTC (permalink / raw)
  To: org-mode-email

[-- Attachment #1: Type: text/plain, Size: 528 bytes --]


Hello,

The latest in my visually-oriented (mostly) short patch series, adding
basic fontification to inline export snippets --- @@comment:these things@@.

I think fontification for stuff like this is nice because it visually
indicates to the user that they've written out an Org construct, and
haven't just mis-remembered / imagined some syntax.

In future this could be extended to use native fontification for
recognised export formats (like src blocks do), but I think this is a
nice improvement over nothing.

--
Timothy


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-Add-font-lock-rule-for-inline-export-snippets.patch --]
[-- Type: text/x-patch, Size: 942 bytes --]

From 3584602f88381ab9624c767a83c18cfd93ffeaf0 Mon Sep 17 00:00:00 2001
From: TEC <tec@tecosaur.com>
Date: Wed, 31 Mar 2021 23:47:58 +0800
Subject: [PATCH] org: Add font-lock rule for inline export snippets

* lisp/org.el (org-set-font-lock-defaults): Add font-lock rule for
inline export snippets.
---
 lisp/org.el | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index f4d069504..240f745c7 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5719,6 +5719,11 @@ (defun org-set-font-lock-defaults ()
 	   ;; Description list items
 	   '("^[ \t]*[-+*][ \t]+\\(.*?[ \t]+::\\)\\([ \t]+\\|$\\)"
 	     1 'org-list-dt prepend)
+           ;; Inline export snippets
+           '("\\(@@\\)\\([a-z-]+:\\).*?\\(@@\\)"
+             (1 'font-lock-comment-face t)
+             (2 'org-tag t)
+             (3 'font-lock-comment-face t))
 	   ;; ARCHIVEd headings
 	   (list (concat
 		  org-outline-regexp-bol
-- 
2.30.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add font-lock rule for inline export snippets
  2021-03-31 15:57 [PATCH] Add font-lock rule for inline export snippets Timothy
@ 2021-04-28  7:23 ` Timothy
  2021-05-01 10:02 ` Bastien
  1 sibling, 0 replies; 3+ messages in thread
From: Timothy @ 2021-04-28  7:23 UTC (permalink / raw)
  To: org-mode-email


Timothy <tecosaur@gmail.com> writes:

> Hello,
>
> The latest in my visually-oriented (mostly) short patch series, adding
> basic fontification to inline export snippets --- @@comment:these things@@.
>
> I think fontification for stuff like this is nice because it visually
> indicates to the user that they've written out an Org construct, and
> haven't just mis-remembered / imagined some syntax.
>
> In future this could be extended to use native fontification for
> recognised export formats (like src blocks do), but I think this is a
> nice improvement over nothing.

This addition to the font-lock regexps is quite simple, and doesn't
contain anything fancy/expensive (like backtracking), so I don't expect
there to be any performance concerns --- but it would be good to hear
from others :)

I considered limiting this to no-newlines, but
https://orgmode.org/worg/dev/org-syntax.html says anything other than @@
is allowed.

--
Timothy


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Add font-lock rule for inline export snippets
  2021-03-31 15:57 [PATCH] Add font-lock rule for inline export snippets Timothy
  2021-04-28  7:23 ` Timothy
@ 2021-05-01 10:02 ` Bastien
  1 sibling, 0 replies; 3+ messages in thread
From: Bastien @ 2021-05-01 10:02 UTC (permalink / raw)
  To: Timothy; +Cc: org-mode-email

Hi Timothy,

Timothy <tecosaur@gmail.com> writes:

> The latest in my visually-oriented (mostly) short patch series, adding
> basic fontification to inline export snippets --- @@comment:these
> things@@.

Applied in master with commit eef9027c, thanks!  I also added a note
in etc/ORG-NEWS.

-- 
 Bastien


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-01 10:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 15:57 [PATCH] Add font-lock rule for inline export snippets Timothy
2021-04-28  7:23 ` Timothy
2021-05-01 10:02 ` Bastien

Code repositories for project(s) associated with this inbox:

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).