From: Florian Beck <fb@miszellen.de>
To: Bastien <bzg@gnu.org>
Cc: emacs-orgmode@gnu.org
Subject: [PATCH] Font-lock: allow hiding of brackets surrounding macros
Date: Fri, 31 Jan 2014 23:13:34 +0100 [thread overview]
Message-ID: <52EC200E.8070301@miszellen.de> (raw)
In-Reply-To: <87ha8lgxes.fsf@bzg.ath.cx>
[-- Attachment #1: Type: text/plain, Size: 112 bytes --]
Hi,
I gave it a try. Well, I spend most of my time on formatting this patch.
Hope it works.
--
Florian Beck
[-- Attachment #2: 0001-Font-lock-allow-hiding-of-brackets-surrounding-macro.patch --]
[-- Type: text/x-patch, Size: 2733 bytes --]
From 7980ee3ab9e048c1bdeddfaa6f7dbe984c469171 Mon Sep 17 00:00:00 2001
From: Florian Beck <fb@miszellen.de>
Date: Fri, 31 Jan 2014 22:42:04 +0100
Subject: [PATCH] Font-lock: allow hiding of brackets surrounding macros
* lisp/org.el (org-hide-macro-markers): new option
(org-fontify-macros): new function
(org-set-font-lock-defaults): call `org-fontify-macros'
* doc/org.texi: Document user option `org-hide-macro-markers'
TINYCHANGE
---
doc/org.texi | 3 +++
lisp/org.el | 21 ++++++++++++++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/doc/org.texi b/doc/org.texi
index 9c7a6a7..792315c 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -10019,6 +10019,9 @@ and to the modification time of the file being exported, respectively.
@var{FORMAT} should be a format string understood by
@code{format-time-string}.
+The surrounding brackets can be made invisible by setting
+@code{org-hide-macro-markers} to @code{t}.
+
Macro expansion takes place during export.
diff --git a/lisp/org.el b/lisp/org.el
index 20dcb92..5844daf 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4145,6 +4145,11 @@ following symbols:
:group 'org-appearance
:type 'boolean)
+(defcustom org-hide-macro-markers nil
+ "Non-nil mean font-lock should hide the brackets marking macro calls."
+ :group 'org-appearance
+ :type 'boolean)
+
(defcustom org-pretty-entities nil
"Non-nil means show entities as UTF8 characters.
When nil, the \\name form remains in the buffer."
@@ -5949,6 +5954,20 @@ by a #."
(org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
t))
+ (defun org-fontify-macros (limit)
+ "Fontify macros."
+ (when (re-search-forward "\\({{{\\).+?\\(}}}\\)" limit t)
+ (add-text-properties
+ (match-beginning 0) (match-end 0)
+ '(font-lock-fontified t face org-macro))
+ (when org-hide-macro-markers
+ (add-text-properties (match-end 2) (match-beginning 2)
+ '(invisible t))
+ (add-text-properties (match-beginning 1) (match-end 1)
+ '(invisible t)))
+ (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
+ t))
+
(defun org-activate-angle-links (limit)
"Run through the buffer and add overlays to links."
(if (and (re-search-forward org-angle-link-re limit t)
@@ -6260,7 +6279,7 @@ needs to be inserted at a specific position in the font-lock sequence.")
;; Diary sexps.
'("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t))
;; Macro
- '("{{{.+?}}}" (0 'org-macro t))
+ '(org-fontify-macros)
'(org-hide-wide-columns (0 nil append))
;; TODO keyword
(list (format org-heading-keyword-regexp-format
--
1.8.3.2
next prev parent reply other threads:[~2014-01-31 22:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-29 8:49 [RFC] Syntax for macros Sebastien Vauban
2014-01-29 9:25 ` Bastien
2014-01-30 10:29 ` Sebastien Vauban
2014-01-30 10:41 ` Bastien
2014-01-30 10:48 ` Sebastien Vauban
2014-01-30 14:08 ` Nick Dokos
2014-01-30 14:56 ` Sebastien Vauban
2014-01-30 16:59 ` Nick Dokos
2014-01-30 17:22 ` Thorsten Jolitz
2014-01-30 18:03 ` Bastien
2014-01-31 22:13 ` Florian Beck [this message]
2014-02-01 0:22 ` [PATCH] Font-lock: allow hiding of brackets surrounding macros Bastien
2014-02-05 10:14 ` Bastien
2014-02-05 13:07 ` Sebastien Vauban
2014-02-05 13:12 ` Bastien
2014-01-30 19:25 ` [RFC] Syntax for macros Florian Beck
2014-01-30 21:11 ` Thomas S. Dye
2014-01-30 18:24 ` Achim Gratz
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52EC200E.8070301@miszellen.de \
--to=fb@miszellen.de \
--cc=bzg@gnu.org \
--cc=emacs-orgmode@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 public 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 read-only IMAP folder(s) and NNTP newsgroup(s).