From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Beck Subject: [PATCH] Font-lock: allow hiding of brackets surrounding macros Date: Fri, 31 Jan 2014 23:13:34 +0100 Message-ID: <52EC200E.8070301@miszellen.de> References: <86ha8n6ulq.fsf@somewhere.org> <87y51zta1a.fsf@bzg.ath.cx> <867g9hiwzy.fsf@somewhere.org> <87sis592gg.fsf@bzg.ath.cx> <8638k5iw3i.fsf@somewhere.org> <8738k57ebi.fsf@gmail.com> <86zjmdfrgl.fsf@somewhere.org> <87y51x8kyr.fsf@alphaville.bos.redhat.com> <87ha8lgxes.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030808040901080105010001" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9MLO-00047d-7N for emacs-orgmode@gnu.org; Fri, 31 Jan 2014 17:13:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W9MLI-0001uk-CU for emacs-orgmode@gnu.org; Fri, 31 Jan 2014 17:13:50 -0500 Received: from mo6-p04-ob.smtp.rzone.de ([2a01:238:20a:202:5304::10]:31625) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W9MLI-0001uS-5A for emacs-orgmode@gnu.org; Fri, 31 Jan 2014 17:13:44 -0500 In-Reply-To: <87ha8lgxes.fsf@bzg.ath.cx> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------030808040901080105010001 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I gave it a try. Well, I spend most of my time on formatting this patch. Hope it works. -- Florian Beck --------------030808040901080105010001 Content-Type: text/x-patch; name="0001-Font-lock-allow-hiding-of-brackets-surrounding-macro.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Font-lock-allow-hiding-of-brackets-surrounding-macro.pa"; filename*1="tch" >From 7980ee3ab9e048c1bdeddfaa6f7dbe984c469171 Mon Sep 17 00:00:00 2001 From: Florian Beck 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 --------------030808040901080105010001--