From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?S=C3=A9bastien_Vauban?= Subject: Re: [babel] ledger tutorial on Worg Date: Wed, 08 Sep 2010 10:21:56 +0200 Message-ID: <871v94wspn.fsf@mundaneum.com> References: <871v9lm0s3.wl%ucecesf@ucl.ac.uk> <4296BE2D-051E-47E8-8AA7-24582082DD0F@gmail.com> <87zkw8vzxw.fsf@gmail.com> <87aao1bt8w.fsf@mundaneum.com> <87mxs1co0f.wl%ucecesf@ucl.ac.uk> <87mxs071us.fsf@mundaneum.com> <87tym8b3e0.fsf@gmail.com> <87mxryv9ah.fsf@mundaneum.com> <8762ymo6hf.fsf@gmail.com> <877hizvrui.fsf@mundaneum.com> <87wrqxw3ou.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Hi Eric, "Eric Schulte" wrote: > S=C3=A9bastien Vauban writes: >> "Eric Schulte" wrote: >>> S=C3=A9bastien Vauban writes: >>>> >>>> 1. I find it weird to have all the parameters of =3D:cmdline=3D not en= closed >>>> between quotes. What should be the best option, here? That was a >>>> subject, long ago, on Org-Babel: to quote or not to quote... >>> >>> I don't know that this was ever explicitly discussed, I believe that the >>> no-quoting behavior may have simply fallen out of the initial >>> implementation. I'd certainly like to hear other people's opinions on >>> this, but I've personally enjoyed not having to place quotes in every >>> instance. >> >> In december 2009, I wrote: >> >> "I'm a bit confused (as you may have seen in my last posts) about wh= en we >> do have to quote strings and when we do have to avoid doing it. Woul= d you >> have a one-liner explanation about when we have to use quotes?" >> >> See http://www.mail-archive.com/emacs-orgmode-mXXj517/zsQ@public.gmane.org/msg20265.html for >> contextual information. >> >> I remembered "you" (Dan or you) answered it somehow, but it must have be= en >> (around that same period) in another thread. Though, I don't find pointe= rs >> anymore... >> >> Question is more: is it clear to mix parameters names (such as =3D:cmdli= ne=3D) and >> long values which are unquoted (such as =3Dregistry unknown credit-card= =3D and >> many much more options)? >> >> Shouldn't we properly begin and end where the given value is? > > Through extensive person use I've not run into any instances where the la= ck > of quotes has actually caused a problem, or where there has been a valid > combination of header arguments which could not be successfully parsed. > Without such an example I don't find it motivating to require quotes. I have no objection against this, as I have no definite view on what's bett= er. Adding quotes would mean begin able to escape them in case the options need quotes, etc. etc. So, maybe it is better the way it currently is. The fact simply is sometimes we must add quotes, sometimes not, and that's = not always intuitive (to me). Not only considering Org-Babel, but Org as a whol= e. See this example of `columnview': --8<---------------cut here---------------start------------->8--- #+BEGIN: columnview :hlines 1 :id "label" #+END: --8<---------------cut here---------------end--------------->8--- or of `org-collector': --8<---------------cut here---------------start------------->8--- #+BEGIN: propview :id "december" :conds ((string=3D spendtype "food")) :col= s (ITEM amount) #+END: --8<---------------cut here---------------end--------------->8--- >>>> 2. When the evaluation produces no output, but had well produced output >>>> before, shouldn't Babel have to delete the previously written resul= ts in >>>> the Org buffer? >>> >>> This is a good point. Currently Babel just quits if it receives a nil >>> result, but I think you're right that we should replace existing results >>> when a nil result has been returned. I'll add this as PROPOSED to the b= abel >>> task list. >> >> I consider this kind of mandatory, for the sake of coherency, and to rea= lly >> make use of Org-babel every time I want to run some shell commands (and = change >> them, eventually getting no results then). >> > > I've just pushed up a change that implements this behavior. I've just git pulled, and tested your change. >From my point of view, it does not work yet. Take this example: --8<---------------cut here---------------start------------->8--- * Journal data #+srcname: ledger-journal #+begin_src ledger 2008/01/03 * (SCORPIOS ) SEB VAUBAN Assets:Bank:Checking:799997400530 550.00 EUR Assets:Bank:Transferred 2008/01/01 * ( ) UNKNOWN-PAYEE Assets:Bank:Checking:799997400530 21.91 EUR Expenses:Unknown #+end_src * Registry Give me the details... #+srcname: ledger-registry #+begin_src ledger :cmdline reg unknown :noweb yes :session <> #+end_src #+results: ledger-registry : -21.91 EUR Expenses:Unknown --8<---------------cut here---------------end--------------->8--- With `:cmdline reg unknown', it produced the line with -21.91 EUR. Correct. Now, if I write `:cmdline "reg" unknown', I expect no output from Ledger, a= nd thus the results block to be removed. That's not the case. Other peculiarity, if I write `:cmdline reeg unknown', I get an exception: --8<---------------cut here---------------start------------->8--- Debugger entered--Lisp error: (args-out-of-range "" -1 0) substring("" -1) (string-equal (substring result -1) "\n") (or (string-equal (substring result -1) "\n") (string-equal (substring re= sult -1) "=0D")) (not (or (string-equal ... "\n") (string-equal ... "=0D"))) (and (stringp result) (not (or ... ...))) (if (and (stringp result) (not ...)) (progn (setq result ...))) (when (and (stringp result) (not ...)) (setq result (concat result "\n"))) (if (and result-params (member "silent" result-params)) (progn (message .= ..) result) (when (and ... ...) (setq result ...)) (save-excursion (let ...= ... ... ... ... ...)) (if (=3D ... 0) (if ... ... ...) (message "finished"= ))) org-babel-insert-result("" ("output" "replace") ("ledger" "2008/01/03 * (= SCORPIOS ) SEB VAUBAN\n Assets:Bank:Checking:799997400530 = 550.00 EUR\n Assets:Bank:Transferred\n\n2008/01/= 01 * ( ) UNKNOWN-PAYEE\n Assets:Bank:Checking:799997400530 = 21.91 EUR\n Expenses:Unknown\n" ((:cache . "no= ") (:cmdline . "reeg unknown") (:comments . "") (:exports . "code") (:hline= s . "no") (:noweb . "yes") (:results . "output replace") (:session) (:sheba= ng . "") (:tangle . "no")) "" "ledger-registry" 0) nil 0 "ledger") (if (and (not arg) new-hash (equal new-hash old-hash)) (save-excursion (g= oto-char ...) (end-of-line 1) (forward-char 1) (setq result ...) (message .= ..) result) (message "executing %s code block%s..." (capitalize lang) (if .= .. ... "")) (setq result (funcall cmd body params)) (if (eq result-type ...= ) (setq result ...)) (org-babel-insert-result result result-params info new= -hash indent lang) (run-hooks (quote org-babel-after-execute-hook)) result) (progn (fset (quote call-process-region) (function* ...)) (unless (fbound= p cmd) (error "No org-babel-execute function for %s!" lang)) (if (and ... n= ew-hash ...) (save-excursion ... ... ... ... ... result) (message "executin= g %s code block%s..." ... ...) (setq result ...) (if ... ...) (org-babel-in= sert-result result result-params info new-hash indent lang) (run-hooks ...)= result)) (unwind-protect (progn (fset ... ...) (unless ... ...) (if ... ... ... ..= . ... ... ... result)) (if --cl-letf-bound-- (fset ... --cl-letf-save--) (f= makunbound ...))) (let* ((--cl-letf-bound-- ...) (--cl-letf-save-- ...)) (unwind-protect (p= rogn ... ... ...) (if --cl-letf-bound-- ... ...))) (letf ((... ...)) (unless (fboundp cmd) (error "No org-babel-execute func= tion for %s!" lang)) (if (and ... new-hash ...) (save-excursion ... ... ...= ... ... result) (message "executing %s code block%s..." ... ...) (setq res= ult ...) (if ... ...) (org-babel-insert-result result result-params info ne= w-hash indent lang) (run-hooks ...) result)) (letf* ((... ...)) (unless (fboundp cmd) (error "No org-babel-execute fun= ction for %s!" lang)) (if (and ... new-hash ...) (save-excursion ... ... ..= . ... ... result) (message "executing %s code block%s..." ... ...) (setq re= sult ...) (if ... ...) (org-babel-insert-result result result-params info n= ew-hash indent lang) (run-hooks ...) result)) (flet ((call-process-region ... ...)) (unless (fboundp cmd) (error "No or= g-babel-execute function for %s!" lang)) (if (and ... new-hash ...) (save-e= xcursion ... ... ... ... ... result) (message "executing %s code block%s...= " ... ...) (setq result ...) (if ... ...) (org-babel-insert-result result r= esult-params info new-hash indent lang) (run-hooks ...) result)) (unwind-protect (flet (...) (unless ... ...) (if ... ... ... ... ... ... = ... result)) (setq call-process-region (quote org-babel-call-process-region= -original))) (let* ((lang ...) (params ...) (new-hash ...) (old-hash ...) (body ...) (= result-params ...) (result-type ...) (cmd ...) (dir ...) (default-directory= ...) (org-babel-call-process-region-original ...) (indent ...) result) (un= wind-protect (flet ... ... ...) (setq call-process-region ...))) (progn (let* (... ... ... ... ... ... ... ... ... ... ... ... result) (un= wind-protect ... ...))) (if (org-babel-confirm-evaluate info) (progn (let* ... ...))) (when (org-babel-confirm-evaluate info) (let* (... ... ... ... ... ... ..= . ... ... ... ... ... result) (unwind-protect ... ...))) (let ((info ...)) (when (org-babel-confirm-evaluate info) (let* ... ...))) org-babel-execute-src-block(nil ("ledger" "2008/01/03 * (SCORPIOS ) SEB V= AUBAN\n Assets:Bank:Checking:799997400530 = 550.00 EUR\n Assets:Bank:Transferred\n\n2008/01/01 * ( ) UNKNOWN= -PAYEE\n Assets:Bank:Checking:799997400530 = 21.91 EUR\n Expenses:Unknown\n" ((:cache . "no") (:cmdline . "= reeg unknown") (:comments . "") (:exports . "code") (:hlines . "no") (:nowe= b . "yes") (:results . "output replace") (:session) (:shebang . "") (:tangl= e . "no")) "" "ledger-registry" 0)) (progn (org-babel-execute-src-block current-prefix-arg info) t) (if info (progn (org-babel-execute-src-block current-prefix-arg info) t) = nil) (let ((info ...)) (if info (progn ... t) nil)) org-babel-execute-src-block-maybe() (or (org-babel-execute-src-block-maybe) (org-babel-lob-execute-maybe)) org-babel-execute-maybe() call-interactively(org-babel-execute-maybe nil nil) --8<---------------cut here---------------end--------------->8--- >> Thanks a lot for everything you did and do for us. > > My pleasure -- Eric Still applicable...=C2=A0;-) Best regards, Seb --=20 S=C3=A9bastien Vauban _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode