From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Sean O'Halpin" Subject: [Babel] [PATCH] Customize regular expression to match noweb references Date: Thu, 26 Jan 2012 05:59:27 +0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:59651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqIMt-0003rw-47 for emacs-orgmode@gnu.org; Thu, 26 Jan 2012 00:59:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqIMr-00015Q-KO for emacs-orgmode@gnu.org; Thu, 26 Jan 2012 00:59:30 -0500 Received: from mail-bk0-f41.google.com ([209.85.214.41]:35731) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqIMr-00015J-8P for emacs-orgmode@gnu.org; Thu, 26 Jan 2012 00:59:29 -0500 Received: by bkbzx1 with SMTP id zx1so190533bkb.0 for ; Wed, 25 Jan 2012 21:59:27 -0800 (PST) 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: Org Mode Hi, Here's a patch I'm using to change the default regular expression used to match noweb references. The default regular expression "<<\\(.+?\\)>>" conflicts with Ruby syntax and confuses syntax highlighting. I now set this to "=AB\\(.+?\\)=BB", i.e. using guillemots instead (AltGr-z and AltGr-x on my keyboard). Regards, Sean Customizable regular expression to match noweb references. --- lisp/ob-tangle.el | 4 +++- lisp/ob.el | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index d7c4d7e..4148774 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -281,12 +281,14 @@ references." (interactive) (goto-char (point-min)) (while (or (re-search-forward "\\[\\[file:.*\\]\\[.*\\]\\]" nil t) - (re-search-forward "<<[^[:space:]]*>>" nil t)) + (re-search-forward org-babel-noweb-regexp nil t)) (delete-region (save-excursion (beginning-of-line 1) (point)) (save-excursion (end-of-line 1) (forward-char 1) (point= ))))) (defvar org-stored-links) (defvar org-bracket-link-regexp) +(defvar org-babel-noweb-regexp) + (defun org-babel-tangle-collect-blocks (&optional language) "Collect source blocks in the current Org-mode file. Return an association list of source-code block specifications of diff --git a/lisp/ob.el b/lisp/ob.el index 47be708..bbd6209 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -113,6 +113,11 @@ remove code block execution from the C-c C-c keybindin= g." :group 'org-babel :type 'boolean) +(defcustom org-babel-noweb-regexp "<<\\(.+?\\)>>" + "Regular expression to use to match noweb references." + :group 'org-babel + :type 'string) + (defcustom org-babel-results-keyword "RESULTS" "Keyword used to name results generated by code blocks. Should be either RESULTS or NAME however any capitalization may @@ -2159,7 +2164,7 @@ block but are passed literally to the \"example-block= \"." (with-temp-buffer (insert body) (goto-char (point-min)) (setq index (point)) - (while (and (re-search-forward "<<\\(.+?\\)>>" nil t)) + (while (and (re-search-forward org-babel-noweb-regexp nil t)) (save-match-data (setf source-name (match-string 1))) (save-match-data (setq evaluate (string-match "\(.*\)" source-na= me))) (save-match-data --=20 1.7.0.4