From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Schmidt Subject: ob-calc duplicate stack-element issue Date: Sun, 15 Mar 2020 11:46:29 +0100 Message-ID: <9eed12f5-face-eb4f-4006-e8ee7890e0a9@webbedtables.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:46754) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDQn2-0007YO-Ez for emacs-orgmode@gnu.org; Sun, 15 Mar 2020 06:46:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDQn1-0005Bd-Ax for emacs-orgmode@gnu.org; Sun, 15 Mar 2020 06:46:40 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:35723) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDQn1-0004lv-1q for emacs-orgmode@gnu.org; Sun, 15 Mar 2020 06:46:39 -0400 Received: from mail.home.webbedtables.de ([88.64.93.113]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MnZwp-1jdAdH25yP-00jXjQ for ; Sun, 15 Mar 2020 11:46:30 +0100 Received: from [192.168.2.21] (cheetah2.fritz.box [192.168.2.21]) by mail.home.webbedtables.de (Postfix) with ESMTP id D4BED83B2F for ; Sun, 15 Mar 2020 11:46:29 +0100 (CET) Content-Language: de-DE 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-mx.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Hi there, the following org snippet is describing my issue. Thanks in advance, Heiko * TODO post problem report about ob-calc duplicate stack-element issue     :LOGBOOK:     - State "TODO"       from              [2020-03-15 Sun 09:19]     :END: - I want to use ob-calc to do some "literate calculation" with the   purpose to document what I thought at the time I wrote it. - problem: When evaluating the calc snippets the top of stack element   is dropped. Because every "begin/end_src calc" block drops the top   of stack, one can't reuse the result in following blocks. - although without expecting any effect here is some version   information:     - emacs version: GNU Emacs 24.4.1 (x86_64-pc-linux-gnu, GTK+ Version     3.14.5) of 2017-09-12 on hullmann, modified by Debian     - org-version:   9.2 ** what I'd like to be able Number of cars (PKW) in germany: #+begin_src calc :exports both 45e6 #+end_src #+RESULTS: : 45000000. Yearly mileage in [km/y] #+begin_src calc :exports both 15000 #+end_src #+RESULTS: : 15000 Calculate amount of complete km per year #+begin_src calc :exports both '* #+end_src #+RESULTS: : 675000000000. ** the problem I'm facing and the nearly working work-around - problem: babel removes the resulting top stack element from the   stack - tried solution: duplicate the last stack-element on evaluation with   "' " (emulate press to duplicate the top element of the   stack in calc) - side effect: I normally delete trailing whitespace in my files - so   entering "' " is a dangerous workaround - I tried to local-set-key the § key to calc-enter which I thought   should enable a command "'§" to duplicate the top of stack. On   evaluation this resulted in an error "byte-code: Wrong type   argument: number-or-marker-p, nil" Number of cars (PKW) in germany: #+begin_src calc :exports both 45e6 ' #+end_src #+RESULTS: : 45000000. Yearly mileage in [km/y] #+begin_src calc :exports both 15000 ' #+end_src #+RESULTS: : 15000 Calculate amount of complete km per year #+begin_src calc :exports both '* ' #+end_src #+RESULTS: : 675000000000. ** hope for a solution or work around from the community - preferred: Is there a way to leave the top of stack from one snippet   to the next (which I don't know)? - alternative: Is there a way to duplicate the top of stack element   between begin/end_src calc blocks? - any advice is appreciated.