* [babel][bug]
@ 2012-01-02 17:41 Martyn Jago
2012-01-03 17:40 ` [babel][bug] org-babel-balanced-split (with Emacs-22) Martyn Jago
0 siblings, 1 reply; 9+ messages in thread
From: Martyn Jago @ 2012-01-02 17:41 UTC (permalink / raw)
To: emacs-orgmode
There is a bug running babel on Emacs 22.1.1 with a minimal init file.
The following code works:
--8<---------------cut here---------------start------------->8---
* Test passes
#+begin_src emacs-lisp
"hello there"
#+end_src
#+results:
: hello there
--8<---------------cut here---------------end--------------->8---
The following fails:
--8<---------------cut here---------------start------------->8---
* Test fails
#+begin_src emacs-lisp :results silent
"hello there"
#+end_src
--8<---------------cut here---------------end--------------->8---
The problem appears to be associated with the :results parsing.
The backtrace is as follows:
--8<---------------cut here---------------start------------->8---
Debugger entered--Lisp error: (wrong-type-argument listp 58)
matches(114 58)
matched(114 58)
#[(ch) "\b
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [babel][bug] org-babel-balanced-split (with Emacs-22)
2012-01-02 17:41 [babel][bug] Martyn Jago
@ 2012-01-03 17:40 ` Martyn Jago
2012-01-03 17:46 ` Eric Schulte
0 siblings, 1 reply; 9+ messages in thread
From: Martyn Jago @ 2012-01-03 17:40 UTC (permalink / raw)
To: emacs-orgmode
Martyn Jago <martyn.jago@btinternet.com> writes:
> There is a bug running babel on Emacs 22.1.1 with a minimal init file.
>
[...]
>
> The following fails:
>
> * Test fails
>
> #+begin_src emacs-lisp :results silent
>
> "hello there"
>
> #+end_src
>
[...]
The problem appears to be associated with the way `member' works:
- on Emacs 23+ the following doesn't generate an error
- on Emacs 22 it generates "Wrong type argument: listp, 58"
#+begin_src emacs-lisp
(member 116 58)
#+end_src
`org-babel-balanced-split' appears to rely on not generating an error
when the `member' LIST parameter is actually a number.
Best, Martyn
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [babel][bug] org-babel-balanced-split (with Emacs-22)
2012-01-03 17:40 ` [babel][bug] org-babel-balanced-split (with Emacs-22) Martyn Jago
@ 2012-01-03 17:46 ` Eric Schulte
2012-01-03 18:32 ` Martyn Jago
0 siblings, 1 reply; 9+ messages in thread
From: Eric Schulte @ 2012-01-03 17:46 UTC (permalink / raw)
To: Martyn Jago; +Cc: emacs-orgmode
Martyn Jago <martyn.jago@btinternet.com> writes:
> Martyn Jago <martyn.jago@btinternet.com> writes:
>
>> There is a bug running babel on Emacs 22.1.1 with a minimal init file.
>>
>
> [...]
>
>>
>> The following fails:
>>
>> * Test fails
>>
>> #+begin_src emacs-lisp :results silent
>>
>> "hello there"
>>
>> #+end_src
>>
>
> [...]
>
> The problem appears to be associated with the way `member' works:
>
> - on Emacs 23+ the following doesn't generate an error
> - on Emacs 22 it generates "Wrong type argument: listp, 58"
>
> #+begin_src emacs-lisp
>
> (member 116 58)
>
> #+end_src
>
> `org-babel-balanced-split' appears to rely on not generating an error
> when the `member' LIST parameter is actually a number.
>
Ah, I see where this comes in, does the included alternative definition
of this function fix the issue on Emacs22? If so I'll apply this change
to the repository.
Thanks,
(defun org-babel-balanced-split (string alts)
"Split STRING on instances of ALTS.
ALTS is a cons of two character options where each option may be
either the numeric code of a single character or a list of
character alternatives. For example to split on balanced
instances of \"[ \t]:\" set ALTS to '((32 9) . 58)."
(flet ((matches (ch spec) (or (and (numberp spec) (= spec ch))
(not (numberp spec) (member ch spec))))
(matched (ch last)
(if (consp alts)
(and (matches ch (cdr alts))
(matches last (car alts)))
(matches ch alts))))
(let ((balance 0) (quote nil) (partial nil) (lst nil) (last 0))
(mapc (lambda (ch) ; split on [], (), "" balanced instances of [ \t]:
(setq balance (+ balance
(cond ((or (equal 91 ch) (equal 40 ch)) 1)
((or (equal 93 ch) (equal 41 ch)) -1)
(t 0))))
(when (and (equal 34 ch) (not (equal 92 last)))
(setq quote (not quote)))
(setq partial (cons ch partial))
(when (and (= balance 0) (not quote) (matched ch last))
(setq lst (cons (apply #'string (nreverse
(if (consp alts)
(cddr partial)
(cdr partial))))
lst))
(setq partial nil))
(setq last ch))
(string-to-list string))
(nreverse (cons (apply #'string (nreverse partial)) lst)))))
>
> Best, Martyn
>
>
>
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [babel][bug] org-babel-balanced-split (with Emacs-22)
2012-01-03 17:46 ` Eric Schulte
@ 2012-01-03 18:32 ` Martyn Jago
2012-01-03 18:46 ` Eric Schulte
0 siblings, 1 reply; 9+ messages in thread
From: Martyn Jago @ 2012-01-03 18:32 UTC (permalink / raw)
To: emacs-orgmode
Eric Schulte <eric.schulte@gmx.com> writes:
> Martyn Jago <martyn.jago@btinternet.com> writes:
>
>> Martyn Jago <martyn.jago@btinternet.com> writes:
>>
>> [...]
>>
>> The problem appears to be associated with the way `member' works:
>>
>> - on Emacs 23+ the following doesn't generate an error
>> - on Emacs 22 it generates "Wrong type argument: listp, 58"
>>
>> #+begin_src emacs-lisp
>>
>> (member 116 58)
>>
>> #+end_src
>>
>> `org-babel-balanced-split' appears to rely on not generating an error
>> when the `member' LIST parameter is actually a number.
>>
>
> Ah, I see where this comes in, does the included alternative definition
> of this function fix the issue on Emacs22? If so I'll apply this change
> to the repository.
>
> Thanks,
>
> (defun org-babel-balanced-split (string alts)
> "Split STRING on instances of ALTS.
> ALTS is a cons of two character options where each option may be
> either the numeric code of a single character or a list of
> character alternatives. For example to split on balanced
> instances of \"[ \t]:\" set ALTS to '((32 9) . 58)."
> (flet ((matches (ch spec) (or (and (numberp spec) (= spec ch))
> (not (numberp spec) (member ch spec))))
[...]
Hi Eric
I fixed a typo on your fix, and added a regression test, and it now
works on Emacs 22. Thanks!
Best, Martyn
--8<---------------cut here---------------start------------->8---
(defun org-babel-balanced-split (string alts)
"Split STRING on instances of ALTS.
ALTS is a cons of two character options where each option may be
either the numeric code of a single character or a list of
character alternatives. For example to split on balanced
instances of \"[ \t]:\" set ALTS to '((32 9) . 58)."
(flet ((matches (ch spec) (or (and (numberp spec) (= spec ch))
(and (not (numberp spec))
(member ch spec))))
(matched (ch last)
(if (consp alts)
(and (matches ch (cdr alts))
(matches last (car alts)))
(matches ch alts))))
(let ((balance 0) (quote nil) (partial nil) (lst nil) (last 0))
(mapc (lambda (ch) ; split on [], (), "" balanced instances of [ \t]:
(setq balance (+ balance
(cond ((or (equal 91 ch) (equal 40 ch)) 1)
((or (equal 93 ch) (equal 41 ch)) -1)
(t 0))))
(when (and (equal 34 ch) (not (equal 92 last)))
(setq quote (not quote)))
(setq partial (cons ch partial))
(when (and (= balance 0) (not quote) (matched ch last))
(setq lst (cons (apply #'string (nreverse
(if (consp alts)
(cddr partial)
(cdr partial))))
lst))
(setq partial nil))
(setq last ch))
(string-to-list string))
(nreverse (cons (apply #'string (nreverse partial)) lst)))))
--8<---------------cut here---------------end--------------->8---
--8<---------------cut here---------------start------------->8---
(ert-deftest test-ob/org-babel-balanced-split ()
(should (equal
'(":a 1" "b [2 3]" "c (4 :d (5 6))")
(org-babel-balanced-split ":a 1 :b [2 3] :c (4 :d (5 6))" '((32 9) . 58)))))
--8<---------------cut here---------------end--------------->8---
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [babel][bug] org-babel-balanced-split (with Emacs-22)
2012-01-03 18:32 ` Martyn Jago
@ 2012-01-03 18:46 ` Eric Schulte
2012-01-03 18:49 ` Achim Gratz
0 siblings, 1 reply; 9+ messages in thread
From: Eric Schulte @ 2012-01-03 18:46 UTC (permalink / raw)
To: Martyn Jago; +Cc: emacs-orgmode
Martyn Jago <martyn.jago@btinternet.com> writes:
> Eric Schulte <eric.schulte@gmx.com> writes:
>
>> Martyn Jago <martyn.jago@btinternet.com> writes:
>>
>>> Martyn Jago <martyn.jago@btinternet.com> writes:
>>>
>>> [...]
>>>
>>> The problem appears to be associated with the way `member' works:
>>>
>>> - on Emacs 23+ the following doesn't generate an error
>>> - on Emacs 22 it generates "Wrong type argument: listp, 58"
>>>
>>> #+begin_src emacs-lisp
>>>
>>> (member 116 58)
>>>
>>> #+end_src
>>>
>>> `org-babel-balanced-split' appears to rely on not generating an error
>>> when the `member' LIST parameter is actually a number.
>>>
>>
>> Ah, I see where this comes in, does the included alternative definition
>> of this function fix the issue on Emacs22? If so I'll apply this change
>> to the repository.
>>
>> Thanks,
>>
>> (defun org-babel-balanced-split (string alts)
>> "Split STRING on instances of ALTS.
>> ALTS is a cons of two character options where each option may be
>> either the numeric code of a single character or a list of
>> character alternatives. For example to split on balanced
>> instances of \"[ \t]:\" set ALTS to '((32 9) . 58)."
>> (flet ((matches (ch spec) (or (and (numberp spec) (= spec ch))
>> (not (numberp spec) (member ch spec))))
>
> [...]
>
> Hi Eric
>
> I fixed a typo on your fix, and added a regression test, and it now
> works on Emacs 22. Thanks!
>
Great, both the test case and a fixed version of this function are now
applied to the git repository.
Thanks,
>
> Best, Martyn
>
> (defun org-babel-balanced-split (string alts)
> "Split STRING on instances of ALTS.
> ALTS is a cons of two character options where each option may be
> either the numeric code of a single character or a list of
> character alternatives. For example to split on balanced
> instances of \"[ \t]:\" set ALTS to '((32 9) . 58)."
> (flet ((matches (ch spec) (or (and (numberp spec) (= spec ch))
> (and (not (numberp spec))
> (member ch spec))))
> (matched (ch last)
> (if (consp alts)
> (and (matches ch (cdr alts))
> (matches last (car alts)))
> (matches ch alts))))
> (let ((balance 0) (quote nil) (partial nil) (lst nil) (last 0))
> (mapc (lambda (ch) ; split on [], (), "" balanced instances of [ \t]:
> (setq balance (+ balance
> (cond ((or (equal 91 ch) (equal 40 ch)) 1)
> ((or (equal 93 ch) (equal 41 ch)) -1)
> (t 0))))
> (when (and (equal 34 ch) (not (equal 92 last)))
> (setq quote (not quote)))
> (setq partial (cons ch partial))
> (when (and (= balance 0) (not quote) (matched ch last))
> (setq lst (cons (apply #'string (nreverse
> (if (consp alts)
> (cddr partial)
> (cdr partial))))
> lst))
> (setq partial nil))
> (setq last ch))
> (string-to-list string))
> (nreverse (cons (apply #'string (nreverse partial)) lst)))))
>
> (ert-deftest test-ob/org-babel-balanced-split ()
> (should (equal
> '(":a 1" "b [2 3]" "c (4 :d (5 6))")
> (org-babel-balanced-split ":a 1 :b [2 3] :c (4 :d (5 6))" '((32 9) . 58)))))
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [babel][bug] org-babel-balanced-split (with Emacs-22)
2012-01-03 18:46 ` Eric Schulte
@ 2012-01-03 18:49 ` Achim Gratz
2012-01-03 19:10 ` Eric Schulte
0 siblings, 1 reply; 9+ messages in thread
From: Achim Gratz @ 2012-01-03 18:49 UTC (permalink / raw)
To: emacs-orgmode
Eric Schulte <eric.schulte@gmx.com> writes:
> Great, both the test case and a fixed version of this function are now
> applied to the git repository.
You've pushed it to both maint and master?
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
Wavetables for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldUserWavetables
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [babel][bug] org-babel-balanced-split (with Emacs-22)
2012-01-03 18:49 ` Achim Gratz
@ 2012-01-03 19:10 ` Eric Schulte
2012-01-03 19:22 ` Achim Gratz
0 siblings, 1 reply; 9+ messages in thread
From: Eric Schulte @ 2012-01-03 19:10 UTC (permalink / raw)
To: Achim Gratz; +Cc: emacs-orgmode
Achim Gratz <Stromeko@nexgo.de> writes:
> Eric Schulte <eric.schulte@gmx.com> writes:
>> Great, both the test case and a fixed version of this function are now
>> applied to the git repository.
>
> You've pushed it to both maint and master?
>
Yes, I'm now pushing bug-fix commits to maint as well as master.
>
>
> Achim.
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [babel][bug] org-babel-balanced-split (with Emacs-22)
2012-01-03 19:10 ` Eric Schulte
@ 2012-01-03 19:22 ` Achim Gratz
2012-01-03 20:57 ` Eric Schulte
0 siblings, 1 reply; 9+ messages in thread
From: Achim Gratz @ 2012-01-03 19:22 UTC (permalink / raw)
To: emacs-orgmode
Eric Schulte <eric.schulte@gmx.com> writes:
> Yes, I'm now pushing bug-fix commits to maint as well as master.
That way you duplicate the commit (the same change now has two ID).
I think it would be preferrable to push bugfixes to maint and then merge
maint back into master.
Regards,
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
DIY Stuff:
http://Synth.Stromeko.net/DIY.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [babel][bug] org-babel-balanced-split (with Emacs-22)
2012-01-03 19:22 ` Achim Gratz
@ 2012-01-03 20:57 ` Eric Schulte
0 siblings, 0 replies; 9+ messages in thread
From: Eric Schulte @ 2012-01-03 20:57 UTC (permalink / raw)
To: Achim Gratz; +Cc: emacs-orgmode
Achim Gratz <Stromeko@nexgo.de> writes:
> Eric Schulte <eric.schulte@gmx.com> writes:
>> Yes, I'm now pushing bug-fix commits to maint as well as master.
>
> That way you duplicate the commit (the same change now has two ID).
> I think it would be preferrable to push bugfixes to maint and then merge
> maint back into master.
>
Alright, that does sound preferable. I'll leave the previous commits as
is so as not to force a non-fast-forward commit, but moving forward I'll
commit bug fixes to maint and then merge maint into master.
Thanks,
>
>
> Regards,
> Achim.
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-01-03 20:57 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-02 17:41 [babel][bug] Martyn Jago
2012-01-03 17:40 ` [babel][bug] org-babel-balanced-split (with Emacs-22) Martyn Jago
2012-01-03 17:46 ` Eric Schulte
2012-01-03 18:32 ` Martyn Jago
2012-01-03 18:46 ` Eric Schulte
2012-01-03 18:49 ` Achim Gratz
2012-01-03 19:10 ` Eric Schulte
2012-01-03 19:22 ` Achim Gratz
2012-01-03 20:57 ` Eric Schulte
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).