* Bug in org-lob: Function call adds space to argument string with parenthesis
@ 2015-12-18 8:46 Tobias Zawada
2015-12-20 15:49 ` Nicolas Goaziou
0 siblings, 1 reply; 5+ messages in thread
From: Tobias Zawada @ 2015-12-18 8:46 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
[-- Attachment #1.1: Type: text/plain, Size: 6879 bytes --]
* Bug in org-lob: Function call adds space to argument string with parenthesis
Dear all,
Please see the following code. I would expect arg="()" as result of the call-line but the result is arg="() " with an additional space.
#+NAME: test
#+BEGIN_SRC emacs-lisp :var arg=""
(message "arg=%S" arg)
#+END_SRC
#+RESULTS:
: arg=""
#+call: test(arg="()")
#+RESULTS:
: arg="() "
* My current fast and dirty hack is using sexps instead of regular expressions:
#+BEGIN_SRC emacs-lisp
(require 'ob-lob)
(defadvice org-babel-lob-get-info (around correct-args activate)
"Return a Library of Babel function call as a list.
1st element is the function call as a string.
2nd element is the indentation width
3rd element is the name of the function call if this call is named."
(setq ad-return-value (let ((case-fold-search t)
(nonempty (lambda (a b)
(let ((it (match-string a)))
(if (= (length it) 0) (match-string b) it)))))
(save-excursion
(beginning-of-line 1)
(when (looking-at org-babel-lob-one-liner-regexp)
(append
(list (if (= (length (match-string 12)) 0)
(org-babel-lob-get-info-call-line)
(org-babel-lob-get-info-inline)))
(list (length (if (= (length (match-string 12)) 0)
(match-string 2) (match-string 11)))
(save-excursion
(forward-line -1)
(and (looking-at (concat org-babel-src-name-regexp
"\\([^\n]*\\)$"))
(org-no-properties (match-string 1)))))))))))
(defun org-babel-lob-get-info-call-line ()
"Unify Library of Babel call string of form \"#+CALL:\"
The unified syntax is
,,#+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>"
(save-excursion
(save-match-data
(let ((name "")
(inside-header-args "[]")
(args "()")
end-header-args)
(skip-syntax-forward " ")
(unless (looking-at "#\\+call:[[:space:]]+\\(\\(?:\\sw\\|\\s_\\)+\\)")
(error "Expecting #+CALL: at beginning of line"))
(setq name (match-string 1))
(goto-char (match-end 0))
(skip-syntax-forward " ")
(when (eq (char-after) ?\[) ;; inside-header-args
(setq inside-header-args (buffer-substring-no-properties (point) (goto-char (scan-sexps (point) 1)))))
(skip-syntax-forward " ")
(when (eq (char-after) ?\()
(setq args (buffer-substring-no-properties (point) (goto-char (scan-sexps (point) 1)))))
(setq end-header-args (buffer-substring-no-properties (point) (line-end-position)))
(concat name inside-header-args args end-header-args)))))
(defun org-babel-lob-get-info-inline ()
"Transform one-line Library of Babel calls of form call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] into the unified syntax
,,#+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>"
(save-excursion
(save-match-data
(let ((name "")
(inside-header-args "[]")
(args "()")
(end-header-args ""))
(skip-syntax-forward " ")
(unless (looking-at "call_\\(\\(?:\\sw\\|\\s_\\)+\\)")
(error "Expecting #+CALL: at beginning of line"))
(setq name (match-string 1))
(goto-char (match-end 0))
(skip-syntax-forward " ")
(when (eq (char-after) ?\[) ;; inside-header-args
(setq inside-header-args (buffer-substring-no-properties (point) (goto-char (scan-sexps (point) 1)))))
(skip-syntax-forward " ")
(when (eq (char-after) ?\()
(setq args (buffer-substring-no-properties (point) (goto-char (scan-sexps (point) 1)))))
(when (eq (char-after) ?\[)
(setq end-header-args (buffer-substring-no-properties (1+ (point)) (1- (scan-sexps (point) 1)))))
(concat name inside-header-args args end-header-args)))))
#+END_SRC
Emacs : GNU Emacs 24.5.1 (x86_64-unknown-cygwin, GTK+ Version 3.14.13)
of 2015-06-23 on desktop-new
Package: Org-mode version 8.3.2
Mit freundlichen Grüßen / Best regards
Tobias Zawada
Engineering / Software Development
T
+49 (351) 26050 0
F
+49 (351) 26050 155
Zawada@itisim.com<mailto:Zawada@itisim.com>
itisim.com
<www.itisim.com>________________________________
SimulationX 3.7 now available
More information <https://www.simulationx.com/simulation-software.html>
Always up to date
Subscribe to the ITI Newsletter<http://www.iti.de/newsletter/>!
[cid:Charta-der-Vielfalt-Logo_2ed28c31-dc91-41ff-ad23-4b8bdeebfbf2.png]<http://www.charta-der-vielfalt.de/>
________________________________
ITI GmbH
Schweriner Straße 1
01067 Dresden
Germany
Managing Director/Geschäftsführer
Dr. Andreas Uhlig
Commercial Register/Handelsregister
Amtsgericht Dresden · HRB 2331
USt.-IdNr.: DE140297717
Diese E-Mail ist streng vertraulich und nur für den Empfänger bestimmt.
Sie kann Informationen enthalten, die rechtliche, geschäftliche oder andere Vergünstigungen bedeuten.
Sollten Sie nicht der ausdrückliche Empfänger sein, dürfen Sie diese Informationen nicht benutzen, veröffentlichen oder vervielfältigen.
The information in this e-mail is strictly confidential, is intended solely for the addressee, and may be privileged.
If you are not the intended addressee you must not disclose, print or take action based upon this transmission and should delete it from your system.
[-- Attachment #1.2: Type: text/html, Size: 27947 bytes --]
[-- Attachment #2: Charta-der-Vielfalt-Logo_2ed28c31-dc91-41ff-ad23-4b8bdeebfbf2.png --]
[-- Type: image/png, Size: 6608 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug in org-lob: Function call adds space to argument string with parenthesis
2015-12-18 8:46 Bug in org-lob: Function call adds space to argument string with parenthesis Tobias Zawada
@ 2015-12-20 15:49 ` Nicolas Goaziou
2015-12-21 8:55 ` Tobias Zawada
0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2015-12-20 15:49 UTC (permalink / raw)
To: Tobias Zawada; +Cc: emacs-orgmode@gnu.org
Hello,
Tobias Zawada <Zawada@itisim.com> writes:
> * Bug in org-lob: Function call adds space to argument string with parenthesis
> Dear all,
> Please see the following code. I would expect arg="()" as result of the call-line but the result is arg="() " with an additional space.
>
> #+NAME: test
> #+BEGIN_SRC emacs-lisp :var arg=""
> (message "arg=%S" arg) #+END_SRC
>
> #+RESULTS: : arg=""
>
> #+call: test(arg="()")
>
> #+RESULTS:
> : arg="() "
I cannot reproduce it in development version. Could you update and try
again?
Thank you.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug in org-lob: Function call adds space to argument string with parenthesis
2015-12-20 15:49 ` Nicolas Goaziou
@ 2015-12-21 8:55 ` Tobias Zawada
2015-12-22 22:01 ` Nicolas Goaziou
0 siblings, 1 reply; 5+ messages in thread
From: Tobias Zawada @ 2015-12-21 8:55 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode@gnu.org
[-- Attachment #1.1: Type: text/plain, Size: 3305 bytes --]
Hello,
I had a look at [org-mode.git]/lisp /ob-lob.el
http://orgmode.org/w/org-mode.git?p=org-mode.git;a=blob;f=lisp/ob-lob.el;h=6b0996b4ce3e8f24b53cb554352566b358da5ceb;hb=5aa12cd122feef79a32459463df5828fe520a7c2
and org-element.el
http://orgmode.org/w/org-mode.git?p=org-mode.git;a=blob;f=lisp/org-element.el;h=1a01e618d79bebaf8cd02f3b4b9213769e056754;hb=5aa12cd122feef79a32459463df5828fe520a7c2
The code has changed considerably. The function org-babel-lob-get-info uses org-element-property in the development version.
At the moment I do not have the time to check whether the development version can also have problems with parsing string arguments.
In my opinion the only robust way to parse arguments without re-inventing the wheel is to use the built in parser (ppss) with a proper defined syntax table (e.g., this of emacs-lisp).
Maybe org-element-property does exactly this. But, the function is rather large so that it is not so easy to check and I have to do some work here...
Hopefully I find some time over the holidays.
I cannot clone the git-repository as non-developer (permission denied). So, trying out the development version is a bit difficult for me.
Best regards
Tobias Zawada
itisim.com
<www.itisim.com>________________________________
SimulationX 3.7 now available
More information <https://www.simulationx.com/simulation-software.html>
Always up to date
Subscribe to the ITI Newsletter<http://www.iti.de/newsletter/>!
[cid:Charta-der-Vielfalt-Logo_2ed28c31-dc91-41ff-ad23-4b8bdeebfbf2.png]<http://www.charta-der-vielfalt.de/>
________________________________
ITI GmbH
Schweriner Straße 1
01067 Dresden
Germany
Managing Director/Geschäftsführer
Dr. Andreas Uhlig
Commercial Register/Handelsregister
Amtsgericht Dresden · HRB 2331
USt.-IdNr.: DE140297717
Diese E-Mail ist streng vertraulich und nur für den Empfänger bestimmt.
Sie kann Informationen enthalten, die rechtliche, geschäftliche oder andere Vergünstigungen bedeuten.
Sollten Sie nicht der ausdrückliche Empfänger sein, dürfen Sie diese Informationen nicht benutzen, veröffentlichen oder vervielfältigen.
The information in this e-mail is strictly confidential, is intended solely for the addressee, and may be privileged.
If you are not the intended addressee you must not disclose, print or take action based upon this transmission and should delete it from your system.
-----Ursprüngliche Nachricht-----
Von: Nicolas Goaziou [mailto:mail@nicolasgoaziou.fr]
Gesendet: Sonntag, 20. Dezember 2015 16:50
An: Tobias Zawada
Cc: emacs-orgmode@gnu.org
Betreff: Re: Bug in org-lob: Function call adds space to argument string with parenthesis
Hello,
Tobias Zawada <Zawada@itisim.com> writes:
> * Bug in org-lob: Function call adds space to argument string with
> parenthesis Dear all,
> Please see the following code. I would expect arg="()" as result of the call-line but the result is arg="() " with an additional space.
>
> #+NAME: test
> #+BEGIN_SRC emacs-lisp :var arg=""
> (message "arg=%S" arg) #+END_SRC
>
> #+RESULTS: : arg=""
>
> #+call: test(arg="()")
>
> #+RESULTS:
> : arg="() "
I cannot reproduce it in development version. Could you update and try again?
Thank you.
Regards,
--
Nicolas Goaziou
[-- Attachment #1.2: Type: text/html, Size: 6860 bytes --]
[-- Attachment #2: Charta-der-Vielfalt-Logo_2ed28c31-dc91-41ff-ad23-4b8bdeebfbf2.png --]
[-- Type: image/png, Size: 6608 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug in org-lob: Function call adds space to argument string with parenthesis
2015-12-21 8:55 ` Tobias Zawada
@ 2015-12-22 22:01 ` Nicolas Goaziou
2015-12-23 0:04 ` Robert Klein
0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2015-12-22 22:01 UTC (permalink / raw)
To: Tobias Zawada; +Cc: emacs-orgmode@gnu.org
Hello,
Tobias Zawada <Zawada@itisim.com> writes:
> I cannot clone the git-repository as non-developer (permission
> denied). So, trying out the development version is a bit difficult for
> me.
git clone git://orgmode.org/org-mode.git
gives access to non-developers, doesn't it?
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bug in org-lob: Function call adds space to argument string with parenthesis
2015-12-22 22:01 ` Nicolas Goaziou
@ 2015-12-23 0:04 ` Robert Klein
0 siblings, 0 replies; 5+ messages in thread
From: Robert Klein @ 2015-12-23 0:04 UTC (permalink / raw)
To: mail; +Cc: Zawada, emacs-orgmode
Hi,
Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Hello,
>
> Tobias Zawada <Zawada@itisim.com> writes:
>
>> I cannot clone the git-repository as non-developer (permission
>> denied). So, trying out the development version is a bit difficult for
>> me.
>
> git clone git://orgmode.org/org-mode.git
>
> gives access to non-developers, doesn't it?
Yes, it does. If you're behind a firewall blocking git, you can also use
git clone http://orgmode.org/org-mode.git
Best regards
Robert
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-12-23 0:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-18 8:46 Bug in org-lob: Function call adds space to argument string with parenthesis Tobias Zawada
2015-12-20 15:49 ` Nicolas Goaziou
2015-12-21 8:55 ` Tobias Zawada
2015-12-22 22:01 ` Nicolas Goaziou
2015-12-23 0:04 ` Robert Klein
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).