From: Martyn Jago <martyn.jago@btinternet.com>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Fixes to inline src block execution
Date: Tue, 06 Sep 2011 09:19:12 +0100 [thread overview]
Message-ID: <m239ga3wxr.fsf@btinternet.com> (raw)
In-Reply-To: 871uvu1h51.fsf@gmail.com
[-- Attachment #1: Type: text/plain, Size: 789 bytes --]
Eric Schulte <schulte.eric@gmail.com> writes:
Hi Eric
> Martyn Jago <martyn.jago@btinternet.com> writes:
>
>> Hi
>>
>> Some fixes to inline src block execution via org-ctrl-c-ctrl-c
>> where point is beyond white-space in the inline src block body...
>>
>> * Start Pomodoro
>> src_emacs-lisp[:results silent]{( org-timer-set-timer 25 )}
[...]
> This looks great. I would like to apply this patch but it breaks unit
> tests at least one of which existed previously and was passing. Would
> you mind taking a look at these unit tests to see if your patch breaks
> existing behavior?
Yes my bad - even my supplied tests failed (it was very late). I've fixed
my code and fixed a failing test due to a previous regression.
All tests now pass here on Mac OSX
[...]
Regards
Martyn
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Fix to ob.el, fix to test, test refactor --]
[-- Type: text/x-patch, Size: 4884 bytes --]
From 3dacd351550ec691beb49c1560ce247033711a76 Mon Sep 17 00:00:00 2001
From: Martyn Jago <martyn.jago@btinternet.com>
Date: Tue, 6 Sep 2011 09:00:24 +0100
Subject: [PATCH] Inline source block and test fixes
* lisp/ob.el: Fixed late night refactoring error
* testing/examples/babel.org: whitespace
* testing/lisp/test-ob.el:
Fixed test-org-babel/inline-src-block-regexp (regression error)
Renamed test-org-babel/parse-header-args2 since duplicate test heading
Made test-org-babel/parse-header-args less brittle
---
lisp/ob.el | 8 +++---
testing/examples/babel.org | 1 +
testing/lisp/test-ob.el | 45 ++++++++++++++++++++++---------------------
3 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/lisp/ob.el b/lisp/ob.el
index 2964f82..d6b0ba3 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -166,11 +166,11 @@ Returns non-nil if match-data set"
(beginning-of-line 1)
(string= "src" (thing-at-point 'word))))
(first-line-p (= 1 (line-number-at-pos)))
- (orig (point)))
- (let ((search-for (cond (src-at-0-p "src_")
- (first-line-p " src_")
+ (orig (point)))
+ (let ((search-for (cond ((and src-at-0-p first-line-p "src_"))
+ (first-line-p "[ \t]src_")
(t "[ \f\t\n\r\v]src_")))
- (lower-limit (if (= 1 (line-number-at-pos))
+ (lower-limit (if first-line-p
nil
(- (point-at-bol) 1))))
(save-excursion
diff --git a/testing/examples/babel.org b/testing/examples/babel.org
index f85e1f0..5b7f2ef 100644
--- a/testing/examples/babel.org
+++ b/testing/examples/babel.org
@@ -279,6 +279,7 @@ this is simple
:ID: d4faa7b3-072b-4dcf-813c-dd7141c633f3
:END:
has length 14
+
* org-babel-get-inline-src-block-matches
:PROPERTIES:
:results: silent
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index 71ea7e2..f9884dd 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -108,7 +108,7 @@
(ert-deftest test-org-babel/inline-src-block-regexp ()
- (should(equal (concat "[^-[:alnum:]]\\(src_\\([^ \f\t\n\r\v]+\\)"
+ (should(equal (concat "\\(?:^\\|[^-[:alnum:]]\\)\\(src_\\([^ \f\t\n\r\v]+\\)"
"\\(\\|\\[\\(.*?\\)\\]\\)"
"{\\([^\f\n\r\v]+?\\)}\\)")
org-babel-inline-src-block-regexp))
@@ -206,7 +206,7 @@
(should(equal '(:result-type . output) (assoc :result-type params)))
(should(equal '(num . 9) (cdr (assoc :var params)))))))
-(ert-deftest test-org-babel/parse-header-args ()
+(ert-deftest test-org-babel/parse-header-args2 ()
(org-test-at-id "2409e8ba-7b5f-4678-8888-e48aa02d8cb4"
(should (string-match (regexp-quote "this is simple")
(org-babel-ref-resolve "simple-subtree")))
@@ -225,26 +225,27 @@
(ert-deftest test-org-babel/org-babel-get-inline-src-block-matches ()
(org-test-at-id "0D0983D4-DE33-400A-8A05-A225A567BC74"
- (should (fboundp 'org-babel-get-inline-src-block-matches))
- (should (re-search-forward "src_" nil t)) ;; 1
- (should (= 6132 (match-end 0)))
- (should (org-babel-get-inline-src-block-matches))
- (should (re-search-forward "}" nil (point-at-bol))) ;; 1
- (should-not (org-babel-get-inline-src-block-matches))
- (should (re-search-forward "in" nil t)) ;; 2
- (should-not (org-babel-get-inline-src-block-matches))
- (should (re-search-forward "echo" nil t)) ;; 2
- (should (org-babel-get-inline-src-block-matches))
- (should (re-search-forward "blocks" nil t)) ;; 3
- (left-char 8) ;; 3
- (should (org-babel-get-inline-src-block-matches))
- (right-char 1) ;;3
- (should-not (org-babel-get-inline-src-block-matches))
- (should (re-search-forward ":results" nil t)) ;; 4
- (should (org-babel-get-inline-src-block-matches))
- (end-of-line)
- (should-not (org-babel-get-inline-src-block-matches))
- ))
+ (let ((test-point (point)))
+ (should (fboundp 'org-babel-get-inline-src-block-matches))
+ (should (re-search-forward "src_" nil t)) ;; 1
+ (should (= (+ test-point 140) (match-end 0)))
+ (should (org-babel-get-inline-src-block-matches))
+ (should (re-search-forward "}" nil (point-at-bol))) ;; 1
+ (should-not (org-babel-get-inline-src-block-matches))
+ (should (re-search-forward "in" nil t)) ;; 2
+ (should-not (org-babel-get-inline-src-block-matches))
+ (should (re-search-forward "echo" nil t)) ;; 2
+ (should (org-babel-get-inline-src-block-matches))
+ (should (re-search-forward "blocks" nil t)) ;; 3
+ (left-char 8) ;; 3
+ (should (org-babel-get-inline-src-block-matches))
+ (right-char 1) ;;3
+ (should-not (org-babel-get-inline-src-block-matches))
+ (should (re-search-forward ":results" nil t)) ;; 4
+ (should (org-babel-get-inline-src-block-matches))
+ (end-of-line)
+ (should-not (org-babel-get-inline-src-block-matches))
+ )))
(provide 'test-ob)
--
1.7.3.4
[-- Attachment #3: Type: text/plain, Size: 140 bytes --]
---
Org-mode version 7.7
GNU Emacs 24.0.50.1 (x86_64-apple-darwin, NS apple-appkit-1038.35)
of 2011-08-21 on virtualmac.porkrind.org
next prev parent reply other threads:[~2011-09-06 8:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-05 22:43 [PATCH] Fixes to inline src block execution Martyn Jago
2011-09-06 3:31 ` Eric Schulte
2011-09-06 8:19 ` Martyn Jago [this message]
2011-09-06 15:12 ` Eric Schulte
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=m239ga3wxr.fsf@btinternet.com \
--to=martyn.jago@btinternet.com \
--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).