Re: Appending results from babel block

2024-01-27 Thread Ken Mankoff
Hi Matt,

On 2024-01-27 at 12:22 -08, Matt  wrote...
>   On Sat, 27 Jan 2024 03:20:37 +0100 Ken Mankoff wrote ---
>> Weirdly,
>> 
>> :results append drawer
>> 
>> Appends result #2, but then inserts all results after the first.
>  
> I'm not sure what you mean. However, trying it, I see bunches of
> "results-end" groups. I assume this is what you see, too?

Yes that's what I see in general format. You ran it 3x in on second so I can't 
very we're seeing the same thing. But the order becomes

1
5
4
3
2

That is, 2 is appended as expected, but then 3 is inserted after 1 but before 
2, 4 is after 1 but before 3, etc.

> I would expect to see:

Again, all your strings appear the same so I can' verify order. I don't mind 
multiple :results: :end: drawers, I just want the order to be

1
2
3
4
5


> I'm curious, what broader goal are you trying to achieve? How does the
> leading ":" stop you?

I have a beancount (plain text accounting) file that is an Org file. Beancount 
parsing of that file ignores lines that start with "*" or "#", so I can 
organize finances by heading. The beancount parser fails on lines that begin 
with ":"

Under a given set of headings, e.g.,

* Finances
** Assets
*** Bank Foo
 Checking

I parse the bank data (code defined elsewhere via library-of-babel) and convert 
to Beancount syntax with:

#+CALL: bank2bc()

I'd like to evaluate (C-c C-c) that CALL when I get a new statement each month, 
and have results appended, not prepended.

For accounts with a lot of transactions, I add a new  heading, and then this 
issue goes away.

* 2024-01

But for accounts with few transactions, I'd like to break it by year not month, 
and have transactions appear in chronological order.


  -k.



Appending results from babel block

2024-01-26 Thread Ken Mankoff
Hello,

I'd like to append results from a babel block, but without the leading ":" that 
sometimes appears. Is this possible. I'm using v9.7-pre.

This works, but has leading colons:

#+BEGIN_SRC bash :results append
echo $(date)
#+END_SRC

#+RESULTS:
: Fri Jan 26 07:17:00 PM PST 2024
: Fri Jan 26 07:17:01 PM PST 2024
: Fri Jan 26 07:17:02 PM PST 2024
: Fri Jan 26 07:17:04 PM PST 2024

Setting :results append raw

prepends - understandably because 'raw' means there is no delimiter, and no way 
to know where the results end.

Weirdly,

:results append drawer

Appends result #2, but then inserts all results after the first.

Is this last behavior a bug? Any way to have true 'append' w/o ":"?

Thanks,

  -k.



Re: Diary sexp and comparing dates, agenda

2024-01-12 Thread Ken Mankoff
Hi David,

I'm not sure if this will help, but I have to file time sheets on the last 
weekday less than or equal to the 15th and last-day-of-month.

I wrote two diary functions to achieve this (I don't handle holiday edge 
cases). I use these functions with:

** INFO [#A] Time Sheet
<%%(kdm/diary-last-weekday-of-month date)>
<%%(kdm/diary-last-weekday-15th date)>

Functions are:

(defun kdm/diary-last-weekday-15th (date)
  (let* (
 (dow (calendar-day-of-week date))
 (dom (calendar-extract-day date))
 (weekday (and (>= dow 1) (<= dow 5
(or 
 (and weekday (= dom 15))
 (and (= dow 5) (= dom 14))
 (and (= dow 5) (= dom 13)

(defun kdm/diary-last-weekday-of-month (date)
  (let* (
 (dow (calendar-day-of-week date))
 (dom (calendar-extract-day date))
 (month (calendar-extract-month date))
 (year (calendar-extract-year date))
 (ldom-num (calendar-last-day-of-month month year))
 (weekday (and (>= dow 1) (<= dow 5
(or 
 (and weekday (= dom ldom-num))
 (and (= dow 5) (= (+ 1 dom) ldom-num))
 (and (= dow 5) (= (+ 2 dom) ldom-num)

  -k.

On 2024-01-11 at 21:58 -08, David Rogers 
wrote...
> Hello all
>
> I'm using the Org agenda to show when certain church occasions will
> happen. Mostly I've got them working correctly, after "stealing" the
> method used in holidays.el for finding the date of Easter, along with
> someone else's function that then uses that to find the difference
> between Easter and today. (I'm pretty sure that whole idea was on
> emacswiki, and I think Paul Sexton put it together.)
>
> So now I have a much smaller problem to solve, but I don't understand
> how to get it to work; I suspect it has to do with how dates get
> formatted within different functions. Using what I already have, I can
> do this:
>
> * Example 1 <%%(= 245 (mf-days-from-easter))>
>
> because "mf-days-from-easter" is defined in my init file, along with
> the definition of Easter itself. This does what it looks like it
> should do; this year, Example 1 is shown on December 1.
>
> And I can do
>
> * Example 2 <%%(and (diary-float 1 0 5 7) (<= (mf-days-from-easter)
> -56))>
>
> to say "five Sundays after January 6th, but only if Easter is still 8
> weeks away or more".
>
> But Example 1 isn't quite finished, because that date is too close to
> Christmas. I can easily show a diary sexp defining when "too close to
> Christmas" is:
>
> <%%(diary-float 12 0 -4 24)>
>
> So I want to combine these ideas, to say "Show Example 1 in the agenda
> 245 days after Easter each year, but only if it's earlier than the
> fourth Sunday before Christmas".
>
> I could do a long string of (and (not this day, not this day, etc etc
> [insert long list of days] . . . , but that seems like a last resort.
>
> Everything in this question fits into "the current year according to
> the agenda view" - there's no need to consider dates that cross a year
> boundary.
>
> So: Is there a fairly simple way to define a (mf-days-from-advent)
> that will do a similar job to what (mf-days-from-easter) is already
> doing (i.e. it works when used in a diary sexp)?
>
>
> Here are the relevant definitions I've been using:
>
>
>(defun mf-easter (displayed-year)
>(let* ((century (1+ (/ displayed-year 100)))
>   (shifted-epact ; age of moon for April 5...
>(% (+ 14 (* 11 (% displayed-year 19)) ; ...by Nicaean
>rule
>  (- ; ...corrected for the Gregorian century rule
>   (/ (* 3 century) 4)) (/ ; ...corrected for
>  Metonic cycle inaccuracy
>   (+ 5 (* 8 century)) 25) (* 30 century)) ; keeps
>  value positive
>   30)) (adjusted-epact ; adjust for 29.5 day month
>(if (or (zerop shifted-epact)
>(and (= shifted-epact 1) (< 10 (%
>   displayed-year 19
>(1+ shifted-epact) shifted-epact))
>   (paschal-moon ; day after the full moon on or after
>   March 21
>(- (calendar-absolute-from-gregorian (list 4 19
>displayed-year))
>   adjusted-epact))) (calendar-dayname-on-or-before 0
>   (+ paschal-moon 7
>
>
>
>(defun mf-days-from-easter ()
>  "When used in a diary sexp, this function will calculate how many
> days are between the current date (DATE) and Easter Sunday."
>  (- (calendar-absolute-from-gregorian date)
> (mf-easter (calendar-extract-year date




Re: Gantt Chart with org-mode

2023-11-07 Thread Ken Mankoff
And Mermaid with ob-mermaid.

https://mermaid.js.org/syntax/gantt.html

  -k.

Please excuse brevity. Sent from tiny pocket computer with non-haptic
feedback keyboard.

On Sun, Nov 5, 2023, 05:08 Christophe Schockaert 
wrote:

> On 2023-11-04 13:30, Heime wrote:
> > Can one construct a Gantt Chart with org-mode ?
>
> Although I didn’t try it yet, there is Elgantt hat caught my eyes :
> https://github.com/legalnonsense/elgantt
>
> Have a good day and nice Org discoveries,
> Christophe
>
>


Re: Gantt Chart with org-mode

2023-11-04 Thread Ken Mankoff
Or PlantUML and ob-plantuml.

https://plantuml.com/gantt-diagram

  -k.

Please excuse brevity. Sent from tiny pocket computer with non-haptic
feedback keyboard.

On Sat, Nov 4, 2023, 06:55 Heime  wrote:

>
> Can one construct a Gantt Chart with org-mode ?
>
>


Re: [BUG] Undo eats buffer [9.7-pre (release_9.6.10-888-g098f08 @ /home/kdm/local/src/org-mode/lisp/)]

2023-10-26 Thread Ken Mankoff
Hi Ihor,

On 2023-10-26 at 05:10 -07, Ihor Radchenko 
wrote...
> Have you tried reporting your problem to emacs-jupyter devs? There
> might be a better chance that they can fix or suggest something.

There is an open issue on that GitHub repository but someone thought it might 
be org-cache related, which is why I posted here. Thank you for your 
suggestions, I will report back there and see if it helps us make progress.

  -k.



[BUG] Undo eats buffer [9.7-pre (release_9.6.10-888-g098f08 @ /home/kdm/local/src/org-mode/lisp/)]

2023-10-26 Thread Ken Mankoff


I'm running into a bug where if I (undo) after evaluating an Org Babel 
emacs-jupyter code block, several hundred lines of the Org buffer below are 
erased. Unfortunately I am having trouble creating an MWE that demonstrates 
this, but I hope the org-element-cache warning below may still be helpful.

The bug occurs when the emacs-jupyter (Python) block produces are error, and 
results look like the following, and then I eval (undo):

#+RESULTS:
:RESULTS:
: some text here
# [goto error]
#+begin_example
  lots of text here
#+end_example
:END:

I've tried (setq org-element-use-cache nil) but that does not seem to help. Any 
suggestions how to work around this, or help the emacs-jupyter effort address 
this if it is their domain, will be much appreciated.

Thanks,

   -k.



Your bug report will be posted to the Org mailing list.

Warning (org-element-cache): org-element--cache: Unregistered buffer 
modifications detected (57640 != 55418). Resetting.
If this warning appears regularly, please report the warning text to Org mode 
mailing list (M-x org-submit-bug-report).
The buffer is: misc.org
 Current command: nil
 Backtrace:
"  backtrace-to-string(nil)
  org-element--cache-sync(# 37660)
  org-element-at-point()
  (progn (org-element-at-point))
  (unwind-protect (progn (org-element-at-point)) (set-match-data 
save-match-data-internal 'evaporate))
  (let ((save-match-data-internal (match-data))) (unwind-protect (progn 
(org-element-at-point)) (set-match-data save-match-data-internal 'evaporate)))
  (let ((element (let ((save-match-data-internal (match-data))) (unwind-protect 
(progn (org-element-at-point)) (set-match-data save-match-data-internal 
'evaporate) (and (eq (org-element-type element) 'src-block) (>= 
(line-beginning-position) (let* ((parray (and t (let* ... ... (if parray 
(let* ((val ...)) (if (eq val ...) 'nil (let ... val))) (let* ((val ...)) (cond 
(... ...) (... ...) (t ...)) (<= (line-end-position) (save-excursion 
(save-restriction (widen) (goto-char (let* (...) (if parray ... ...))) 
(skip-chars-backward \" \\11\\n\") (line-end-position 
(org-element--property :language element nil nil)))
  org-eldoc-get-src-lang()
  (let ((lang (org-eldoc-get-src-lang))) (cond ((string= lang \"org\") nil) 
((or (string= lang \"emacs-lisp\") (string= lang \"elisp\")) (cond ((and 
(boundp 'eldoc-documentation-functions) (fboundp 'elisp-eldoc-var-docstring) 
(fboundp 'elisp-eldoc-funcall)) (let ((eldoc-documentation-functions ...)) 
(eldoc-print-current-symbol-info))) ((fboundp 
'elisp-eldoc-documentation-function) (elisp-eldoc-documentation-function)) (t 
(let (eldoc-documentation-function) (eldoc-print-current-symbol-info) ((or 
(string= lang \"c\") (string= lang \"C\")) (if (require 'c-eldoc nil t) (progn 
(c-eldoc-print-current-symbol-info ((string= lang \"css\") (if (require 
'css-eldoc nil t) (progn (css-eldoc-function ((string= lang \"php\") (if 
(require 'php-eldoc nil t) (progn (php-eldoc-function ((or (string= lang 
\"go\") (string= lang \"golang\")) (if (require 'go-eldoc nil t) (progn 
(go-eldoc--documentation-function (t (let ((doc-fun 
(org-eldoc-get-mode-local-documentation-function lang)) (callback (car args))) 
(if (functionp doc-fun) (progn (if (functionp callback) (funcall doc-fun 
callback) (funcall doc-fun
  (or (org-eldoc-get-breadcrumb) (org-eldoc-get-src-header) (let ((lang 
(org-eldoc-get-src-lang))) (cond ((string= lang \"org\") nil) ((or (string= 
lang \"emacs-lisp\") (string= lang \"elisp\")) (cond ((and (boundp ...) 
(fboundp ...) (fboundp ...)) (let (...) (eldoc-print-current-symbol-info))) 
((fboundp 'elisp-eldoc-documentation-function) 
(elisp-eldoc-documentation-function)) (t (let (eldoc-documentation-function) 
(eldoc-print-current-symbol-info) ((or (string= lang \"c\") (string= lang 
\"C\")) (if (require 'c-eldoc nil t) (progn 
(c-eldoc-print-current-symbol-info ((string= lang \"css\") (if (require 
'css-eldoc nil t) (progn (css-eldoc-function ((string= lang \"php\") (if 
(require 'php-eldoc nil t) (progn (php-eldoc-function ((or (string= lang 
\"go\") (string= lang \"golang\")) (if (require 'go-eldoc nil t) (progn 
(go-eldoc--documentation-function (t (let ((doc-fun 
(org-eldoc-get-mode-local-documentation-function lang)) (callback (car args))) 
(if (functionp doc-fun) (progn (if ... ... ...
  org-eldoc-documentation-function(#f(compiled-function (string  plist) 
#))
  run-hook-with-args-until-success(org-eldoc-documentation-function 
#f(compiled-function (string  plist) #))
  eldoc-documentation-default()
  eldoc--invoke-strategy(nil)
  eldoc-print-current-symbol-info()
  #f(compiled-function () #)()
  apply(#f(compiled-function () #) nil)
  timer-event-handler([t 0 0 50 nil #f(compiled-function () #) nil idle 0 nil])
" Disable showing Disable logging



Emacs  : GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 

Re: [O] Injecting properties with noweb

2023-04-08 Thread Ken Mankoff
Hi Ihor,

I had posted this in another thread, but repeat it here for anyone interested. 
I think it is a similar end result to what you posted, but skips the =identity= 
 step. The examples below show (1) setting a bash environment variable in 
screen, or (2) printing from a Python prompt after sshing to a remote computer. 
It is language agnostic. Because it uses PROPERTIES and not :var, it also lets 
me work in Org Column View mode.


* Header
:PROPERTIES:
:foo: 42
:END:

#+NAME: ex1-screen-bash
#+BEGIN_SRC screen

export foo="<>"
#+END_SRC

#+NAME: ex2-ssh-python
#+BEGIN_SRC bash

ssh somewhere
python
print("<>")
#+END_SRC

#+CALL: ex2-ssh-python()

#+RESULTS:
: foo


The relevant section from my library-of-babel is:

* Properties into header args
:PROPERTIES:
:hellomessage: hello
:END:

https://emacs.stackexchange.com/questions/41922/

#+NAME: get_property
#+BEGIN_SRC emacs-lisp :var prop_name="" :results silent

(org-with-point-at org-babel-current-src-block-location
  (org-entry-get nil prop_name t))
#+END_SRC

** Example Usage

*** Header arg

#+HEADER: :var prop_message=(org-entry-get nil "hellomessage" t)
#+BEGIN_SRC emacs-lisp
  (message prop_message)
#+END_SRC

#+RESULTS:
: hello

*** Noweb

#+BEGIN_SRC emacs-lisp :noweb yes
  (message "<>")
#+END_SRC


#+RESULTS:
: hello

#+BEGIN_SRC bash :noweb yes :results verbatim
echo "<>"
#+END_SRC

#+RESULTS:
: hello

If hope this helps someone if they need it.

  -k.




On 2023-04-08 at 05:22 -07, Ihor Radchenko  wrote...
> Ken Mankoff  writes:
>
>> Is it possible to set variables using Org Babel inside screen, which
>> does not support ":var" header args? I'd actually lke a double-nested
>> screen over ssh, and the ability to re-use Babel code blocks under
>> different headings, using header args or PROPERTIES to change
>> variables. That is, something like:
>
> Yes.
>
>> ...
>> #+NAME: get-prop
>> #+BEGIN_SRC emacs-lisp :var prop="FOO" :noweb yes
>> (org-macro--get-property prop "")
>> #+END_SRC
>>
>> #+NAME: inject_vars
>> #+BEGIN_SRC shell :noweb yes
>> # echo <> # testing
>> echo export FOO=<>
>> echo export BAR=<>
>> echo export BAZ=<>
>> #+END_SRC
>
> This did not work as you expected because noweb evaluates code block
> with point at that code block.
>
> To get the property value at the code block where you expand noweb
> reference, you need to compute the value in the arguments to the
> reference. Something like
>
> #+name: identity
> #+begin_src elisp :var x=""
>
> x
> #+end_src
>
> ...
> echo export FOO=< ...




Re: [PATCH v4] lisp/ob-screen.el: Support ~:var~ header args for babel blocks

2023-03-19 Thread Ken Mankoff
Hi Max,

On 2023-03-16 at 11:09 -04, Max Nikulin  wrote...
> Ken, you wrote that you have other patches for ob-screen.el. Do you
> plan to sent them?

Here is the other patch. Respect custom screen command.

  -k.

>From ff919de09e020fa053f5727f3b36026a3a773f88 Mon Sep 17 00:00:00 2001
From: "Kenneth D. Mankoff" 
Date: Sun, 26 Feb 2023 17:38:54 -0800
Subject: [PATCH 2/2] ob-screen.el: respect custom screen location

---
 lisp/ob-screen.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index 6356d84dd..2013cf12d 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -98,7 +98,7 @@ In case you want to use a different screen than one selected by your $PATH")
 
 (defun org-babel-screen-session-socketname (session)
   "Check if SESSION exists by parsing output of \"screen -ls\"."
-  (let* ((screen-ls (shell-command-to-string "screen -ls"))
+  (let* ((screen-ls (shell-command-to-string (concat org-babel-screen-location " -ls")))
  (sockets (delq
 		   nil
(mapcar
-- 
2.34.1



Re: Noweb Function's body without evaluation

2023-03-15 Thread Ken Mankoff
Hi,

I'm not sure that I understand your issue or needs from the provided examples, 
but I wonder if the example I provide here would be helpful. It bypasses :var 
an lets you inject a PROPERTY value anywhere. It is also language agnostic. You 
can use it to execute commands (that are set as PROPERTY values) or set 
variables to values.

https://lists.gnu.org/archive/html/emacs-orgmode/2023-03/msg00251.html

  -k.

On 2023-03-15 at 18:54 -04, suarezmigu...@icloud.com wrote...
> Hello Org-mode community. I’m using Emacs Doom Framework, specifically:
>
> Emacs 28.2 (build 1, aarch64-apple-darwin22.3.0, Carbon Version 169
> AppKit 2299.4) of 2023-02-23.
>
> I use heavily org-mode for Literate DevOps, so I have a lot of shell
> commands that connect through SSH and do some things later, for
> example:
>
> #+name: initSSH
> #+begin_src shell :var connection=“admin@somehost"
>
> ssh -t miguel@host "sudo -u someuser ssh -t $connection 'sudo su'"
> #+end_src
>
> So then I can call:
>
> #+call: initSSH(connection=“admin@anotherhost”)
>
> With any other header parameters or session, the above works
> correctly. I cannot use tramp due to network latency issues, so this
> is the most performance way for me, since I also have to do some
> multi-hops which are indeed supported in tramp, but it is too slow for
> me, so I rather only commands.
>
> The thing is that, I then would like to call these not with a #+call
> function, but add them into a bigger script, let’s say that I define
> another command:
>
> #+name: getStorage
> #+begin_src shell
>
> df
> #+end_src
>
> Which has to be run in a remote server, could be any remote server as
> I have to connect to several. So I would like to be able to:
>
> #+begin_src shell
> <>
> <>
> #+end_src
>
>
> The first doesn’t work as org-mode runs the code and passes the
> resulting string to bash, which isn’t a command. The latter works
> normally. So the issue here are the parameters.
>
> So I made another simple example for this:
>
> #+name: greeting
> #+begin_src sh :var name="world" :results output :session testing
>
> echo "hello, $name\!"
> #+end_src
>
> #+results: greeting
> #+begin_src sh
>
> hello, world\!
> #+end_src
>
> #+begin_src shell
> <>
> #+end_src
>
>
> This results in sh: hello,: command not found, as it is executing the 
> function. I see in the documentation that I can:
> - Call a function’s body with <>
> - Execute a function and return its results with <>
> - Execute a function and return its results even with different params with 
> <>
>
> So right now, the one that’s missing is, call a function’s body with 
> different parameters. So the
> function <> is not evaluated.
>
> After searching a lot, I came across:
>
> #+begin_src shell :session testing
> <>
> #+end_src
>
> Which results in:
>
> sh-3.2$ PS1="org_babel_sh_prompt> "
> org_babel_sh_prompt> name='Testin'
> org_babel_sh_prompt> echo "hello, $name\!"
> hello, Testin\!
> org_babel_sh_prompt> echo 'org_babel_sh_eoe'
> org_babel_sh_eoe
> org_babel_sh_prompt> hello, Testin\!
> sh: hello,: command not found
> org_babel_sh_prompt> echo 'org_babel_sh_eoe'
> org_babel_sh_eoe
> org_babel_sh_prompt> 
>
> Which is somewhat what I need since at least the variable is changed,
> but the result of this execution is also passed to shell so, same
> error.
>
> I can’t find much documentation about this, what is the correct syntax
> here?,
>
> Thank you!




Re: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks

2023-03-15 Thread Ken Mankoff
Hi Ihor and Max,

Just a follow-up note that I am unlikely to be able to complete this patch 
anytime soon. Re-alignment of priorities because my need for :var header 
support in Org Babel is mitigated by a different method of injecting variables 
into Org Babel sections: Use noweb.

I find this more powerful than =:var=. The examples below show (1) setting a 
bash environment variable in screen, or (2) printing from a Python prompt after 
sshing to a remote computer. It is language agnostic. Because it uses 
PROPERTIES and not :var, it also lets me work in Org Column View mode.

* Header
:PROPERTIES:
:foo: 42
:END:

#+NAME: ex1-screen-bash
#+BEGIN_SRC screen
export foo="<>"
#+END_SRC

#+NAME: ex2-ssh-python
#+BEGIN_SRC bash
ssh somewhere
python
print("<>")
#+END_SRC

#+CALL: ex2-ssh-python()

#+RESULTS:
: foo


The relevant section from my library-of-babel is:

* Properties into header args
:PROPERTIES:
:hellomessage: hello
:END:

https://emacs.stackexchange.com/questions/41922/

#+NAME: get_property
#+BEGIN_SRC emacs-lisp :var prop_name="" :results silent
(org-with-point-at org-babel-current-src-block-location
  (org-entry-get nil prop_name t))
#+END_SRC

** Example Usage

*** Header arg

#+HEADER: :var prop_message=(org-entry-get nil "hellomessage" t)
#+BEGIN_SRC emacs-lisp
  (message prop_message)
#+END_SRC

#+RESULTS:
: hello

*** Noweb
#+BEGIN_SRC emacs-lisp :noweb yes
  (message "<>")
#+END_SRC

#+RESULTS:
: hello

#+BEGIN_SRC bash :noweb yes :results verbatim
echo "<>"
#+END_SRC

#+RESULTS:
: hello

If hope this helps someone if they need it.

  -k.



Re: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks

2023-02-26 Thread Ken Mankoff
Hi Max,

On 2023-02-26 at 02:11 -08, Max Nikulin  wrote:
> As to `org-babel-screen-test' perhaps the issue is additional newline
> added after random number. I have not tried stepping through the
> function in debugger though.

I haven't either. I'll see if I can figure out the issue with the help of the 
debugger.

> It seems top level headings were separated by single empty line.

Fixed.

> ;; Reuse the variable assignment code from ob-shell
>> +(defalias 'org-babel-variable-assignments:screen
>> +  'org-babel-variable-assignments:shell)
>
> Have you tried to compile using make? I expect a warning due to missed
> (require 'ob-shell).

Make did not complain about this, but did suggest mapcar -> mapc.

> P.S. My expectations based on the package name were that ob-screen is
> intended for running commands on remote hosts.

That too. But I also find it useful for running long commands on localhost 
without worrying about :async in emacs.

Another nice thing here is that this is, by default, session-based, and can be 
accessed outside of Org, while Bash blocks don't always play nice with 
sessions. I can, for example and all in Org Babel, spawn a screen session, ssh 
to a remote host, and then inject :var into the remote session. I find this 
quite powerful, and I haven't figured out how to do it with =BEGIN_SRC bash= or 
=BEGIN_SRC shell= blocks.

> Reading the code I noticed a couple of issues that may be fixed when
> you will decide to touch this file next time: -
> `org-babel-screen-session-socketname' does not respect
> `org-babel-screen-location' - `string-match' is used where it may be
> replaced by `string-match-p' since match data is not used.

Both fixed. Should these be separate patches (3 total), or two - one for the 
new feature, and one 'cleanup'?

> I noticed that ob-core besides org-babel-default-header-args:LANG uses
> org-babel-header-args:LANG. The latter is not defined in ob-screen,
> however I am unsure concerning its effect (completion?).

I don't understand this either.

  -k.



Re: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks

2023-02-26 Thread Ken Mankoff
Hi Ihor,

On 2023-02-26 at 04:18 -08, Ihor Radchenko  wrote:
>> +;; Reuse the variable assignment code from ob-shell
>> +(defalias 'org-babel-variable-assignments:screen
>> +  'org-babel-variable-assignments:shell)
>
> This will work, but you are relying on implementation detail of
> ob-shell.el. A more safe approach would be calling
> org-babel-variable-assignments:LANG depending on the :cmd header arg.
> For :cmd bash - org-babel-variable-assignments:bash, for :cmd fish -
> org-babel-variable-assignments:fish.
>
> To archive this, you can define a full
> org-babel-variable-assignments:screen function that does what I
> described.

You're pushing my lisp skills here. Which is fine, but I might need some help.

In ob-shell I see

(defcustom org-babel-shell-names
  '("sh" "bash" "zsh" "fish" "csh" "ash" "dash" "ksh" "mksh" "posh")

Should I create a function that, using case statement or something similar, 
checks for each of these and calls that flavor? I think I could do that.


But if I also see org-babel-shell-initialize in ob-shell that looks like it 
creates defaliases for each of these to (org-babel-execute:shell) and 
#'org-babel-variable-assignments:shell.

I'm not sure how that is very different from what I've done. I'm not sure what 
to do here, nor how to do what you suggest (yet - I've only read it so far, not 
spent a lot of time experimenting and searching, so I may be able to implement 
what I think is a solution to what you wrote, but I doubt it'll be what you 
expect).

  -k.



Re: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks

2023-02-25 Thread Ken Mankoff
Hi Max,

On 2023-02-25 at 08:05 -08, Max Nikulin  wrote:
> I believe, it is safer to define
> `org-babel-variable-assignments:screen' some way: alias, substitution,
> function that calls `org-babel-variable-assignments:shell'. I am
> unsure which variant is better. I see a couple of callers for specific
> language in ob-core.el.

How's this with a defalias?

  -k.

>From f7ca0258d72b3da5743b1134718b1d1f0d74491d Mon Sep 17 00:00:00 2001
From: "Kenneth D. Mankoff" 
Date: Mon, 20 Feb 2023 21:40:39 -0800
Subject: [PATCH] lisp/ob-screen.el: Support var header args for babel blocks

* ob-screen.el: (org-babel-execute:screen): Parse header params
for `:var', then inject into screen session.

* etc/ORG-NEWS: Document as New Feature
---
 etc/ORG-NEWS  | 12 
 lisp/ob-screen.el |  8 
 2 files changed, 20 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 87ecd77cd..0da686354 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -106,6 +106,18 @@ selection.
 TODO state, priority, tags, statistics cookies, and COMMENT keywords
 are allowed in the tree structure.
 
+*** ob-screen now supports :var header arguments
+
+The ~:var~ header arg is now supported.
+
+#+BEGIN_src org
+,#+BEGIN_SRC screen :var x=42
+,echo $x
+,#+END_SRC
+#+END_src
+
+
+
 * Version 9.6
 
 ** Important announcements and breaking changes
diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index 269538e79..6e6a31ea6 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -40,6 +40,10 @@
 
 (require 'ob)
 
+;; Reuse the variable assignment code from ob-shell
+(defalias 'org-babel-variable-assignments:screen
+  'org-babel-variable-assignments:shell)
+
 (defvar org-babel-screen-location "screen"
   "The command location for screen.
 In case you want to use a different screen than one selected by your $PATH")
@@ -55,8 +59,12 @@ In case you want to use a different screen than one selected by your $PATH")
   (message "Sending source code block to interactive terminal session...")
   (save-window-excursion
 (let* ((session (cdr (assq :session params)))
+   (var-lines (org-babel-variable-assignments:screen params))
(socket (org-babel-screen-session-socketname session)))
   (unless socket (org-babel-prep-session:screen session params))
+  (mapcar (lambda (var)
+(org-babel-screen-session-execute-string session var))
+  var-lines)
   (org-babel-screen-session-execute-string
session (org-babel-expand-body:generic body params)
 
-- 
2.34.1



Re: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks

2023-02-25 Thread Ken Mankoff
I note that `org-babel-screen-test` fails, but it appears to fail before
this change too...

  -k.

On Sat, Feb 25, 2023 at 7:14 AM Ken Mankoff  wrote:

> Hi Max,
>
> On 2023-02-24 at 19:51 -08, Max Nikulin  wrote:
> > On 25/02/2023 01:33, Ken Mankoff wrote:
> > I am unsure if Org markup is suitable for commit messages (~:var~)
> > since it may appear in Emacs commit logs.
>
> Fixed.
>
> > The code still depends on on ob-shell. Is there a reason why calling
> > `org-babel-variable-assignments:shell' is a worse variant than copy of
> > the whole function body?
>
> I didn't realize that was a dependency. I now use that function. This also
> means that arrays/tables/etc. are all supported by :var, although not in
> the default screen ":cmd sh" because sh doesn't support "declare", but it
> works with ":cmd bash".
>
> Improved patch attached.
>
> Thanks,
>
>   -k.
>
>
>
>


Re: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks

2023-02-25 Thread Ken Mankoff
Hi Max,

On 2023-02-24 at 19:51 -08, Max Nikulin  wrote:
> On 25/02/2023 01:33, Ken Mankoff wrote:
> I am unsure if Org markup is suitable for commit messages (~:var~)
> since it may appear in Emacs commit logs.

Fixed.

> The code still depends on on ob-shell. Is there a reason why calling
> `org-babel-variable-assignments:shell' is a worse variant than copy of
> the whole function body?

I didn't realize that was a dependency. I now use that function. This also 
means that arrays/tables/etc. are all supported by :var, although not in the 
default screen ":cmd sh" because sh doesn't support "declare", but it works 
with ":cmd bash".

Improved patch attached.

Thanks,

  -k.



>From 580499925644cdb9c2dd8c783ec03c095bec7a86 Mon Sep 17 00:00:00 2001
From: "Kenneth D. Mankoff" 
Date: Mon, 20 Feb 2023 21:40:39 -0800
Subject: [PATCH] lisp/ob-screen.el: Support var header args for babel blocks

* ob-screen.el: (org-babel-execute:screen): Parse header params
for `:var', then inject into screen session.

* etc/ORG-NEWS: Document as New Feature
---
 etc/ORG-NEWS  | 12 
 lisp/ob-screen.el |  4 
 2 files changed, 16 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 87ecd77cd..0da686354 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -106,6 +106,18 @@ selection.
 TODO state, priority, tags, statistics cookies, and COMMENT keywords
 are allowed in the tree structure.
 
+*** ob-screen now supports :var header arguments
+
+The ~:var~ header arg is now supported.
+
+#+BEGIN_src org
+,#+BEGIN_SRC screen :var x=42
+,echo $x
+,#+END_SRC
+#+END_src
+
+
+
 * Version 9.6
 
 ** Important announcements and breaking changes
diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index 269538e79..bd8650f6b 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -55,8 +55,12 @@ In case you want to use a different screen than one selected by your $PATH")
   (message "Sending source code block to interactive terminal session...")
   (save-window-excursion
 (let* ((session (cdr (assq :session params)))
+   (var-lines (org-babel-variable-assignments:shell params))
(socket (org-babel-screen-session-socketname session)))
   (unless socket (org-babel-prep-session:screen session params))
+  (mapcar (lambda (var)
+(org-babel-screen-session-execute-string session var))
+  var-lines)
   (org-babel-screen-session-execute-string
session (org-babel-expand-body:generic body params)
 
-- 
2.34.1



Re: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks

2023-02-24 Thread Ken Mankoff

I realize the patch should be an attachment, not the body of the email. Sorry. 
R-sending as attachment.

  -k.

>From 5a4707cc16fb5f10cd394762f41d50d8830db240 Mon Sep 17 00:00:00 2001
From: "Kenneth D. Mankoff" 
Date: Mon, 20 Feb 2023 21:40:39 -0800
Subject: [PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel
 blocks

* ob-screen.el: (org-babel-execute:screen): Parse header params
for `:var', then inject into screen session.
(org-babel-variable-assignments:screen): Copied from
ob-shell.el org-babel-variable-assignments:shell

* etc/ORG-NEWS: Document as New Feature

This change only supports single-value variables
(e.g., ~:var x=42~), not tables or arrays as is
currently supported by some other languages.
---
 etc/ORG-NEWS  | 13 +
 lisp/ob-screen.el | 21 +
 2 files changed, 34 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 87ecd77cd..d4b454d13 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -106,6 +106,19 @@ selection.
 TODO state, priority, tags, statistics cookies, and COMMENT keywords
 are allowed in the tree structure.
 
+*** ob-screen now supports :var header arguments
+
+The ~:var~ header arg now supports simple single-value variables
+(arrays and tables are not supported).
+
+#+BEGIN_src org
+,#+BEGIN_SRC screen :var x=42
+,echo $x
+,#+END_SRC
+#+END_src
+
+
+
 * Version 9.6
 
 ** Important announcements and breaking changes
diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index 269538e79..d8f361e50 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -55,11 +55,32 @@ In case you want to use a different screen than one selected by your $PATH")
   (message "Sending source code block to interactive terminal session...")
   (save-window-excursion
 (let* ((session (cdr (assq :session params)))
+   (var-lines (org-babel-variable-assignments:screen params))
(socket (org-babel-screen-session-socketname session)))
   (unless socket (org-babel-prep-session:screen session params))
+  (mapcar (lambda (var)
+(org-babel-screen-session-execute-string session var))
+  var-lines)
   (org-babel-screen-session-execute-string
session (org-babel-expand-body:generic body params)
 
+(defun org-babel-variable-assignments:screen (params)
+  "Return list of shell statements assigning the block's variables."
+  ;; From ob-shell but change function name from ":shell" to ":screen"
+  (let ((sep (cdr (assq :separator params)))
+	(hline (when (string= "yes" (cdr (assq :hlines params)))
+		 (or (cdr (assq :hline-string params))
+		 "hline"
+(mapcar
+ (lambda (pair)
+   (if (string-suffix-p "bash" shell-file-name)
+	   (org-babel--variable-assignments:bash
+(car pair) (cdr pair) sep hline)
+ (org-babel--variable-assignments:sh-generic
+	  (car pair) (cdr pair) sep hline)))
+ (org-babel--get-vars params
+
+
 (defun org-babel-prep-session:screen (_session params)
   "Prepare SESSION according to the header arguments specified in PARAMS."
   (let* ((session (cdr (assq :session params)))
-- 
2.34.1



[PATCH] lisp/ob-screen.el: Support ~:var~ header args for babel blocks

2023-02-24 Thread Ken Mankoff


* ob-screen.el: (org-babel-execute:screen): Parse header params
for `:var', then inject into screen session.
(org-babel-variable-assignments:screen): Copied from
ob-shell.el org-babel-variable-assignments:shell

* etc/ORG-NEWS: Document as New Feature

This change only supports single-value variables
(e.g., ~:var x=42~), not tables or arrays as is
currently supported by some other languages.

---
 etc/ORG-NEWS  | 13 +
 lisp/ob-screen.el | 21 +
 2 files changed, 34 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 87ecd77cd..d4b454d13 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -106,6 +106,19 @@ selection.
 TODO state, priority, tags, statistics cookies, and COMMENT keywords
 are allowed in the tree structure.
 
+*** ob-screen now supports :var header arguments
+
+The ~:var~ header arg now supports simple single-value variables
+(arrays and tables are not supported).
+
+#+BEGIN_src org
+,#+BEGIN_SRC screen :var x=42
+,echo $x
+,#+END_SRC
+#+END_src
+
+
+
 * Version 9.6
 
 ** Important announcements and breaking changes
diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index 269538e79..d8f361e50 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -55,11 +55,32 @@ In case you want to use a different screen than one 
selected by your $PATH")
   (message "Sending source code block to interactive terminal session...")
   (save-window-excursion
 (let* ((session (cdr (assq :session params)))
+   (var-lines (org-babel-variable-assignments:screen params))
(socket (org-babel-screen-session-socketname session)))
   (unless socket (org-babel-prep-session:screen session params))
+  (mapcar (lambda (var)
+(org-babel-screen-session-execute-string session var))
+  var-lines)
   (org-babel-screen-session-execute-string
session (org-babel-expand-body:generic body params)
 
+(defun org-babel-variable-assignments:screen (params)
+  "Return list of shell statements assigning the block's variables."
+  ;; From ob-shell but change function name from ":shell" to ":screen"
+  (let ((sep (cdr (assq :separator params)))
+   (hline (when (string= "yes" (cdr (assq :hlines params)))
+(or (cdr (assq :hline-string params))
+"hline"
+(mapcar
+ (lambda (pair)
+   (if (string-suffix-p "bash" shell-file-name)
+  (org-babel--variable-assignments:bash
+(car pair) (cdr pair) sep hline)
+ (org-babel--variable-assignments:sh-generic
+ (car pair) (cdr pair) sep hline)))
+ (org-babel--get-vars params
+
+
 (defun org-babel-prep-session:screen (_session params)
   "Prepare SESSION according to the header arguments specified in PARAMS."
   (let* ((session (cdr (assq :session params)))



[O] Injecting properties with noweb

2023-02-20 Thread Ken Mankoff
Hello,

Is it possible to set variables using Org Babel inside screen, which does not 
support ":var" header args? I'd actually lke a double-nested screen over ssh, 
and the ability to re-use Babel code blocks under different headings, using 
header args or PROPERTIES to change variables. That is, something like:

* Setup
:SETTINGS:
:FOO: default
:BAR: one
:header-args:screen+: :cmd /bin/bash :session (org-macro--get-property "FOO" "")
:END:

#+NAME: setup
#+BEGIN_SRC screen
if [[ ! $(hostname) =~ "host"* ]]; then ssh host; fi
<>
# eval <> ??
echo $FOO
#+END_SRC

Should print out "one" (the default setting under Setup) in the screen terminal.

** OTHER
:PROPERTIES:
:FOO: two
:END:

#+BEGIN_SRC screen
<>
#+END_SRC

Should print out "two" (the sub-heding adjusted property) in the screen 
terminal.


I'm OK with not being able to inject arbitrary variables, only the ~10 or so 
that I need to be able to set, and having a code block that has these 10 
hard-coded on the LHS, but with some <> or something on the RHS so that 
they value of the variable can be controlled using PROPERTIES under headings 
(better yet, header-args, but I don't think that is possible).  

That's the behavior I'm after, but am having trouble. I thought something like:

#+NAME: get-prop
#+BEGIN_SRC emacs-lisp :var prop="FOO" :noweb yes
(org-macro--get-property prop "")
#+END_SRC

#+NAME: inject_vars
#+BEGIN_SRC shell :noweb yes
# echo <> # testing
echo export FOO=<>
echo export BAR=<>
echo export BAZ=<>
#+END_SRC

#+BEGIN_SRC screen
<>
echo $FOO
#+END_SRC

might work, but it's just printing nil.


Thanks for any suggestions,

  -k.



Re: [off-topic] E-readers and Org-Mode

2022-10-25 Thread Ken Mankoff
See also Dasung NotEReader. Full Android tablet, no lockdown like the
ReMarkable. Looks fast - can watch YouTube videos for example. If it's
really full Android, then it should be able to install and run emacs
natively. 10.3 or 7.8 inch versions.

  -k.

Please excuse brevity. Sent from tiny pocket computer with non-haptic
feedback keyboard.

On Tue, Oct 25, 2022, 08:27 Fraga, Eric  wrote:

> On Tuesday, 25 Oct 2022 at 21:37, Max Nikulin wrote:
> > E-ink displays are slow (my device was manufactured 15 years ago but I
>
> We are venturing well into OT for this list... ;-)
>
> E-ink displays are getting significantly faster, with some claiming 60
> Hz refresh rates (cf. the PineNote).  Often, however, they are tied to
> low power and low performance processors given their use case: mostly
> reading with some annotations.
>
> --
> : Eric S Fraga, with org release_9.5.5-1028-gcd835d in Emacs 29.0.50
>


Re: [O] Plantuml w/ noweb and cached results

2022-09-23 Thread Ken Mankoff
Hi Ihor,

Thank you for your reply. I apologize for not doing a more thorough test with 
'-Q'. I'll try to find the problem in my setup.

  -k.

On 2022-09-22 at 22:02 -04, Ihor Radchenko  wrote:
> Ken Mankoff  writes:
>
>> #+BEGIN_SRC plantuml :noweb yes :file cache-yes.png
>> @startjson
>> <>
>> @endjson
>> #+END_SRC
>>
>> #+RESULTS:
>> [[file:cache-yes.png]]
>>
>> The above graphic is an error message. It states,
>>
>> "Your data does not sound like JSON data".
>
> I tried your example it is working just fine on my side.
> I suggest you to try reproducing starting from Emacs -Q.
> See https://orgmode.org/manual/Feedback.html. You may also find
> https://github.com/alphapapa/with-emacs.sh useful to install packages
> into a temporary clean Emacs instance.




[O] Plantuml w/ noweb and cached results

2022-09-21 Thread Ken Mankoff
Hello,

I'm not sure if this is a bug in ob-restclient, ob-plantuml, or Babel. If 
someone can help me figure out where, I can move this report to GitHub (if 
ob-restclient) - otherwise I think it remains here.

I cannot use ob-plantuml if results are cached. See example:

#+NAME: cache-no
#+BEGIN_SRC restclient :jq .[0].address :cache no

GET https://jsonplaceholder.typicode.com/users
#+END_SRC

#+RESULTS: cache-no
#+BEGIN_SRC js

{
  "street": "Kulas Light",
  "suite": "Apt. 556",
  "city": "Gwenborough",
  "zipcode": "92998-3874",
  "geo": {
"lat": "-37.3159",
"lng": "81.1496"
  }
}
#+END_SRC

#+BEGIN_SRC plantuml :noweb yes :file cache-no.png
@startjson
<>
@endjson
#+END_SRC


#+RESULTS:
[[file:cache-no.png]]

The above graphic is generated by plantuml.



#+NAME: cache-yes
#+BEGIN_SRC restclient :jq .[0].address :cache yes

GET https://jsonplaceholder.typicode.com/users
#+END_SRC

#+RESULTS[(2022-09-20 15:52:59) c41e0371fd392d6fbfd07ff4078abf8c387885ea]: 
cache-yes

#+BEGIN_SRC js
{
  "street": "Kulas Light",
  "suite": "Apt. 556",
  "city": "Gwenborough",
  "zipcode": "92998-3874",
  "geo": {
"lat": "-37.3159",
"lng": "81.1496"
  }
}
#+END_SRC

#+BEGIN_SRC plantuml :noweb yes :file cache-yes.png
@startjson
<>
@endjson
#+END_SRC

#+RESULTS:
[[file:cache-yes.png]]

The above graphic is an error message. It states,

"Your data does not sound like JSON data".

  -k.

n



Re: Org links and Flatpak firefox

2022-07-28 Thread Ken Mankoff
Hi Max,

Sorry for the delayed reply.

On 2022-07-05 at 08:16 -07, Max Nikulin  wrote:
> On 03/07/2022 20:25, Ken Mankoff wrote:
>> I had "browse-url-generic-program" set to a script that used xdotool
>> to find if there was a firefox on this desktop, and then sent the URL
>> there. xdotool doesn't play nice withe flatpak, and that was the
>> problem.
>
> I am not an X11 expert but it sounds strange. The protocol is designed
> to work across network, so it should not matter whether some
> application is running from flatpak. May it happen that after upgrade
> Wayland session is used instead of X11? Though in such case I would
> expect that xdotool should be rather broken due to stricter security
> model.

As you suggested, the problem was not xdotool or X11. It was simply that 
instead of calling

firefox "${1}" &

to open the URL, I needed to call

flatpak run org.mozilla.firefox "${1}" &

> Out of curiosity, what is the reason why you are avoiding firefox as a
> snap package?

I'm not 100 % sure why but I don't like snap. Maybe because it pollutes the 
home folder. I read up on snap vs flatpak vs AppImage and flatpak seemed to get 
the best reviews, so I've gone with that one.

  -k.



Re: Org links and Flatpak firefox

2022-07-03 Thread Ken Mankoff
Hi Max,

Thanks for the debugging suggestions. It helped me figure out that the problem 
was us usual human error.

Emacs opens URLs in the last-active (from the UI perspective) firefox, even if 
there is a firefox on the current virtual desktop. I had 
"browse-url-generic-program" set to a script that used xdotool to find if there 
was a firefox on this desktop, and then sent the URL there. xdotool doesn't 
play nice withe flatpak, and that was the problem.

Thanks again for the suggestions,

  -k.

On 2022-07-02 at 20:46 -07, Max Nikulin  wrote:
> On 02/07/2022 23:03, Ken Mankoff wrote:
>> I've just upgraded to Kubuntu 22.04. Firefox is no longer
>> instsallable via apt so I chose flatpak over snap. Now when I C-c
>> C-o (org-open-at-point) on a URL, Firefox comes to the foreground,
>> but nothing else happens. The page does not load. If I 'xdg-open
>> URL' then the URL loads, so the system outside of emacs does
>> interact correctly with the flatpak app.
>
> Please, seek for various messages reported during this action:
> - Emacs *Messages* buffer (C-h C-e)
> - Firefox console (Ctrl+Shift+J)
> - stderr of the Firefox process, unsure where it can be expected for
>   flatpak apps: terminal application from which Firefox was initially 
> started, output of "journalctl --user", in earlier days X11 errors may
> be saved to ~/.xsession-errors
> - flatpak may have its own log file.
>
> It is rather strange that Firefox receives some event, xdg-open works
> in isolation, but not from Emacs. What does happen when
> - `browse-url' is called from Emacs,
> - a link is activated in an Org document when Firefox application is closed?
>
> Notice that you did not specify which versions of Emacs and Org you
> have installed (M-x org-version), and the source of the package:
> bundled with emacs, elpa-org deb package, Emacs ELPA package, etc.




Org links and Flatpak firefox

2022-07-02 Thread Ken Mankoff
Hello,

I've just upgraded to Kubuntu 22.04. Firefox is no longer instsallable via
apt so I chose flatpak over snap. Now when I C-c C-o (org-open-at-point) on
a URL, Firefox comes to the foreground, but nothing else happens. The page
does not load. If I 'xdg-open URL' then the URL loads, so the system
outside of emacs does interact correctly with the flatpak app.

Can anyone advise how to get Org (or emacs) to play well with 3rd-party
flatpak'd apps?

/grumble - I get that these new installation methods are solving a
dependency problem, but it feels like a step backward. I can't
drag-and-drop images onto some apps, icons appear as generic X11 rather
than the app icon in the task switcher, etc. Oh well. I guess this is
progress.

Thanks,

  -k.


[O] Google Docs now supports MarkDown, but not Org syntax

2022-03-30 Thread Ken Mankoff


Google Docs now supports MarkDown, not Org syntax :(.

https://workspaceupdates.googleblog.com/2022/03/compose-with-markdown-in-google-docs-on.html

  -k.



Re: Custom TODO states for one item

2022-02-26 Thread Ken Mankoff
Hi Sam,

I only want one active state. I'd like the list of allowable and
short-cuttable states to be specific to one headline, different from the
file properties.

  -k.

Please excuse brevity. Sent from tiny pocket computer with non-haptic
feedback keyboard.

On Sat, Feb 26, 2022, 16:13 Samuel Wales  wrote:

> you can noly have one todo kw per heading that is meaningful to org.
> you can use tags.
>
> there are quasi-kw like archive and comment, however.
>
>
> On 2/26/22, Ken Mankoff  wrote:
> > Hello,
> >
> > I have a file with custom TODO states:
> >
> > #+TODO: FOO(f@/@) | BAR(b@/@)
> >
> > I have one item (heading) within that file that I'd like to have
> different
> > TODO states. Is this possible?
> >
> > Thanks,
> >
> >   -k.
> >
> >
> >
>
>
> --
> The Kafka Pandemic
>
> A blog about science, health, human rights, and misopathy:
> https://thekafkapandemic.blogspot.com
>


Custom TODO states for one item

2022-02-26 Thread Ken Mankoff
Hello,

I have a file with custom TODO states:

#+TODO: FOO(f@/@) | BAR(b@/@)

I have one item (heading) within that file that I'd like to have different TODO 
states. Is this possible?

Thanks,

  -k.




Re: ox-taskjuggler missing

2022-02-19 Thread Ken Mankoff
This might be an alternative option

https://plantuml.com/gantt-diagram

Please excuse brevity. Sent from tiny pocket computer with non-haptic
feedback keyboard.

On Sat, Feb 19, 2022, 18:18 Tim Cross  wrote:

>
> Greg Sullivan  writes:
>
> > Trying to export to taskjuggler (tj3) to get a gantt chart as in this
> description.
> > But I can't find the taskjuggler exporter.
> >
> > emacs-version
> > => GNU Emacs 27.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60
> Version 10.14.6 (Build 18G95)) of 2021-11-18
> >
> > org-version
> > => Org mode version 9.4.4 (release_9.4.4 @
> /Applications/Emacs.app/Contents/Resources/lisp/org/)
> >
> > (require 'ox-taskjuggler)
> > => Debugger entered--Lisp error: (file-missing "Cannot open load file"
> "No such file or directory" "ox-taskjuggler")
> >
> > There does not seem to be an "ox-taskjuggler" on melpa.
> >
> > I couldn't find any notes about taskjuggler export explicitly being
> removed from the standard org distribution.
> > Do others with emacs 27.2 and org-mode version 9.4.4 have ox-taskjuggler
> available?
> > If so, I must have messed up my installation.
> >
> > Thanks for any guidance.
> > -- Greg
>
>
> TaskJuggler is not part of org mode. It is one of the packages in the
> org contgrib package, which is now distributed via the nongnu elpa
> repository (see https://elpa.nongnu.org/nongnu/).
>
> I haven't used it in a long time and I don't think anyone is maintaining
> it, so don't know how well it is working with current org versions.
>
>
>
>


[O] How to add "days since" in heading

2022-02-16 Thread Ken Mankoff
Hello,

I'd like to have something like "diary-anniversary" but report "days since" a 
date, rather than "years since". For example, I have

> ** Birthdays
> %%(diary-anniversary 12 11 2010) Their %d%s birthday

And in my Agenda I then see:

> events: Their 21st birthday

I'd like to have something like this:

> ** Foo
> %%(diary-foo 2021-02-13) Bar [%d days]

And in my Agenda I then see:

> events: Bar [4 days]


That is, I would like to track how long since an event (in this case, how long 
a paper has been in review) without using SCHEDULING which makes things appear 
overdue if scheduled in the past.

Thanks,

  -k.



[O] Feature Request: org-log-schedule

2022-01-25 Thread Ken Mankoff
Hello,

I make use of

  (setq org-log-done 'note
org-log-reschedule 'note
org-log-delschedule 'note
org-log-redeadline 'note
org-log-deldeadline 'note
org-log-refile 'note)


But would like to also add a note when for org-log-schedule. I will add this to 
my todo list and implement it eventually and submit a patch, but post this here 
in case someone else gets to it first.

  -k.



Re: Preview fonts from Dired with org-latex-preview (and test opentype features)

2022-01-18 Thread Ken Mankoff
Please excuse brevity. Sent from tiny pocket computer with non-haptic
feedback keyboard.

On Mon, Jan 10, 2022, 08:53 Juan Manuel Macías 
wrote:

> Hi,
>
> I have written for my personal use this code (still quite crude) that
> allows me to preview with org-latex-preview small text strings in a font
> marked in dired, and test open type features too. The preview is
> compiled with LuaLaTeX, since LuaTeX allows to load fonts that are not
> installed in the system.
>
> When a font is selected, the list of opentype features included in the
> font are extracted (using the otfinfo command), and they are arranged in
> the preview buffer as buttons. By clicking on each button we can
> activate in the preview the corresponding opentype feature. For example,
> if the font includes the 'smcp' feature, clicking on the button 'smcp'
> the text will be displayed in small caps.
>
> We can enter the text strings literally or through Unicode code: each
> character separated by a space; the separation between words is marked
> with a vertical bar. For example, this code:
>
> 0063 006f 0064 0065 | 0068 0065 0072 0065
>
> returns the string "code here".
>
> As a third option, a complete specimen can be displayed from a file.
>
> Here is a demo video: https://cloud.disroot.org/s/aHXKiof36fTSZGB
>
> As I said, my function is still pretty crude, and while it works well,
> it's now more of a proof of concept than a finished thing. But if anyone
> wants to try it, I attach the code here in an org document.
>
> Best regards,
>
> Juan Manuel
>
>


Re: Question Regarding Creating Workflow For Automatic Formulas For Finance Based Org Spreadsheet

2022-01-09 Thread Ken Mankoff
Hi Sam,

Have you looked into Org Ledger?

  -k.

Please excuse brevity. Sent from tiny pocket computer with non-haptic
feedback keyboard.

On Sun, Jan 9, 2022, 09:18 Samuel Banya  wrote:

> Hey there,
>
> So I've been managing my finances via an org doc that basically has tables
> that list all the expenses from my bank account, which has been awesome on
> some respects.
>
> The only annoying thing I want to somehow figure out this year is how to
> make the process of updating the formula for a given month less tedious, so
> I am wondering if anyone could help me figure out a better workflow for
> doing this.
>
> *Here's My Current Workflow*
>
>- Download .csv from banking website
>- Convert .csv to .org file via file manager (with 'ranger' in 'vterm')
>- Change over to Dired Mode in the same directory and view the same
>.org file, and convert the data into an org table by using 'C-x h' to
>highlight everything, and use 'C-c |' to convert the range into an org 
> table
>- Open up the existing running total org mode spreadsheet in a
>separate buffer
>- Copy over the converted org mode table data from the new .csv buffer
>and paste it into the running org mode spreadsheet
>- Use 'C-c }' to show all formulas row and column values in the
>spreadsheet
>- Find the existing formula row line for the given month's totals at
>the bottom of the spreadsheet, and manually delete the values for the 3rd
>and 4th row respectively
>- Re-enter the formula manually for each cell and hit tab
>- Enter the same formulas on the next line to double check my work to
>make sure I entered them in correctly.
>
>
> *After Reading The Online Manual, I Figured This Out:*
>
>- I tried using the 'org-table-edit-formulas' function via the "C-c '
>(single quote)" (Obtained this formula via the docs, '
>
> https://www.gnu.org/software/emacs/manual/html_mono/org.html#Formula-syntax-for-Lisp
>')
>- I then accepted the mini buffer's changes with 'C-c C-c' which goes
>back to the spreadsheet.
>- I then hit 'C-c *' to update the tables present.
>- The problem with this is that when I attempt to do this function for
>each separate calculation row, both of the bottom calculation rows now only
>refer to a single formula for some reason.
>
>
> *For Reference, Here's A Modified Version Of My Running Finance
> Spreadsheet (Modified Without Actual Values Or Records For Personal
> Reasons) (NOTE: Sorry that the paste is terribly aligned --> I blame email
> formatting for this, also, note that I also put a note for myself as to
> what the formulas involved are for a given month since I can never remember
> the syntax personally since its flipped from typical Excel syntax of using
> row and column --> it uses column then row like an older calculator)*
>
>
> |+--+---+--|
> | 01/03/2022 | Example Rent Expense |   |
> -1061.67 |
> | 01/04/2022 | Example Food Expense |   |
> -1061.67 |
> | 02/05/2022 | Example Utility Expense  |   |
> -2061.67 |
> | 02/06/2022 | Example Random Expense   |   |
> -2061.67 |
>
> |+--+---+--|
> || EXPENSES JAN 2022 vsum(@1$3..@2$3) vsum(@1$4..@2$4)  | 0 |
> -2123.34 |
> || EXPENSES Feb 2022 vsum(@3$3..@4$3) vsum(@3$4..@4$4)  | 0 |
> -4123.34 |
>
> |+--+---+--|
>
> *Formulas Presented In the 3rd and 4th columns for Row 5:*
> # Column Formulas
> $3 = vsum(@1$3..@2$3)
> $4 = vsum(@1$4..@2$4)
>
> *Formulas Presented In The 3rd And 4th Columns For Row 6 (**NOTE**:
> Notice how I can't make them unique for each row for some reason):*
> # Column Formulas
> $3 = vsum(@1$3..@2$3)
> $4 = vsum(@1$4..@2$4)
>
> *Main Questions Regarding Formula Issues:*
>
>- Why can't I use individual row formulas in this scenario?
>- Why is it that when I use "C-c ' (single quote)" the row formulas
>are the same for completely separate rows
>
>
> *My Main Workflow Questions Include The Following:*
>
>- Is there a way I can maybe automate the initial steps of converting
>that .csv into an .org mode doc, and to paste them into the existing org
>spreadsheet?
>- Is there a way I can also update the existing formula for the given
>month if Emacs would somehow know the current date time stamp and figure
>out the month's row at the bottom of the spreadsheet accordingly to update
>the correct row?
>
>
> Anyway, I know my question might be a bit ambiguous and most likely will
> involve using 'F3' to record macros, but I figured i would ask to maybe
> make it easier since one of my goals for the new year is to make recording
> finances an easier process.
>
> I felt 

Re: Feedback on Emacs-Jupyter

2022-01-04 Thread Ken Mankoff
Hi Nathaniel,

First, thank you (many times) for maintaining emacs-jupyter. It is one of the 
most-used tools on my computer. I've been using your software daily for the 
past few years to develop code and write papers.

I may think of more things as others reply, but the one thing I can think of 
now is that I sometimes have issues inputting tables into Python code blocks. 
We discussed this back in 2020/2021 here: 
https://github.com/nnicandro/emacs-jupyter/issues/267 It is not emacs-jupyter 
according to you, but I mention it here anyway.


Another feature that could be nice - Org has the ability to embed/encode images 
into the document (see 
https://emacs.stackexchange.com/questions/27060/embed-image-as-base64-on-html-export-from-orgmode
 and  http://mbork.pl/2017-12-04_Embedding_files_in_Org-mode ). I do not 
suggest doing this for large graphics, but for small graphics, it could be 
interesting to have a "* Graphics" section at the bottom where the encoded 
graphics are stored, and then display those encoded graphics at the normal 
location (#+RESULTS: blocks below the code or elsewhere if #+NAME'd).

Implementing this feature would mean you could have self-contained / 
single-file / standalone Org files with graphics, similar to how .ipynb files 
contain graphics within. I'm not sure how useful this would be, but I throw it 
out there as a concept/idea.

Thanks again for the excellent software,

  -k.


On 2022-01-04 at 15:24 -08, Nathaniel Nicandro  
wrote:
> Hello all,
>
> I'm the maintainer of the emacs-jupyter project
> (https://github.com/nnicandro/emacs-jupyter) which essentially
> integrates Jupyter kernels (https://jupyter.org) with Org mode source
> blocks.
>
> I wanted to make an introduction to the Org community. So...hello! And
> thanks for promoting the project on https://orgmode.org/features.html.
>
> I believe a lot of users of the project use it mainly for the Org
> integration. I thought it would be a good idea to get some feedback
> from the community on how their experience using emacs-jupyter has
> been. I'm getting back into active maintenance of the project and am
> looking for feedback to get a better idea of what the future of the
> project could look like. What features of standard Org source blocks
> do you find Jupyter source blocks are lacking? What potential features
> do you think would be useful for Jupyter source blocks to support,
> given the capabilities of Jupyter? What would it mean to see
> Emacs-Jupyter and Org more integrated? Of course, any other thoughts
> are welcome.




Re: Org + git branches for derived files

2021-08-15 Thread Ken Mankoff
Hi All,

Thank you for the suggestions.

I think the most elegant solution is to have a hook on GitHub that compiles the 
PDF on a remote server. But it takes a lot more work, because I don't 
necessarily have *everything* in Git - my local 'library.bib' usually isn't 
included, nor my custom emacs config, latexmkrc, etc. 

I'd just like the compiled PDF easily readable by anyone, but I don't want 100s 
of historical copies.

There are a few solutions.

1) Maintain a branch with the 'no-history' files. When they need to be updated, 
commit and amend, then force-push. See 
https://stackoverflow.com/questions/22824922/git-commit-and-push-a-binary-file-but-dont-keep-history

2) Add the 'no-history' files to their own commit in the main branch. When they 
need to be updated, make a new commit and rebase/fixup from the previous 
commit. See 
https://stackoverflow.com/questions/12964145/how-to-config-git-to-overwrite-non-text-file-instead-of-version-controlled-it

  -k.




Org + git branches for derived files

2021-08-13 Thread Ken Mankoff
Hello,

I think this might be more of a git question than an Org question, but I 
imagine I might find the answer here and that it might be useful to others, so 
I ask here.

I'd like to keep derivative products (the LaTeX output, the final PDF, etc.) 
available in Git, but not commit those changes each time I change the Org file. 
Perhaps git-annex as appropriate for this, but seems over-kill.

Is there some way to mostly-seamlessly commit the LaTeX and/or PDF and/or other 
files to their own git branches but in a way that overwrites the history of 
that branch, so that a small Org file that generates a big binary PDF does not 
pollute the git tree?

Thanks,

  -k.



Calling code block from header in agenda

2021-06-17 Thread Ken Mankoff
Hello,

I'd like to `ctrl-c ctrl-c` on a TODO section header in the agenda and have a 
code block execute. Is this possible?

Outside the agenda I can CC on part of this header (the src_bash{date} part) 
and it evaluates. Elsewhere it asks for tags as usual.

** TODO foo src_bash{date}

In the agenda, it asks for tags regardless of where I CC.

I don't need the src_bash in the headline, but it seems like a security issue 
to have org-babel-execute-subtree invoked from the agenda. I figure someone 
could add src_elisp{(org-babel-execute-subtree)} to the headline if they need 
that.

  -k.



Re: Babel: Programmatically evaluate a heading and subtrees?

2021-03-01 Thread Ken Mankoff
Hi Nathan,

On 2021-02-20 at 11:10 -08, Nathan Neff  wrote...
> I have some code like this:
>
> * Heading 1
>
> # code block name:FOO
>
> ** Subheading 1
>
> # code block
>
> ** Subheading 2
>
> # code block
>
> I find that I often want to evaluate the code in Heading 1 and its
> subheadings.
>
> Currently, I navigate to Heading 1 and then use org-babel-execute-subtree
>
> I see that there's a function called org-babel-goto-named-src-block,
> so I think I could write a small function to jump to FOO in Heading 1
> and then run execute subtree and then jump back to my previous
> location in Emacs.
>
> Is there a more programmatic or built-in way? For example:
> org-babel-execute-block-and-subheadings FOO

What about,

(defun my/eval-parent-subtree()
  (save-excursion
(outline-up-heading 1)
(org-babel-execute-subtree)))

And then binding that to some key or something? Or (outline-up-heading 99) if 
you always want to go to "*". Or make that line a bit more dynamically 
controllable by use of 'prefix-arg' ?

  -k.



Re: ob-haskell

2021-01-03 Thread Ken Mankoff
Hi Lawrence,

This isn't a method for official language support, but I've had success with 
entirely unsupported REPLs and ob-screen. A .screenrc can launch the REPL, and 
then Org ob-screen just sends each line to the buffer. It works OK for me.

  -k.

On 2021-01-02 at 13:44 -08, Lawrence Bottorff  wrote...
> I recently wimped out of trying to update ob-haskell as an official
> maintainer, but I'd eventually like to get back to it -- *after *I get
> some base understanding of what Haskell is (Zeno's paradox-land?) and
> how the ghci works. Basically, the ghci is what it is -- tautological,
> but true. And that means when ob-haskell does nothing but dump the
> contents of a babel code block into ghci, it's no better than if the
> user had typed in into the REPL line-by-line. A quick run-down:
>
> :set +m supposedly alerts ghci that a multi-line expression is coming, will
> come; but typically, it doesn't infer this very well.
>
> Enclosing code in :{ ... :} is fairly good -- again you can type this in at
> the REPL prompt and see how it works -- however, there are gotchas.
>
> a plain block:
>
> #+begin_src haskell
> ...code...
> #+end_src
>
> is okay when you only have a one-liner to evaluate. But again, ob-haskell
> seems to do nothing but take the block contents and dump it to the ghci
> REPL as though the user had typed it in line-by-line, Enter, Enter...
>
> What would be nice is if a C-c C-c inside a block could somehow act as
> though the ghci were being sent a regular  *.hs buffer in haskell-mode --
> and that, of course, cumulatively. C-' creates a decent haskell-mode
> environment, BTW, so some form of a babel block to haskell-mode connection
> does exist
>
> So am I on the right track? It's obvious at this point raw dumps into the
> REPL aren't optimal, i.e., are fraught. What is, e.g., geiser doing
> that ob-haskell isn't?
>
> LB
>
> PS: Eventually, I'll try to glean some hints from the Jupyter Haskell
>  effort.
>
> PPS: GHCI User's Guide
> 
> doesn't
> really tell me anything other than yes, ob-haskell is raw-dumping into an
> environment that isn't designed to play nice with babel.




org-todo-yesterday with 1-day repeater tasks: repeats tomorrow

2020-12-14 Thread Ken Mankoff
Hello list,

I regularly use org-todo-yesterday or org-agenda-todo-yesterday. However, with 
a 1-day repeater task, or any ++ repeater, it sets the repetition using today 
as the starting point, not yesterday.

It seems like the repeater time and date-setter is not respecting 
"org-extend-today-until", which has this wonderful docstring:

"""IMPORTANT:  This is a feature whose implementation is and likely will
remain incomplete.  Really, it is only here because past midnight seems to
be the favorite working time of John Wiegley :-)"""

Are other experiencing this behavior? Is there some prefix arg I am missing 
that I should be using? I have not found other complaining about this behavior 
or reporting this issue, so I wonder if I'm missing something. If not, I'll 
work on submitting a patch.

Thanks,

  -k.



Re: Is there possibility to provide back links to each finely grained part of Org file?

2020-11-09 Thread Ken Mankoff


On 2020-11-09 at 03:38 -08, Eric S Fraga  wrote...
> On Sunday,  8 Nov 2020 at 23:40, Jean Louis wrote:
>> I know that #names exist in HTML export for *** headings. Do they or
>> can they exist for every paragraph or item listed?
>
> Maybe not quite what you want but you can place anchors (aka targets)
> anywhere you want in your document using <>. I use these
> for within-document linking but I imagine you can link to these from
> other documents as well (untested).

Also I imagine https://github.com/alphapapa/org-make-toc or 
https://github.com/snosov1/toc-org that already auto-make TOCs to every header 
could be hacked to add paragraph-level links?

  -k.




Re: Thoughts on the standardization of Org

2020-11-03 Thread Ken Mankoff
Hi Eric,

On 2020-11-03 at 05:00 -08, Eric S Fraga  wrote...
> The benefits of org mode for me are that it is Emacs. [...] I find it
> difficult to see any further standardization that would provide any
> real benefits *to me*. If others see those benefits, excellent! All
> power to them and I hope there is success in greater use of org
> documents outside Emacs which would possibly trickle back benefits
> into org mode in Emacs.

No need to apologize!

I'm similar to you re emacs usage and cannot imagine I'd leave it even if 
3rd-party implementations existed. There is no way that 3rd party tool would 
also read my email, have magit, implement all of Org that I use, edit TeX, etc.

But I'm weary of seeing all my colleagues say "Jupyter" and not "Org" when it 
comes to sharing their code/work. I have a fantasy that in 5 years I tell 
someone who doesn't use Emacs but uses Atom or some other editor to "pip 
install org-lsp" and then double-click on this Org file I just emailed you, and 
then right-click on the code block and select "evaluate" from the popup menu. 
That sounds horrific to me as a user, except the part where I can interact more 
powerfully with more colleagues.

In this fantasy this adds no additional effort or stress to the current devs, 
because we're a big diverse community, and if TEC doesn't want to work on Org 
core code, but does want to make an emacs-lsp or org-lsp, more power to them.

  -k.



Re: Thoughts on the standardization of Org

2020-11-03 Thread Ken Mankoff


On 2020-11-03 at 00:24 -08, David Rogers  wrote...
> I disagree (in principle, not just because it would be difficult) with
> the idea of “expanding beyond Emacs”. Org-mode benefits greatly from
> current and future Emacs development, and asking to standardize “just
> the parts that are not Emacs” would cause Org-mode to lose that huge
> advantage. Org-mode relies heavily on the editor it’s built on, and if
> it ceased to rely on Emacs, it would be forced to rely on “nothing at
> all” instead. Not only that, but for Org-mode users being able to
> count on all of Emacs is a big part of why it works. This means
> separating Org-mode from Emacs is a “lose-lose” idea.

It seems like you have never used Orgzly or read on Org file on GitHub. Those 
are not ideas, but are actual current real-world win-win implementations of 
parts of Org outside of Emacs.

More of these would be better.

Everyone on this thread who says you can't separate Org from Emacs is correct 
that it is unreasonable to expect a 100 % bit-compatible and 
keystroke-compatible experience outside of Emacs. I don't think that level of 
re-implementation was what the OP was suggesting.

Again: GitHub. Orgzly. The conversation should move from "it can't be done" or 
"it isn't helpful" (why so much negativity on this thread?) to

+ What parts can be standardized and re-implemented outside of Emacs.
+ How do we define graceful failure for the other parts.
+ How do we support 3rd-party implementation in a way that benefits all of us.

  -k.



Re: Thoughts on the standardization of Org

2020-11-01 Thread Ken Mankoff


To all who argue that Org is too tightly coupled to Emacs to consider working 
with it outside of Emacs, I point to GitHub. The fact that GitHub natively 
renders Org files "well enough" is a huge benefit to those of us who use Org. 
It is also useful for gaining new users (assuming more users is a good thing).

Therefore, if other tools have the ability to do *something* with an Org file 
(display most of it well enough, allow editing without breaking things, maybe 
implementing a simple Babel interpreter for a few popular languages, whatever), 
this would be A Good Thing.

For example, I'd contribute more to Stack Exchange sites if I could answer 
using Org syntax rather than Markdown syntax. None of these 3rd party 
implementations need to be comprehensive or perfect, just as the GitHub 
renderer is neither complete nor perfect. But we all benefit from the GitHub 
rendering.

  -k.




Re: New website - back to the old unicorn!

2020-10-28 Thread Ken Mankoff


On 2020-10-28 at 08:40 -07, Daniele Nicolodi  wrote...
> If I can bikeshed a bit more: I like the lighter page background that
> is currently on http://orgomode.org more than the darker one in the
> new version.

A few more minor comments based on the current version at 
https://orgmode.tecosaur.com/

1) Code block should use some coloring for header blocks and code body. The 
current theme highlights almost everything else but the header and code 
background.

2 and more important) Use the most popular language to get the most people 
interested. There are probably a lot more Python programmers than shell 
scripters. I suggest the code example should be a minimal (~6 lines?) of Python 
that produces either (or both) a simple graph or ~3 column table.

Also, I just noticed you can click on the sections (sections, babel header, 
results) to collapse them! :).

Which led me to an Org bug: The TODO Is 28 % complete, or 2/7, but 2/7*100 = 
28.5714285714, so I think it should be 29 % complete.

  -k.



Re: Please help by becoming a maintainer for an Org Babel file

2020-10-27 Thread Ken Mankoff


I'll help maintain ob-screen.el

  -k.


On 2020-10-26 at 01:07 -07, Bastien  wrote...
> Dear all,
>
> we are looking for more maintainers of individual Org Babel files.
>
> Jack and Ian are already in, I added myself to ob-clojure.el.
>
> If you feel like proposing yourself for maintaining an Org Babel
> language, that would be super helpful.
>
> Thanks a lot!




Re: official orgmode parser

2020-10-26 Thread Ken Mankoff


On 2020-10-26 at 14:00 -07, Tom Gillespie  wrote...
>> list ::= ('+' string newline)+ sublist?
>> sublist ::= (indent list)+
>>
>> I think this captures lists?
>
> Ah yes, I see my mistake here. In order for this to work the parser
> has to implement significant whitespace, so whitespace cannot be
> parsed into a single token. I think everything works out after that.

If we agree that the syntax above captures lists and sublists, then I think we 
could apply the same methods to the issue of headlines and sub-headlines?

  -k.



Re: official orgmode parser

2020-10-26 Thread Ken Mankoff


On 2020-10-26 at 10:59 -07, Tom Gillespie  wrote...
> You can identify headlines, but you can't identify nesting level;

Do you need to? This is valid as an entire Org file, I think:

*** foo
* bar
* baz

And that can be represented in EBNF. I'm not aware of places where behavior is 
indent-level specific, except inline tasks, and that edge case can be 
represented.

> There is a similar issue with the indentation level in
> order to correctly interpret plain lists.

list ::= ('+' string newline)+ sublist?
sublist ::= (indent list)+

I think this captures lists?

> Another example of something that requires a stack is the greater
> blocks, where you have #+begin_{name} and #+end_{name}, and the names
> must match.

Definitely not able to be represented in EBNF, unless as you say {name} is a 
limited vocabulary.

  -k.



Re: official orgmode parser

2020-10-26 Thread Ken Mankoff


On 2020-10-26 at 09:24 -07, Nicolas Goaziou  wrote...
> # This is a comment (1)
>
> #+begin_example
> # This is not a comment (2)
> #+end_example
>
> AFAICT, you cannot distinguish between lines (1) and (2) with EBNF.

I agree. I think this is a better (correct?) example than the footnotes on Org 
Syntax page.

  -k.




Re: official orgmode parser

2020-10-26 Thread Ken Mankoff

On 2020-10-26 at 07:21 -07, Nicolas Goaziou  wrote...
> Ken Mankoff  writes:
>
>> I question if this is possible because EBNF is for context-free
>> grammars, but I *think* Org syntax is context-free.
>
> It's not as explained in a footnote in the Org syntax document.

Yes, I meant to write that I think Org syntax is maybe *not* context-free, and 
therefore EBNF can't capture all of it. But it could still be very helpful and 
capture most of it.

But the more I think about it, the more I think Org may be context-free.

For the footnotes, I'm not sure that "(1) In particular, the parser requires 
stars at column 0 to be quoted by a comma when they do not define a headline" 
violates context. An "*" in the first column defines a header. It can be 
escaped by anything else too (" *" works too). If ",*" has a special meaning, 
that can be captured elsewhere in the syntax.

I'm also not sure (2) violates context-freeness, at least in the EBNF sense 
where a context can include a newline. See for example:

section ::= "*"+ string (tag+) newline (planning newline)? (property_drawer 
newline)?

planning ::= ("SCHEDULED:" "<" date_or_time ">")? ("DEADLINE:" "<" date_or_time 
">")?

property_drawer ::= ":PROPERTIES:" newline drawer_contents newline ":END:"

drawer_contents ::= ":" property ":" whitespace string

Where the first line, "section" is represented graphically as the attached 
image.

I guess I'm not 100% clear what "context-free" means. EBNF can represent a 
language where a for loop has an opening and closing brace. The closing brace 
is context-dependent, just as the planning or property drawers are.

I recently used EBNF to represent a CSV file with header, and I was unable to 
capture the requirement that the header column must have the same number of 
fields or commas as the data section. I think that is context-free. 



  -k.


Re: official orgmode parser

2020-10-26 Thread Ken Mankoff
Hello,

On 2020-09-23 at 01:09 -07, Bastien  wrote...
> I disagree that a parser is too difficult to maintain because Org is a
> moving target. Org core syntax is not moving anymore, a parser can
> reasonably target it. That's what is done with the Ruby parser, in use
> in this small project called github.com :)

Do you think it would be useful (or possible) to represent the current Org 
syntax in EBNF form so that people can use the EBNF to build parsers or 
graphically understand the form? I'm thinking of a nice page of railroad 
diagrams from this tool: https://github.com/GuntherRademacher/rr

I question if this is possible because EBNF is for context-free grammars, but I 
*think* Org syntax is context-free. Even if not, I think those railroad 
diagrams might be useful for parser-writers and can still describe 99 % of the 
syntax, even if a few extra sentences are needed to clarify some edge case.

  -k.



[O] babel bash :var tables - change from associative to index arrays

2020-09-12 Thread Ken Mankoff
Hi Org List,

I'd like to submit a patch so that all bash babel arrays are indexed. Are there 
cons to this that I'm not seeing? It might break some existing code that 
expects associative arrays. Could this be a breaking change that is included in 
Org 5.0? I'd like to check on the likely acceptance of such a patch before I 
take the time to code it.

Currently Org Babel uses associative arrays for multi-column bash :var inputs, 
and indexed arrays if single column. Put differently, for 1D tables the array 
is indexed [0,1,...,n] and for 2D arrays it is indexed using the first column. 
Example at the bottom of this email.

There are some drawbacks to this method: 1) It drops rows if the first column 
is not unique (I have tables where the first three columns make a unique index 
from "|year|month|day|value") and 2) associative arrays do not maintain order, 
so the code cannot rely on the order of the rows (see example below where 
"foo2,bar2" order is swapped).

If all arrays are indexed, these two issues would go away.

  -k.


#+NAME: tbl1D
| foo1  |
| bar1  |

#+NAME: tbl2D
| foo2  | 42 |
| bar2  | 24 |

#+NAME: print_tbl
#+BEGIN_SRC bash :var tbl=tbl1D
for key in "${!tbl[@]}"; do
  row=${tbl[$key]}
  echo $key $row
done
#+END_SRC

#+CALL: print_tbl(tbl=tbl1D)

#+RESULTS:
| 0 | foo1 |
| 1 | bar1 |

#+CALL: print_tbl(tbl=tbl2D)

#+RESULTS:
| bar2 | 24 |
| foo2 | 42 |



Re: Can you automatically noweb include?

2020-08-06 Thread Ken Mankoff
Actual example:


* Prologue test
:PROPERTIES:
:header-args:python+: :prologue "import numpy as np; import os"
:END:

#+BEGIN_SRC python :results output
print(np.__version__)
#+END_SRC

#+RESULTS:
: 1.18.4




On Wed, Aug 5, 2020 at 3:03 PM Ken Mankoff  wrote:

> What about using :pre or :prologue and setting it at the header or
> document level?
>
> Please excuse brevity. Sent from tiny pocket computer with
> non-haptic-feedback keyboard.
>
> On Wed, Aug 5, 2020, 14:22 George Mauer  wrote:
>
>> Use case:
>>
>> I'm using ob-racket <https://github.com/togakangaroo/ob-racket> but this
>> would apply just as well to a few other workflows I have with python or js.
>>
>> I would like to write a helper function in a src block and then
>> automatically have access to it in other src blocks further down the
>> document. I don't really want a stateful session (nor does ob-racket
>> support sessions) so I essentially want the equivalent of automatically
>> including it everywhere so I don't have to type it out all the time (and
>> have it screw up syntax coloring/indentation).
>>
>> Is this currently possible? Does anyone have any ideas for how to extend
>> things so it is?
>>
>


Re: Can you automatically noweb include?

2020-08-05 Thread Ken Mankoff
What about using :pre or :prologue and setting it at the header or document
level?

Please excuse brevity. Sent from tiny pocket computer with
non-haptic-feedback keyboard.

On Wed, Aug 5, 2020, 14:22 George Mauer  wrote:

> Use case:
>
> I'm using ob-racket  but this
> would apply just as well to a few other workflows I have with python or js.
>
> I would like to write a helper function in a src block and then
> automatically have access to it in other src blocks further down the
> document. I don't really want a stateful session (nor does ob-racket
> support sessions) so I essentially want the equivalent of automatically
> including it everywhere so I don't have to type it out all the time (and
> have it screw up syntax coloring/indentation).
>
> Is this currently possible? Does anyone have any ideas for how to extend
> things so it is?
>


Re: [PATCH] 3 improvements to ob-screen

2020-07-15 Thread Ken Mankoff


On 2020-07-15 at 20:12 -07, Kyle Meyer  wrote...
> Well, applied, but not pushed yet. In the second patch, the session
> name is no longer passed to string-match; it was in the original patch
> at . I'll fix it up
> locally before pushing.

Argh - I apologize for introducing that bug. Thank you for catching it and 
accepting the patches. I'll look at the tweaks you made to the commit messages 
to learn what is preferred for my next contribution.

  -k.



Re: [PATCH] 3 improvements to ob-screen

2020-07-15 Thread Ken Mankoff

On 2020-07-14 at 20:08 -07, Kyle Meyer  wrote...
> Could you add a changelog entry to the body of this commit message and
> the others?

I made the changes you requested. Updated patches attached.

  -k.

>From d7b7555969ce0e58653c5b5a78d9a4a0bebbacdf Mon Sep 17 00:00:00 2001
From: "Kenneth D. Mankoff" 
Date: Tue, 14 Jul 2020 13:29:36 -0700
Subject: [PATCH 1/3] ob-screen: Execute last line in block (send newline)

* lisp/ob-screen.el (org-babel-screen-session-write-temp-file): insert
newline after body.
---
 lisp/ob-screen.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index 75a2dc691..3edc2c265 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -108,6 +108,7 @@ In case you want to use a different screen than one selected by your $PATH")
   (let ((tmpfile (org-babel-temp-file "screen-")))
 (with-temp-file tmpfile
   (insert body)
+  (insert "\n")
 
   ;; org-babel has superfluous spaces
   (goto-char (point-min))
-- 
2.25.1

>From 05dcb2a9f9acb6d15c88ac67d9268243b620cf5e Mon Sep 17 00:00:00 2001
From: "Kenneth D. Mankoff" 
Date: Tue, 14 Jul 2020 13:41:35 -0700
Subject: [PATCH 2/3] ob-screen: Respect :session name. Don't prepend
 'org-babel-session-'

* lisp/ob-screen.el (org-babel-prep-session:screen): Remove concat of
"org-babel-session-" string onto session name when creating session.

* lisp/ob-screen.el (org-babel-screen-session-socketname): Remove
concat of "org-babel-session-" string onto session name searching for
existing screen session.
---
 etc/ORG-NEWS  | 7 +++
 lisp/ob-screen.el | 6 ++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index c366f61e0..623fa9dc3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -380,6 +380,13 @@ From ~org-enable-priority-commands~ to ~org-priority-enable-commands~.
 From ~org-show-priority~ to ~org-priority-show~.
 
 ** Miscellaneous
+*** =ob-screen.el=: Respect screen =:session= name
+
+Screen babel session are now named based on the =:session= header 
+argument (defaults to ~default~). 
+
+Previously all session names had  ~org-babel-session-~ prepended.
+
 *** Forward/backward paragraph functions in line with the rest of Emacs
 ~org-forward-paragraph~ and ~org-backward-paragraph~, bound to
 ~~ and ~~ functions mimic more closely behaviour of
diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index 3edc2c265..fe4698203 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -62,8 +62,7 @@ In case you want to use a different screen than one selected by your $PATH")
  (process-name (concat "org-babel: terminal (" session ")")))
 (apply 'start-process process-name "*Messages*"
terminal `("-T" ,(concat "org-babel: " session) "-e" ,org-babel-screen-location
-		  "-c" "/dev/null" "-mS" ,(concat "org-babel-session-" session)
-		  ,cmd))
+		  "-c" "/dev/null" "-mS" ,session ,cmd))
 ;; XXX: Is there a better way than the following?
 (while (not (org-babel-screen-session-socketname session))
   ;; wait until screen session is available before returning
@@ -97,8 +96,7 @@ In case you want to use a different screen than one selected by your $PATH")
 			 nil
 			 (mapcar
 			  (lambda (x)
-			(when (string-match
-   (concat "org-babel-session-" session) x)
+			(when (string-match x)
 			  x))
 			  sockets)
 (when match-socket (car (split-string match-socket)
-- 
2.25.1

>From d99c637f1cade54ab2f66b72ec32026a15aa03de Mon Sep 17 00:00:00 2001
From: "Kenneth D. Mankoff" 
Date: Tue, 14 Jul 2020 13:48:52 -0700
Subject: [PATCH 3/3] ob-screen: accept :screenrc header argument

* lisp/ob-screen.el (org-babel-default-header-args:screen): Add
default header argument `:screenrc' and value "/dev/null".

* lisp/ob-screen.el (org-babel-prep-session:screen): Use header
argument in variable `screenrc' and not hard-coded value.
---
 etc/ORG-NEWS  | 6 ++
 lisp/ob-screen.el | 6 --
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 623fa9dc3..5fb2af22e 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -229,6 +229,12 @@ directory configured for ClojureScript will /not/ work.
 Babel Java blocks recognize header argument =:cmdargs= and pass its
 value in call to =java=.
 
+*** =ob-screen.el=: Screen now accepts =:screenrc= header argument
+
+Screen blocks now recognize the =:screenrc= header argument and pass
+its value to the screen command via the "-c" option. The default
+remains =/dev/null= (i.e. a clean screen session)
+
 *** =RET= and =C-j= now obey ~electric-indent-mode~
 
 Since Emacs 24.4, ~electric-indent-mode~ is enabled by default.  In
diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index fe4698203..021fef60d 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -40,7 +40,8 @@
 In case you want to use a different screen than one selected by your $PATH")
 
 (defvar org-babel-default-header-args:screen
-  '((:results . 

[PATCH] 3 improvements to ob-screen

2020-07-14 Thread Ken Mankoff
Hello,

The attached three patches implement a bug fix, a simplification, and a new 
feature to ob-screen.

bug fix: 001 Execute last line in block (send newline)
simplify: 002 Don't add extra characters to session name
feature: 003 Accept :screenrc header argument

I've signed the FSF docs but do not see my name here: 
https://orgmode.org/worg/org-contribute.html under "Current contributors".

  -k.

>From cb014cd2da79b30967dd24fba37d7f75569ed92d Mon Sep 17 00:00:00 2001
From: "Kenneth D. Mankoff" 
Date: Tue, 14 Jul 2020 13:29:36 -0700
Subject: [PATCH 1/3] ob-screen: Execute last line in block (send newline)

---
 lisp/ob-screen.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index 75a2dc691..3edc2c265 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -108,6 +108,7 @@ In case you want to use a different screen than one selected by your $PATH")
   (let ((tmpfile (org-babel-temp-file "screen-")))
 (with-temp-file tmpfile
   (insert body)
+  (insert "\n")
 
   ;; org-babel has superfluous spaces
   (goto-char (point-min))
-- 
2.25.1

>From e6ee8bff913da35a0183f8e2c1db7021342492d9 Mon Sep 17 00:00:00 2001
From: "Kenneth D. Mankoff" 
Date: Tue, 14 Jul 2020 13:41:35 -0700
Subject: [PATCH 2/3] ob-screen: Respect :session name. Don't prepend
 'org-babel-session-'

---
 etc/ORG-NEWS  | 7 +++
 lisp/ob-screen.el | 6 ++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index c366f61e0..623fa9dc3 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -380,6 +380,13 @@ From ~org-enable-priority-commands~ to ~org-priority-enable-commands~.
 From ~org-show-priority~ to ~org-priority-show~.
 
 ** Miscellaneous
+*** =ob-screen.el=: Respect screen =:session= name
+
+Screen babel session are now named based on the =:session= header 
+argument (defaults to ~default~). 
+
+Previously all session names had  ~org-babel-session-~ prepended.
+
 *** Forward/backward paragraph functions in line with the rest of Emacs
 ~org-forward-paragraph~ and ~org-backward-paragraph~, bound to
 ~~ and ~~ functions mimic more closely behaviour of
diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index 3edc2c265..fe4698203 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -62,8 +62,7 @@ In case you want to use a different screen than one selected by your $PATH")
  (process-name (concat "org-babel: terminal (" session ")")))
 (apply 'start-process process-name "*Messages*"
terminal `("-T" ,(concat "org-babel: " session) "-e" ,org-babel-screen-location
-		  "-c" "/dev/null" "-mS" ,(concat "org-babel-session-" session)
-		  ,cmd))
+		  "-c" "/dev/null" "-mS" ,session ,cmd))
 ;; XXX: Is there a better way than the following?
 (while (not (org-babel-screen-session-socketname session))
   ;; wait until screen session is available before returning
@@ -97,8 +96,7 @@ In case you want to use a different screen than one selected by your $PATH")
 			 nil
 			 (mapcar
 			  (lambda (x)
-			(when (string-match
-   (concat "org-babel-session-" session) x)
+			(when (string-match x)
 			  x))
 			  sockets)
 (when match-socket (car (split-string match-socket)
-- 
2.25.1

>From 866f3c4788e58bf26dcf9c90cb7638f48a6a4ecc Mon Sep 17 00:00:00 2001
From: "Kenneth D. Mankoff" 
Date: Tue, 14 Jul 2020 13:48:52 -0700
Subject: [PATCH 3/3] ob-screen: accept :screenrc header argument

---
 etc/ORG-NEWS  | 6 ++
 lisp/ob-screen.el | 5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 623fa9dc3..5fb2af22e 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -229,6 +229,12 @@ directory configured for ClojureScript will /not/ work.
 Babel Java blocks recognize header argument =:cmdargs= and pass its
 value in call to =java=.
 
+*** =ob-screen.el=: Screen now accepts =:screenrc= header argument
+
+Screen blocks now recognize the =:screenrc= header argument and pass
+its value to the screen command via the "-c" option. The default
+remains =/dev/null= (i.e. a clean screen session)
+
 *** =RET= and =C-j= now obey ~electric-indent-mode~
 
 Since Emacs 24.4, ~electric-indent-mode~ is enabled by default.  In
diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index fe4698203..7115080f8 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -40,7 +40,7 @@
 In case you want to use a different screen than one selected by your $PATH")
 
 (defvar org-babel-default-header-args:screen
-  '((:results . "silent") (:session . "default") (:cmd . "sh") (:terminal . "xterm"))
+  '((:results . "silent") (:session . "default") (:cmd . "sh") (:terminal . "xterm") (:screenrc . "/dev/null"))
   "Default arguments to use when running screen source blocks.")
 
 (defun org-babel-execute:screen (body params)
@@ -59,10 +59,11 @@ In case you want to use a different screen than one selected by your $PATH")
   (let* ((session (cdr (assq :session 

patch: ob-screen support for user-specified screenrc [9.3.7 (9.3.7-12-g5d6868-elpaplus @ /home/kdm/.emacs.d/elpa/org-plus-contrib-20200706/)]

2020-07-09 Thread Ken Mankoff


Last ob-screen patch. I apologize if these should have been one email but they 
are there independent issues.

This patch maintains the default behavior of no screenrc "-c /dev/null", but 
adds a :screenrc header arg that allows the user to specify their default or 
any file to be used as a screenrc file.

  -k.


diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index 75a2dc691..3769a767d 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -29,6 +29,8 @@
 ;; Adding :cmd and :terminal as header arguments
 ;; :terminal must support the -T (title) and -e (command) parameter
 ;;
+;; Adding :screenrc as header arguments. Defaults to /dev/null.
+;;
 ;; You can test the default setup. (xterm + sh) with
 ;; M-x org-babel-screen-test RET
 
@@ -40,7 +42,7 @@
 In case you want to use a different screen than one selected by your $PATH")
 
 (defvar org-babel-default-header-args:screen
-  '((:results . "silent") (:session . "default") (:cmd . "sh") (:terminal . 
"xterm"))
+  '((:results . "silent") (:session . "default") (:cmd . "sh") (:terminal . 
"xterm") (:screenrc . "/dev/null"))
   "Default arguments to use when running screen source blocks.")
 
 (defun org-babel-execute:screen (body params)
@@ -59,10 +61,11 @@ In case you want to use a different screen than one 
selected by your $PATH")
   (let* ((session (cdr (assq :session params)))
  (cmd (cdr (assq :cmd params)))
  (terminal (cdr (assq :terminal params)))
+ (screenrc (cdr (assq :screenrc params)))
  (process-name (concat "org-babel: terminal (" session ")")))
 (apply 'start-process process-name "*Messages*"
terminal `("-T" ,(concat "org-babel: " session) "-e" 
,org-babel-screen-location
- "-c" "/dev/null" "-mS" ,(concat "org-babel-session-" 
session)
+ "-c" ,screenrc "-mS" ,(concat "org-babel-session-" 
session)
  ,cmd))
 ;; XXX: Is there a better way than the following?
 (while (not (org-babel-screen-session-socketname session))



patch: ob-screen: don't change user-specified session name [9.3.7 (9.3.7-12-g5d6868-elpaplus @ /home/kdm/.emacs.d/elpa/org-plus-contrib-20200706/)]

2020-07-09 Thread Ken Mankoff


ob-screen prepends "org-babel-session-" to the user-specific screen name for 
some reason. I suggest this is not necessary nor optimal. One of the key points 
of 'screen' is that you can detach and attach from elsewhere. The name of the 
session is an important part of this process, and changing the user-chosen name 
complicates this. I note that in the other babel :session names I use (shell, 
Python, jupyter-python, etc.) the :session name is not modified.

  -k.



diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index 75a2dc691..685961a7e 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -62,8 +62,7 @@ In case you want to use a different screen than one selected 
by your $PATH")
  (process-name (concat "org-babel: terminal (" session ")")))
 (apply 'start-process process-name "*Messages*"
terminal `("-T" ,(concat "org-babel: " session) "-e" 
,org-babel-screen-location
- "-c" "/dev/null" "-mS" ,(concat "org-babel-session-" 
session)
- ,cmd))
+ "-c" "/dev/null" "-mS" ,session ,cmd))
 ;; XXX: Is there a better way than the following?
 (while (not (org-babel-screen-session-socketname session))
   ;; wait until screen session is available before returning
@@ -97,8 +96,7 @@ In case you want to use a different screen than one selected 
by your $PATH")
 nil
 (mapcar
  (lambda (x)
-   (when (string-match
-  (concat "org-babel-session-" session) x)
+   (when (string-match session x)
  x))
  sockets)
 (when match-socket (car (split-string match-socket)



Patch: send 'return' after babel blocks sent to ob-screen [9.3.7 (9.3.7-12-g5d6868-elpaplus @ /home/kdm/.emacs.d/elpa/org-plus-contrib-20200706/)]

2020-07-09 Thread Ken Mankoff
Using ob-screen and this example:

#+begin_src screen
ls
#+end_src

The "ls" is transmitted to the screen session, but without a newline, it does 
not execute. The following patch adds a newline to all babel blocks sent to the 
screen session.

diff --git a/lisp/ob-screen.el b/lisp/ob-screen.el
index 75a2dc691..5616143fe 100644
--- a/lisp/ob-screen.el
+++ b/lisp/ob-screen.el
@@ -108,7 +108,7 @@ In case you want to use a different screen than one 
selected by your $PATH")
   (let ((tmpfile (org-babel-temp-file "screen-")))
 (with-temp-file tmpfile
   (insert body)
-
+  (insert "\n")
   ;; org-babel has superfluous spaces
   (goto-char (point-min))
   (delete-matching-lines "^ +$"))


Also, can anyone clarify why there is both

./contrib/lisp/org-screen.el
./lisp/ob-screen.el

?

Thanks,

  -k.



Bug: org-babel-ref-resolve does not find refs in a COMMENT'ed section [9.3.7 (9.3.7-elpaplus @ /home/kdm/.emacs.d/DEBUG/elpa/org-plus-contrib-20200602/)]

2020-06-05 Thread Ken Mankoff
Hello,

I think this is a recent change in behavior. I can no longer eval Babel blocks 
that expect table inputs via :var when they are in a section with a COMMENT 
status.



Here is an MWE org file:

=== BEGIN ===

* COMMENT Tables not found when section is commented

#+NAME: table
| foo |

(org-babel-ref-resolve "table")

=== END ===




When I try to eval (org-babel-ref-resolve "table"), Org reports:

org-babel-ref-resolve: Reference ‘table’ not found in this buffer

If I remove the "COMMENT" state on the heading, then the table is found.

I do not recall this happening in earlier versions of Org, but does now with 
the latest version from melpa.





Tested with /usr/bin/emacs -Q -l ~/.emacs.d/DEBUG.el ~/.emacs.d/DEBUG.org with 
DEBUG.org above and DEBUG.el containing:


(setq package-user-dir (expand-file-name "elpa" "~/.emacs.d/DEBUG"))
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/;) t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/;) t)
(package-initialize)
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(setq package-enable-at-startup nil)
(defvar use-package-verbose t)
(require 'use-package)
(setq use-package-always-ensure t)

(use-package org
  :ensure org-plus-contrib
  :config
  (setq org-confirm-babel-evaluate nil)
  (org-babel-do-load-languages
   'org-babel-load-languages
   '((shell . t


  -k.



Re: Help speeding up Org iCal export

2020-05-28 Thread Ken Mankoff
Hi Nicolas,

Thank you for providing suggestions about the appropriate tool. I've
profiled it, examined the variables you suggested, but am not sure what
next steps to take. I hope it is OK that I post questions about this on
this list...

On Thu, May 28, 2020 at 5:17 AM Nicolas Goaziou 
wrote:

> Ken Mankoff  writes:
>
> > When I eval `(org-icalendar-combine-agenda-files nil)`, it takes about
> > 15 seconds.
>
> OK. You may want to profile this, or use ELP.
>

Output from the profiler is here: https://pastebin.com/QvL9w69R but the key
lines seems to be:

  - org-icalendar-combine-agenda-files  15540  83%
   - apply  15540  83%
- org-icalendar--combine-files  15540  83%
 - mapconcat15536  83%
  - #   15536  83%
   - org-export-as  15162  81%
- org-export-data6493  34%
 - mapconcat 6493  34%
  - #6493  34%
   - org-export-data 6493  34%
- mapconcat  6164  33%
 - # 6160  33%
  - org-export-data  6156  33%
   - mapconcat   5674  30%

with org-export-data and mapconcat repeating, AND

- mapc   5672  30%
 - # 5672  30%
  - mapc 5672  30%
   - #   5668  30%
- #   4392  23%
 - org-id-find   4392  23%
  - org-id-update-id-locations
4376  23%
   - org-map-entries 3696  19%
- org-scan-tags  3668  19%
 + #990
  5%
 + #879
  4%
 + #830
  4%



> Some strange messages in the *Messages* buffer include:

> >
> > 22 files scanned, 7 files contains IDs and in total 23 IDs found.
>
> You may have set `org-icalendar-store-UID' somehow.
>

It is set to nil. I have only the *scratch* buffer open, and no other
buffers (although some where open earlier in this emacs session).


> > But my `org-agenda-files` variable only contains 12 files and no
> > #+INCLUDE statements.
>
> ID scanning is not limited to agenda files. Org also scans files known
> to contain ID. E.g., if, during the session, you insert an ID in
> "foo.org", later scans (in the same session) will include "foo.org".
>
> See `org-id-files' (internal variable), and `org-id-extra-files', which
> may contain even more files.
>

`org-id-files` contained a subset of my agenda files plus a few extra
(total: 7 files, and these 7 plus my agenda files do not sum to 22). When I
set it to nil, nothing significant changed, but it was reset after running
`org-icalendar-combine-agenda-files` again.

`org-id-extra-files` was set to org-agenda-text-search-extra-files. When I
set it to nil, nothing significant changed. It does not get reset when
`org-icalendar-combine-agenda-files` is run.

  -k.


[O] Help speeding up Org iCal export

2020-05-27 Thread Ken Mankoff
Hello,

When I eval `(org-icalendar-combine-agenda-files nil)`, it takes about 15 
seconds.

Some strange messages in the *Messages* buffer include:

22 files scanned, 7 files contains IDs and in total 23 IDs found.

But my `org-agenda-files` variable only contains 12 files and no #+INCLUDE 
statements.

There are also several dozen lines of

org-babel-exp process sh at position 74770...
org-babel-exp process sh at position 74830...
org-babel-exp process sh at position 75147...
...
org-babel-exp process sqlite at position 27700...
org-babel-exp process sqlite at position 27704...
org-babel-exp process sh at position 27604...
org-babel-exp process sh at position 27617...
org-babel-exp process sh at position 27691...
org-babel-exp process translate at position 27970...

(and with bash, python, emacs-lisp, and other languages). When I view for 
example the only #BEGIN_SRC translate block in any of my files it is just a 
test in my notes file:

#+BEGIN_SRC translate :src en :dest da
This is a test
#+END_SRC

I cannot eval it with C-c C-c because I have set ":eval no" system-wide with:

  (setq org-babel-default-header-args
(cons '(:eval . "no")
  (assq-delete-all :eval org-babel-default-header-args)))


Sometimes the Messages contain confirmation that a code block is disabled:

org-babel-exp process plantuml at position 27719...
Evaluation of this plantuml code block is disabled.
org-babel-exp process plantuml at position 27762...
Evaluation of this plantuml code block is disabled.


But those blocks don't have any special header:

#+begin_src plantuml :file tryout.png
...misc plantuml code here.
#+end_src


Can anyone offer suggestions why it reports scanning 22 files, and how to speed 
it up since no code should be evaluated?

Thank you,

  -k.



Re: issue tracker?

2020-05-22 Thread Ken Mankoff
On Wed, May 20, 2020 at 7:36 PM Anthony Carrico 
wrote:

> Given that the mailing list holds the issues, it would be nice if you
> could import the mailing list into your client as a lump (maildir/mbox).
> Currently you can only download it chunk by chunk, so it isn't really
> practical for a newcomer to import the whole list to do research a new
> issue before reporting it.
>

You can import it. See recent announcement to this list:
https://lists.gnu.org/archive/html/emacs-orgmode/2020-04/msg00020.html

  -k.


[O] (no)export of special blocks

2020-05-07 Thread Ken Mankoff
Hello,

I'd like to be able to optionally export/not-export a specific paragraph within 
a section, based on a top-level property. Is this possible in Org? I know I can 
toggle export of code blocks, but what about text blocks?

More specifically, I'm writing a journal article and I would like to have 
figures in the text where I think they should be:

[[./fig/foo.png]]
#+CAPTION: foo

But the journal wants the figures at the end of the document.

I'd like to replicate the "[[./fig/foo.png]]", once inline and once at the end. 
I'd then like to be able to wrap this in a #+BEGIN_SOMETHING and toggle that 
with a property to export or not. E.g:

#+BEGIN_something :export (org-macro--get-property "results-y-or-n" "")
[[./fig/foo.png]]
#+CAPTION: foo
#+END_something


I recognize that if the figure is generated from a code block I can achieve my 
desired behavior. The code can have ":exports results" set to ":exports 
(org-macro--get-property "results-y-or-n" "")", and elsewhere

:PROPERTIES:
:results-y-or-n: nil
:END:

But there are a few problems with this:

1) org-macro--get-property works for header level properties in :PROPERTIES: 
drawers, but not top level #+PROPERTY: items.

2) Not all my figures are generated from code blocks

Thanks,

  -k.



Re: Overleaf equivalent for org-babel users?

2020-04-18 Thread Ken Mankoff
I've looked a bit more into what Joseph linked to. What about using Org
locally on your computer, and sharing an http://markup.rocks + DropBox
access to your Org files for non-emacs collaborators?

If CoCalc provides something you need that you don't have locally, you
could combine CoCalc + Markup.Rocks. I heard (and CoCalc repeats) here
https://doc.cocalc.com/howto/external-tools.html that DropBox won't work on
certain linux filesystems, but I have never run into this issue yet, so it
may work.

On Sat, Apr 18, 2020 at 8:17 AM Prof. Dr. Johanna May <
johanna@th-koeln.de> wrote:

> Dear Ken,
>
> thank you very much. I'm looking into cocalc now. I already got it to
> compile some test.org file as pdf. I also set up a test file there in
> order to start finding out how to do this. Next step, I guess, would be
> to see, if org-babel works. Unfortunately, it looks like
> a bit more work since for collaboration I need to find out about
> versioning and testing the stuff and also about how to get some very
> simple interface working there, maybe for small edits github is
> nicer. But I have to admit, my experience on tramp (what is that?) and
> git is very limited, so I don't yet have an idea of how to set that up
> in a good way.
>
> Jupyter Notebooks are not what I feel is right for lecture notes in that
> subject since they cannot display circuitikz and latex export is not the
> way it should be. It's not a programming class I'm teaching and many
> students do prefer the pdf they can either print out or annotate in some
> software on their tablets or just display on their smartphone. The exam
> is in writing and on paper.
>
> I do also provide some jupyter notebooks, but only for the interested
> part of the class and they surely can manage without that. As always,
> such options are rather taken up by the more skilled, and not so much by
> the weaker students, unfortunately.
>
> Cheers, have a good weekend!
>
> J
>
> Am Samstag, 18. April 2020 um 15:59 schrieb Ken Mankoff ...
> > Hi Dr. May,
> >
> > Unfortunately I have not found Emacs + Org to be the right tools when
> collaborating. What we need is a way for Org wrap/interface/edit Jupyter
> Notebooks, since that seems to be becoming the standard. Unfortunately.
> >
> > I have had some luck with a hybrid approach using the Sage Notebook
> server. That project is no longer active (perhaps due to the success of
> Jupyter Notebooks?), but I think you can do something similar with either
> Google Colab https://colab.research.google.com or more likely CoCalc
> https://cocalc.com/
> >
> > Google Collab is just an interface to Jupyter Notebooks.
> >
> > CoCalc can also just run Jupyter Notebooks, but also lets you have a
> full Linux environment, bash shell, ssh, git, etc. I think you may need to
> pay for this level of service, but you could then run emacs remotely via
> ssh, or locally and use tramp. If the backend is git you may be able to
> work locally and sync with the webserver interface to the tools that your
> colleagues would see.
> >
> > I still don't think your colleagues would be directly editing your Org
> source though, but you may be able to get close to what you're looking for
> on those sites. Good luck, and please do post back here if you come up with
> a good solution.
> >
> >   -k.
> >
> > On 2020-04-16 at 10:22 -07, Prof. Dr. Johanna May
> >  wrote...
> >> Hey there,
> >>
> >> I've been preparing lecture notes with org-mode and lualatex export
> >> that include python diagrams and so on for about more than a year. Now
> >> my colleagues and team start to get interested in tweaking the
> >> results. Therefore, we would need some kind of online collaboration
> >> solution similar to overleaf that can compile the latex including the
> >> python (org-babel) inserts. And, obviously, versioning would also come
> >> in handy, so that would rather be github / gitlab functionality.
> >>
> >> Does anyone know of a solution like overleaf that can be used for
> >> that? Could you point me at your description of any setup needed? Or,
> >> alternatively, do you have some good description of how to set up a
> >> server / virtual machine that can do that? (at best including a
> >> virtual emacs interface, so not all users have to do all the
> >> installations locally)? If so, that description would also interest
> >> me.
> >>
> >> I would like to either use some online platform like overleaf or
> >> explain to my university colleagues who already have servers running
> >> what they could do for me.
> >>
> >> 

Re: Overleaf equivalent for org-babel users?

2020-04-18 Thread Ken Mankoff
Hi Dr. May,

Unfortunately I have not found Emacs + Org to be the right tools when 
collaborating. What we need is a way for Org wrap/interface/edit Jupyter 
Notebooks, since that seems to be becoming the standard. Unfortunately.

I have had some luck with a hybrid approach using the Sage Notebook server. 
That project is no longer active (perhaps due to the success of Jupyter 
Notebooks?), but I think you can do something similar with either Google Colab 
https://colab.research.google.com or more likely CoCalc https://cocalc.com/

Google Collab is just an interface to Jupyter Notebooks.

CoCalc can also just run Jupyter Notebooks, but also lets you have a full Linux 
environment, bash shell, ssh, git, etc. I think you may need to pay for this 
level of service, but you could then run emacs remotely via ssh, or locally and 
use tramp. If the backend is git you may be able to work locally and sync with 
the webserver interface to the tools that your colleagues would see.

I still don't think your colleagues would be directly editing your Org source 
though, but you may be able to get close to what you're looking for on those 
sites. Good luck, and please do post back here if you come up with a good 
solution.

  -k.

On 2020-04-16 at 10:22 -07, Prof. Dr. Johanna May
 wrote...
> Hey there,
>
> I've been preparing lecture notes with org-mode and lualatex export
> that include python diagrams and so on for about more than a year. Now
> my colleagues and team start to get interested in tweaking the
> results. Therefore, we would need some kind of online collaboration
> solution similar to overleaf that can compile the latex including the
> python (org-babel) inserts. And, obviously, versioning would also come
> in handy, so that would rather be github / gitlab functionality.
>
> Does anyone know of a solution like overleaf that can be used for
> that? Could you point me at your description of any setup needed? Or,
> alternatively, do you have some good description of how to set up a
> server / virtual machine that can do that? (at best including a
> virtual emacs interface, so not all users have to do all the
> installations locally)? If so, that description would also interest
> me.
>
> I would like to either use some online platform like overleaf or
> explain to my university colleagues who already have servers running
> what they could do for me.
>
> The problem is, that the collaboration colleagues are not good friends
> with coding (they prefer word to latex, excel to python ... until now,
> at least), so I'm not very inclined to suggest them to start using
> emacs. I would very much prefer some web-based solution to get them
> started. Also, such a solution might provide ways of having students
> contribute smaller bits and pieces without having to go thru the whole
> learning curve of learning the use of emacs, installing all the tools,
> etc.pp. Any ideas?
>
> Thank you very much!
>
> Cheers,
>
> J. May




Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block

2020-03-31 Thread Ken Mankoff
Yes I'm sure. From the link Thomas sent,

Any property specification, unless it is postfixed with a `+`, will *reset*
the value of that property to its current value.

C-c C-v  (for me, Charles uses C-c C-v C-i) withitn a code block shows
you the header args that are set for that block. Useful for debugging.

  -k.

On Mon, Mar 30, 2020 at 3:24 PM Joost Kremers 
wrote:

>
> On Mon, Mar 30 2020, Ken Mankoff wrote:
> > Header args overwrite. Change python to python+ to append header
> > args.
>
> Are you sure? That's not documented anywhere I can find and it
> seems to be belied by the fact that if I put the headers in the
> order:
>
> ```
> :PROPERTIES:
> :header-args:python: :tangle out1.py
> :header-args:python: :session py1 :results function
> :END:
> ```
>
> everything works as I would expect (the code blocks are tangled to
> a file `out1.py` *and* they are evaluated in a python session
> `py1`), meaning that *all* header args are picked up.
>
> If I reverse the order and add a `+` sign, like so:
>
> ```
> :PROPERTIES:
> :header-args:python+: :session py1 :results function
> :header-args:python+: :tangle out1.py
> :END:
> ```
>
> the code does indeed get tangled, but the `:results` header arg
> isn't picked up, because the code block doesn't produce any
> output.
>
> For reference, this is my test file:
>
> ```
> * Header 1
> :PROPERTIES:
> :header-args:python+: :session py1 :results function
> :header-args:python+: :tangle out1.py
> :END:
>
> #+begin_src python
> a=1
> b=2
> c=a+b
> return c
> #+end_src
>
> #+RESULTS:
> ```
>
>
> --
> Joost Kremers
> Life has its moments
>


Re: :tangle header argument not picked up in #+PROPERTY line or :PROPERTIES: block

2020-03-29 Thread Ken Mankoff
Header args overwrite. Change python to python+ to append header args.

Please excuse brevity. Sent from tiny pocket computer with non-haptic
feedback keyboard.

On Sun, Mar 29, 2020, 15:42 Joost Kremers  wrote:

>
> On Mon, Mar 30 2020, Joost Kremers wrote:
> > Looks like a bug, right?
>
> And while I'm at it, this doesn't work as expected either:
>
> ```
> #+PROPERTY: header-args :dir /home/joost/tmp/dlpy/
>
> * Header 1
> :PROPERTIES:
> :header-args:python: :tangle out1.py
> :header-args:python: :session py1 :results function
> :END:
>
> #+begin_src python
> a=1
> b=2
> c=a+b
> return c
> #+end_src
> ```
>
> I would expect that the file `out1.py` is created in the directory
> `/home/joost/tmp/dlpy`, but it's created in the same directory as
> the Org file.
>
> Are my expectations wrong or is this really a bug?
>
>
> --
> Joost Kremers
> Life has its moments
>
>


Re: Strange Org <> OS interaction w/ bad ID

2020-02-24 Thread Ken Mankoff
On Mon, Feb 24, 2020 at 10:51 AM Nicolas Goaziou 
wrote:

> > Does anyone know why Org is parsing files in random folders when
> > I have a bad ID and a <>?
>
> I don't. You may want to check `org-id-files', or walk the hash table
> `org-id-locations'.
>

(apropos "org-id-files") returns nil, which is strange because it seems to
be in Org for the past 11 years
https://github.com/bzg/org-mode/blame/a3da64ad574e6ba860ea03c1bf6af91f279d86ee/lisp/org-id.el#L216

Same with org-id-locations.

With `emacs -Q` and nothing else, should these be set?

  -k.


[O] Strange Org <> OS interaction w/ bad ID

2020-02-24 Thread Ken Mankoff
Hi Org List,

This is cross-posted here: 
https://www.reddit.com/r/emacs/comments/f8t50q/help_debugging_org_os_interaction/

I've run into a strange bug. This is reproducible on my machine with "emacs 
-Q", but not with with emacs-sandbox 
https://github.com/alphapapa/emacs-sandbox.sh/ so I don't know if you'll be 
able to recreate this...

Problem: When exporting an Org file that contains 1) <> refs and 2) 
id:link links to CUSTOM_ID, then Org parses files all over my filesystem. Given 
that this happens with "emacs -Q", I don't know why it would be opening files 
in random folders!

The MWE Org file that I'm opening and exporting is:

=== BEGIN ===

#+BEGIN_SRC emacs-lisp :results value :noweb yes :eval no-export
<>
#+END_SRC

#+NAME: bar
#+BEGIN_SRC emacs-lisp :results value :noweb yes :eval no-export
(org-version)
#+END_SRC

* Bug: Export with IDs and links
:PROPERTIES:
:CUSTOM_ID: foo
:END:

+ Link to id:foo

=== END ===

The file is eventually exported correctly and the link works. I think I found 
the bug - when I run org-lint, I am told

> 18 high  Unknown ID "foo"

And when I change "CUSTOM_ID" to "ID", then everything works. No bug. No random 
files parsed. With CUSTOM_ID I can see it parse files throughout my filesystem 
(how does it find them??) because I get this error message about 10x:

> The local variables in /path/to/folder
> contains values that may not be safe (*).
>
> Do you want to apply it? You can type
> [snip]
> 
> * eval: (pyvenv-activate "/path/to/anaconda/envs/env")

The bug needs both the id: link to CUSTOM_ID *and* the <> ref. If I 
comment out the <> ref, then the bug does not appear.

I thought named IDs were supposed to go into CUSTOM_ID properties rather than 
ID properties. Is this incorrect?

Does anyone know why Org is parsing files in random folders when I have a bad 
ID and a <>?

Thanks,

 -k.




Building MWE DEBUG.org template file

2020-02-23 Thread Ken Mankoff
Hello,

I'm trying to build a DEBUG.org that makes it easy to share MWEs of bugs I run 
across in Emacs packages. I'd like it to load the latest Org mode by default. 
Then for any given bug I load the needed packages, configure them, and 
demonstrate the bug.

Right now when I run the attached file, the first time I run it everything 
appears to work correctly. It installs Org from melpa into a temporary elpa 
folder, and the output of

#+BEGIN_SRC emacs-lisp :results value :noweb yes
<>
<>
(org-version nil t)
#+END_SRC

is:

#+RESULTS:
: Org mode version 9.3.6 (9.3.6-4-gdfa7a3-elpaplus @ 
/home/kdm/.emacs.d/DEBUG/elpa/org-plus-contrib-20200217/)

But when I load the file a second time in a clean emacs session (i.e. 
/usr/bin/emacs -Q ~/.emacs.d/DEBUG.org & ), then the Org version is incorrect, 
and I see:

#+RESULTS:
: Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ 
/home/kdm/.emacs.d/DEBUG/elpa/org-plus-contrib-20200217/)


Can anyone explain what I'm doing incorrectly in the attached file?

Thanks,

  -k.


Run this debug Org file in a clean emacs session with:

/usr/bin/emacs -Q ~/.emacs.d/DEBUG.org & 

Initialize Emacs to reproduce this bug. Press `C-c C-c` in the Org Babel block below.

#+BEGIN_SRC emacs-lisp :results value :noweb yes
<>
<>
(org-version nil t)
#+END_SRC

#+RESULTS:
: Org mode version 9.3.6 (9.3.6-4-gdfa7a3-elpaplus @ /home/kdm/.emacs.d/DEBUG/elpa/org-plus-contrib-20200217/)

* Bug
** COMMENT Example Bug

Put example code here for this bug.

#+BEGIN_SRC emacs-lisp :results value
(defmacro measure-time ( body)
  "Measure the time it takes to evaluate BODY."
  `(let ((time (current-time)))
 ,@body
 (message "%.06f" (float-time (time-since time)

(measure-time (message "hello, world"))
#+END_SRC

#+RESULTS:
: 0.000134


* Init
** Emacs

#+NAME: init_emacs
#+BEGIN_SRC emacs-lisp :results none
(setq package-user-dir (expand-file-name "elpa" "~/.emacs.d/DEBUG"))

(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/;) t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/;) t)

(package-initialize)
;; Bootstrap `use-package'
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(setq package-enable-at-startup nil)

(defvar use-package-verbose t)
(require 'use-package)
(setq use-package-always-ensure t)
;(setq use-package-always-defer t)
;; (require 'diminish);; if you use :diminish
;; (require 'bind-key)   
#+END_SRC

** Org

#+NAME: init_org
#+BEGIN_SRC emacs-lisp :results none
(use-package org
  :ensure org-plus-contrib)
(setq org-confirm-babel-evaluate nil) ;; don't ask to eval code
(org-babel-do-load-languages
 'org-babel-load-languages
 '((emacs-lisp . t)   
   (shell . t)))
#+END_SRC





Re: Automatic LaTeX preview toggling

2020-02-18 Thread Ken Mankoff
Recent melpa package does this:
https://github.com/io12/org-fragtog

  -k.


Please excuse brevity. Sent from tiny pocket computer with non-haptic
feedback keyboard.

On Thu, Feb 13, 2020, 21:20 Ag Ibragimov  wrote:

>
> I just recently discovered that this excellent code snippet that I found
> long time ago here:
> http://slumpy.org/blog/2017-02-01-automatic-latex-preview-in-org-mode
>
> which is based on even older post originally written by John Kitchin:
>
>
> http://kitchingroup.cheme.cmu.edu/blog/2015/10/09/Automatic-latex-image-toggling-when-cursor-is-on-a-fragment/
>
> unfortunately stopped working. I guess I missed it, at some point it seems
> org--list-latex-overlays function was removed.
>
> Does anyone know if there's updated version of this thing somewhere? Or
> maybe this was extracted into some plugin or something that can be
> installed from MELPA maybe and I don't even know?
>
>


Re: How to set time limit and memory limit for execution of source blocks

2020-02-09 Thread Ken Mankoff
On 2020-02-03 at 22:40 -08, Anoop GR  wrote...
> How do I enforce the same on my orgmode source blocks. I want the
> execution to stop whenever it exceeds the above limits on memory and
> time.

There are several packages that implement :async source blocks via the :async 
header arg. It seems like one of these could be fairly easy to adapt to monitor 
the process it spawns.

  -k.




Re: Properties Drawer versus tags

2019-12-20 Thread Ken Mankoff


On 2019-12-19 at 22:24 -08, Lawrence Bottorff 
wrote...
> Very simple, largely philosophical question: When/why use a properties
> drawer below a heading versus just using tags on the heading? What are
> the advantages, disadvantages of both?

Tags are binary. They are there or not.

Property drawers allow you to assign values to variables.

I've never fully understood why some property drawers are set to binary. For 
controlling LaTeX export I have both a property ":clearpage: t" and a tag 
":ignore:", and the tag makes more sense to me. Some of those may only exist in 
my personal config.

  -k.



Re: noweb multiple block together

2019-11-25 Thread Ken Mankoff
Hi Sebastian,

On 2019-11-24 at 22:24 -08, Sebastian Miele  wrote...
> there is the possibility to give a common name to multiple blocks via
> the header arg :noweb-ref. That works in the way you looking for.

Yes this does what I want. I once knew but then forgot about this. Thank you 
for reminding me.

  -k.




noweb multiple block together

2019-11-24 Thread Ken Mankoff
Hello,

When tangling blocks, I can tangle multiple blocks by setting a (sub)-tree 
level property, or ":tangle foo" in multiple headers. Is there a way to achieve 
the same thing with noweb?

I've tried giving multiple blocks the same "+name:" and then <>, but only 
one seems to be included. Does this feature exist through some mechanism?

Thanks,

  -k.



Re: Using Org and eev together - problem with source blocks

2019-11-10 Thread Ken Mankoff


On 2019-11-10 at 15:36 +01, Eduardo Ochs  wrote...
> Changing the Python source block to
>
> #+BEGIN_SRC python :output results
>
> Are you sure that you wrote it correctly?

I'm pretty sure I did not. Try ":results output"

  -k.




Re: Using Org and eev together - problem with source blocks

2019-11-10 Thread Ken Mankoff


On 2019-11-10 at 02:54 +01, Eduardo Ochs  wrote...
> #+BEGIN_SRC python
> def square (x):
> return x*x
>
> print(square(5))
> #+END_SRC
>
> [...] when I run the Python block with C-c C-c I always get a results
> block like this (without the indentation):
>
>   #+RESULTS:
>   : None
>
> What am I doing wrong? I expected an output of "25"... =(

Adding ":output results" makes this work for me, but I'm not using emacs24.

  -k.



Re: where to place caption so babel results include caption?

2019-11-09 Thread Ken Mankoff


On 2019-11-06 at 17:53 +01, Ken Mankoff  wrote...
> On 2019-11-06 at 17:05 +01, Berry, Charles  wrote...
>> M-: (org-babel-map-src-blocks nil (org-babel-insert-result ""
>> '("replace"))) RET

An improvement: Don't insert #+results: if they don't already exist:

(org-babel-map-src-blocks nil
(if (org-babel-where-is-src-block-result)
(org-babel-insert-result "" '("replace"

  -k.



Re: where to place caption so babel results include caption?

2019-11-06 Thread Ken Mankoff


On 2019-11-06 at 17:05 +01, Berry, Charles  wrote...
> M-: (org-babel-map-src-blocks nil (org-babel-insert-result ""
> '("replace"))) RET
>
> HTH,

Yes that helps! A simple solution. Thank you.

  -k.



[O] where to place caption so babel results include caption?

2019-11-06 Thread Ken Mankoff
Hello,

If I have a babel block that generates a table and I'd like latex attributes 
associated with that table, it seems to work well if I do this:

#+NAME: foo
#+BEGIN_SRC bash :results table
echo "${RANDOM}|${RANDOM}|"
echo "${RANDOM}|${RANDOM}|"
#+END_SRC

#+caption: foo
#+latex_attr: :placement [!h]
#+RESULTS: foo
| 17326 | 29919 |
| 30565 |  9548 |


And I can re-run the babel block and CAPTION and ATTR_LATEX remain.

But if I want to clean with =[C-u] C-c C-v k= or 
(org-babel-remove-result-one-or-many) and regenerate =C-c C-v C-b= or 
(org-babel-execute-buffer), then this happens:


#+RESULTS: foo
| 17225 | 29253 |
| 18433 | 27388 |

#+caption: foo
#+latex_attr: :placement [!h]

If I place CAPTION and LATEX_ATTR above the babel block it isn't exported 
correctly. Is there some way to have this work?

Thanks,

  -k.



Re: Org mode for meeting minutes

2019-10-31 Thread Ken Mankoff
Hello,

I think you can achieve that table with existing functionality.

(setq org-agenda-overriding-columns-format "%ITEM %TODO %DEADLINE")

And then agenda column view (C-c C-x C-c) shows a similar output.

I think similar outputs and methods could be used with :property: keywords too 
for adding follow-up dates to task, team-members, effort estimates, etc.

  -k.



Re: [O] Creating a (RabbitMQ) diagram

2019-10-17 Thread Ken Mankoff


On 2019-10-17 at 13:12 +02, PICCA Frederic-Emmanuel 
 wrote...
> https://en.wikipedia.org/wiki/PGF/TikZ

Or you can do it with Ditaa, http://plantuml.com, others that may be easier to 
use than TikZ.

  -k.




Re: [O] [PATCH] Add :eval only-manual to babel blocks

2019-10-16 Thread Ken Mankoff


On 2019-10-16 at 12:38 +02, Nicolas Goaziou  wrote...
> Of course, meawhile, do not rely on undefined behaviour :)

Would you accept a documentation patch that defines the current behavior?

Then I get what I want, and it is on future developers to not mess it up :).

  -k.




Re: [O] [PATCH] Add :eval only-manual to babel blocks

2019-10-16 Thread Ken Mankoff
Hi Nicolas,

On 2019-10-16 at 12:38 +02, Nicolas Goaziou  wrote...
> Note that what you want, i.e., to distinguish behaviour depending on
> the location of the call stack is cheesy, at best. Think about macros,
> user-defined functions, etc.

Yes, it felt a bit hackish. But I'm new to this level of Org coding.

> The Emacs' answer to this is usually to check if call to a function is
> interactive, or not.

Can you provide a more obvious hint? :) I've read the documentation on 
called-interactively-p but have not had success yet with that function. The 
bottom of that doc string suggests this is not an appropriate use for it.

I've read the manual part on "Distinguish Interactive Calls"[1] but working 
through those examples I can't get deeper called functions to know if the 
nth-parent was called interactively or not.

Would you solve this issue somewhere completely different? Like an advice 
around the org-ctrl-c-ctrl-c function or something?

Thanks,

  -k.

[1] 
https://www.gnu.org/software/emacs/manual/html_node/elisp/Distinguish-Interactive.html



Re: [O] [PATCH] Add :eval only-manual to babel blocks

2019-10-16 Thread Ken Mankoff


On 2019-10-14 at 09:10 +02, Ken Mankoff  wrote...
> With this patch and ":eval only-manual" in a babel header,
>
> Org evaluates the source code if it is run via ~org-ctrl-c-ctrl-c~
> (e.g. =C-c C-c= in the babel block), but not if run via the
> ~org-babel-execute-buffer~ function.

Hmm. So it turns out (I think) this patch isn't necessary. The behavior I 
wanted and thought I implemented is actually the default behavior! I think the 
behavior is undefined for :eval not equal to "yes", "no", or "query", but the 
current undefined implementation does what I want.

  -k.




Re: [O] JShell support in Babel?

2019-10-15 Thread Ken Mankoff


On 2019-10-15 at 13:04 +02, Jarmo Hurri  wrote...
> JShell is a pretty nifty tool for exploring and demonstrating basic Java
> features. Has anyone happened to write support for it in Babel?

You can start working with it even without official Babel support:

#+BEGIN_SRC bash :results verbatim
jshell
int a[] = {0,1,3,5,8}
a
a[3] = 42
a

""
#+END_SRC
#+RESULTS:
#+begin_example
|  Welcome to JShell -- Version 11.0.4
|  For an introduction type: /help intro

jshell> int a[] = {0,1,3,5,8}
a ==> int[5] { 0, 1, 3, 5, 8 }

jshell> a
a ==> int[5] { 0, 1, 3, 5, 8 }

jshell> a[3] = 42
$3 ==> 42

jshell> a
a ==> int[5] { 0, 1, 3, 42, 8 }

jshell> 

jshell> ""
#+end_example


The last line doesn't P (from REPL) until I added the "". You can probably find 
a more elegant solution using :post.

  -k.
  



[O] [PATCH] Add :eval only-manual to babel blocks

2019-10-14 Thread Ken Mankoff

With this patch and ":eval only-manual" in a babel header,

Org evaluates the source code if it is run via ~org-ctrl-c-ctrl-c~ (e.g. =C-c 
C-c= in the babel block), but not if run via the ~org-babel-execute-buffer~ 
function.

This is my first contribution to Org core. I've signed FSF papers. 

  -k.

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 59591894d..aa72c642c 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -17051,6 +17051,12 @@ evaluating untrusted code blocks by prompting for a confirmation.
   Org does not evaluate the source code when exporting, yet the user
   can evaluate it interactively.
 
+- =only-manual= ::
+
+  Org evaluates the source code if it is run via ~org-ctrl-c-ctrl-c~
+  (e.g. =C-c C-c= in the babel block), but not if run via the 
+  ~org-babel-execute-buffer~ function.
+
 - =query-export= ::
 
   Org prompts the user for permission to evaluate the source code
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 572f97919..15fadadf0 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -228,7 +228,9 @@ should be asked whether to allow evaluation."
   (let* ((headers (nth 2 info))
 	 (eval (or (cdr  (assq :eval headers))
 		   (when (assq :noeval headers) "no")))
-	 (eval-no (member eval '("no" "never")))
+	 (manual (and (not (eq nil (member 'org-ctrl-c-ctrl-c (org--function-stack
+		  (not (eq nil (member eval '("only-manual"))
+	 (eval-no (member eval '("no" "never" "only-manual")))
 	 (export org-babel-exp-reference-buffer)
 	 (eval-no-export (and export (member eval '("no-export" "never-export"
 	 (noeval (or eval-no eval-no-export))
@@ -240,10 +242,24 @@ should be asked whether to allow evaluation."
  (nth 0 info) (nth 1 info))
 		  org-confirm-babel-evaluate
 (cond
+ (manual t)
  (noeval nil)
  (query 'query)
  (t t
 
+(defun org--function-stack ()
+  "Return the current call stack function names."
+  ;; https://emacs.stackexchange.com/questions/7396/
+  (butlast (mapcar 'cl-second 
+		   (let ((frames)
+			 (frame)
+			 (index 5))
+		 (while (setq frame (backtrace-frame index))
+		   (push frame frames)
+		   (incf index))
+		 (remove-if-not 'car frames)
+
+
 (defun org-babel-check-evaluate (info)
   "Check if code block INFO should be evaluated.
 Do not query the user, but do display an informative message if


Re: [O] Bug and quick bugfix

2019-10-13 Thread Ken Mankoff


On 2019-10-13 at 09:26 +02, Nicolas Goaziou  wrote...
> IIRC, the label has to be included in the caption command. I applied a
> different solution. Let me know if that works for you.

I thought so too. But I couldn't find a definitive answer for this when 
searching about this last night.

  -k.




Re: [O] Babel eval w/ C-c C-c but not (org-babel-execute-buffer)

2019-10-10 Thread Ken Mankoff


On 2019-10-11 at 00:13 +02, Tim Cross  wrote...
> My concern with this suggestion is that I think it my result in
> 'surprising' or unexpected results for users.

I hope nobody would be surprised if they C-u C-u C-c C-c'd ! :) Just as they 
shouldn't be surprised if the :cache is ignored, if run with prefix-arg. But I 
do understand your concern and agree with it.

> Perhaps an additional recognised configuration value for :export and
> :tangle, such as 'manual', which might mean something like 'onl[y]
> evaluate/tangle this block when requested with block level commands,
> not buffer level.

Yes, I agree this is preferred. The only reason I implemented the first version 
using prefix-arg is because I could see how to do that easily. I started down 
the path you describe above and ran into my own lisp and org limitations.

I'm open to implementation suggestions. My plan is to modify 
(org-babel-check-confirm-evaluate) and use introspection and see if 
(org-ctrl-c-ctrl-c) is in the call stack, and if so, return t. Does this make 
sense? Is there some better way to determine how 
org-babel-check-confirm-evaluate was reached? Or some better place to add the 
feature? Also, I'd use ":eval only-manual" unless someone suggests another 
value ("only-on-cc"?)

Thanks,

  -k.



Re: [O] Babel eval w/ C-c C-c but not (org-babel-execute-buffer)

2019-10-10 Thread Ken Mankoff
Hi Charles,

On 2019-10-10 at 18:22 +02, Berry, Charles  wrote...
> If the language mode you use supports of evaluation of the src edit
> buffer (e.g. ESS[R], Python), you can issue
>
> C-c C-v v C-c C-b
>
> for ESS[R] or
>
> C-c C-v v C-c C-c
>
> for Python (I think)
>
> The commands will expand :var args and noweb declarations, then
> execute the corresponding 'send-buffer' command regardless of :eval.

This could work in theory, but doesn't for bash on my system. And (I think) 
with this method tables of output are not then injected back into the Org 
buffer that can be exported as part of the document.

> Why not use something like this
>
> :eval (ok2run)
>
> where `ok2run' consults a property to decide whether to eval the block?

I need to think about this some more... Can you describe more how you picture 
this working? Off the top of my head, I am picturing a top-level property 
setting :eval (ok2run) and then blocks I want to always run have :eval yes and 
blocks I want to run interactively only have a new property, ":eval-on-c-c" set 
to "t". The, (ok2run) checks for eval-on-c-c as a header arg and returns 't' if 
it exists and 'nil' if it does not?


While your suggestions do work for some cases, they feel like work-arounds for 
a missing feature. Isn't the feature I'm proposing a logical enhancement? Why 
would someone C-c C-c (or C-u C-u C-c C-c) on a code block if they didn't want 
it to run? Shouldn't an explicit request override a local header or 
top-level-document flag that says "don't eval"?

  -k.




Re: [O] Babel eval w/ C-c C-c but not (org-babel-execute-buffer)

2019-10-10 Thread Ken Mankoff
Hello,

I think that even when ":eval no" is set, eval should happen if the user 
explicitly requests it.

The use case is that I have code that takes an unreasonable amount of compute 
time to run it in Emacs (e.g. a full day of compute time). I think even with 
:async this type of code should be run outside of emacs, so I tangle it and run 
the python or bash scripts in a terminal.

Elsewhere in the project (Org file) I have babel blocks that I want to update 
throughout the file. I do this by cleaning all result blocks with =C-u C-c C-v 
k= or (org-babel-remove-result-one-or-many), then executing all blocks (without 
=:eval no=) using =C-c C-v C-b= or (org-babel-execute-buffer).

In order to not spend days of compute time when I eval 
(org-babel-execute-buffer), I set :eval no to the computationally heavy babel 
blocks. But during development it would be nice to run these... hence the 
conflict with the current Org behavior and my desire for a new feature.

The two-line change at the bottom implements the following behavior:

When the prefix arg is passed to org-babel-execute-src-block, the block is 
evaluated regardless of the :eval flag.

Note that this doubles up on the prefix arg behavior, which is already set 
according to the documentation:

> With prefix argument ARG, force re-execution even if an existing
> result cached in the buffer would otherwise have been returned.

Questions for the list:

Is this feature something that makes sense?

If yes, then do you also think that tangling should occur when explicitly 
requested (i.e. C-u C-c C-v C-t), even if :tangle no is set?

Suggestions for a better implementation?

Thanks,

  -k.


diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 572f97919..9f9add334 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -646,7 +646,7 @@ block."
 ;; Merge PARAMS with INFO before considering source block
 ;; evaluation since both could disagree.
 (cl-callf org-babel-merge-params (nth 2 info) params)
-(when (org-babel-check-evaluate info)
+(when (or arg (org-babel-check-evaluate info))
   (cl-callf org-babel-process-params (nth 2 info))
   (let* ((params (nth 2 info))
 (cache (let ((c (cdr (assq :cache params
@@ -663,7 +663,7 @@ block."
(let ((result (org-babel-read-result)))
  (message (replace-regexp-in-string "%" "%%" (format "%S" result)))
  result)))
-((org-babel-confirm-evaluate info)
+ ((or arg (org-babel-confirm-evaluate info))
  (let* ((lang (nth 0 info))
 (result-params (cdr (assq :result-params params)))
 ;; Expand noweb references in BODY and remove any




Re: [O] noweb and :var statements

2019-10-06 Thread Ken Mankoff
Hi Sebastian,

Thanks for your help. I was running with "-Q" but must have been making some 
other mistakes. It does work.

As for your other email... I do know several tangles can go to the same file. 
And I may be using <> incorrectly, but I'm using it for the following 
reasons:

1) I'd like to bury code that must run first but is inconsequential at the 
bottom of the Org file. Noweb lets me have a tangled <> at the top, and 
then hide the lengthy <> code elsewhere. Is this a correct use case?

2) I'd like to import 10 tables, so I thought a noweb function might be useful 
for code reuse.

I finally got the behavior I'm looking for. What I need to remember/understand 
is that <> just pastes the body, and <> evaluates the function. 
From this, my Python code needs to generate Python code! I now have the 
following MWE that behaves as I want both for in-buffer C-c C-c eval of main 
code block and tangled results. The key bit of code is the last babel block.

Thanks for your help,

  -k.


* MWE init
#+BEGIN_SRC emacs-lisp :results output
(setq org-confirm-babel-evaluate nil)
(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))
(print (emacs-version))
(print (org-version nil t))
(org-babel-tangle)
#+END_SRC

* Main Project

#+NAME: main
#+BEGIN_SRC python :tangle MWE3.py :noweb yes :results output
<>
print(t42.sum())
print(t100.sum())
#+END_SRC

#+RESULTS: main
: 84.0
: 100.0

* Data Tables
#+NAME: table_42
| foo |
|-|
|  42 |
|  42 |

#+NAME: table_100
| bar |
|-|
| 100 |

* Setup

#+NAME: setup
#+BEGIN_SRC python :noweb yes
import numpy as np
<>
<>
#+END_SRC

* Table Import Code

#+NAME: import_table_to_varname
#+BEGIN_SRC python :var table=table_42 :var varname="foo" :noweb yes :results 
output
print(varname + "=np.array(" + str(table) + ").astype(np.float).flatten()")
#+END_SRC



Re: [O] noweb and :var statements

2019-10-06 Thread Ken Mankoff


On 2019-10-06 at 21:52 +02, Sebastian Miele  wrote...
> I wrote:
>
>> [..]
>>
>> However, something like the following may suit your use case. (For the
>> header-args property see section 15.2 (Using Header Arguments) of the
>> manual.)
>>
>> * A Heading
>> :PROPERTIES:
>> :header-args: :var table=table_foo
>> :END:
>>
>> #+NAME: table_foo
>> | foo |
>> |-|
>> |  42 |
>> | 100 |
>>
>> #+NAME: import
>> #+BEGIN_SRC python
>> import numpy as np
>> table = np.array(table).astype(np.float).flatten()
>> #+END_SRC
>>
>> #+BEGIN_SRC python :noweb yes :tangle import_noweb.py
>> <>
>> #+END_SRC
>
> Just the following works too, of course:
>
> #+NAME: table_foo
> | foo |
> |-|
> |  42 |
> | 100 |
>
> #+NAME: import
> #+BEGIN_SRC python
> import numpy as np
> table = np.array(table).astype(np.float).flatten()
> #+END_SRC
>
> #+BEGIN_SRC python :noweb yes :var table=table_foo :tangle import_noweb.py
> <>
> #+END_SRC

The result of tangling this is "import_noweb.py" contains:

import numpy as np
table = np.array(table).astype(np.float).flatten()

And I'd like it to somewhere include the line:
table = [42,100]
or something similar. I don't have the table data in the tangled code.

  -k.



Re: [O] noweb and :var statements

2019-10-06 Thread Ken Mankoff
Hi Sebastian,

I'm not getting the results I expect from your MWE either. Perhaps I gave too 
much code and asked X when what I really want is Y. I think I've distilled it 
to this:

What is the most elegant Org way to get a table into a Python array?

I can code it directly:

#+BEGIN_SRC python
<>
print(foo)
#+END_SRC


And now I can hide <> in a section at the bottom of the document. If it 
looks like this, everything works:

#+NAME: setup
#+BEGIN_SRC python
foo = np.array([42,43,44])
#+END_SRC

But is there a more elegant method? Can I get the same behavior if the data I 
want is in an Org table rather than hard-coded directly in Python?





Ideally, I'd like to have:

#+NAME: setup
#+BEGIN_SRC python
<>
<>
#+END_SRC

And a #+NAME: setup block that takes a :var table and sticks it in the :var 
varname variable.

And then after calling <> be able to use variable "foo" and "bar" that 
are generated from column or 2D Org tables elsewhere in the document. Can I do 
this in Org?

Thanks,

  -k.




[O] noweb and :var statements

2019-10-06 Thread Ken Mankoff
Hi Org list,

I'm having with noweb and variables. Can someone explain what I'm doing wrong? 
For example, if I have this table:

#+NAME: table_foo
| foo |
|-|
|  42 |
| 100 |

And I want to import it into Python and use it, I can do that like this:

#+NAME: import
#+BEGIN_SRC python :var table=table_foo :session foo
import numpy as np
table = np.array(table).astype(np.float).flatten()
#+END_SRC

Eval of this block works, and if I tangle it, I see:

> table=[[42], [100]]
> import numpy as np
> table = np.array(table).astype(np.float).flatten()

But if I want to use that block elsewhere via noweb, it doesn't seem to work:

#+BEGIN_SRC python :results output drawer :noweb yes :session foo :tangle 
import_noweb.py
<>
#+END_SRC

The code runs and in a clean *foo* session I do have my table variable, but I 
*also* get an error. The buffer contains the text at the bottom of this 
message, and the tangled code in import_noweb.py is only "nil".

How can I 1) run noweb blocks with variables and 2) tangle noweb blocks with 
variables (i.e. tangle tables into source files).

Thanks,

  -k.


table=[[42], [100]]
Python 2.7.15+ (default, Jul  9 2019, 16:51:35) 
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> >>> python.el: native completion setup loaded
>>> 
>>> import numpy as np
table = np.array(table).astype(np.float).flatten()

open('/tmp/babel-Mb4ojd/python-GEnZeZ', 'w').write(str(_))


'org_babel_python_eoe'
>>> Traceback (most recent call last):
  File "", line 1, in 
NameError: name '_' is not defined
>>> >>> >>> 'org_babel_python_eoe'
>>> 
>>> 
>>> 
>>> 
>>> 'org_babel_python_eoe'
'org_babel_python_eoe'
>>> 



[O] Babel eval w/ C-c C-c but not (org-babel-execute-buffer)

2019-10-02 Thread Ken Mankoff
Hello,

I'm interested in having code blocks that do not eval when I run 
(org-babel-execute-buffer) but do when the cursor is within them and I 
explicitly want to execute them by entering C-c C-c.

I cannot get this behavior playing around with the :eval header argument. Is 
the behavior I described possible?

Thanks,

  -k.



Re: [O] Org babel tangle: Don't export code

2019-09-24 Thread Ken Mankoff


On 2019-09-25 at 01:07 +02, Tim Cross  wrote...
> I just put :tangle no in the block header e.g.
>
> #+begin_src emacs-lisp :tangle no
>
> #+end_src

Also,

* COMMENT Section
#+BEGIN_SRC
# not exported because of COMMENT
#+END_SRC

  -k.




Re: [O] Modify a variable before it is passed to babel (or exported)?

2019-09-16 Thread Ken Mankoff
Hello,

I solved this with (org-sbe). For example, using "add-one" and "table" from the 
original email

#+Name: test-add-one
#+BEGIN_SRC python :results output values :var data=(org-sbe add-one (data 
table))
print(data)
#+END_SRC

#+RESULTS: test-add-one
: 43

Or

src_elisp{(org-sbe add-one (data table))} {{{results(=43=)}}}

   -k.

On 2019-09-16 at 10:21 -07, Ken Mankoff  wrote...
> I'd like to modify a variable with a babel block before another block
> sees the variable. For example, I always want to add one to a
> variable:
>
> #+NAME: add-one
> #+BEGIN_SRC bash :results verbatim :var data=0
> data=$(( data + 1 ))
> echo $data
> #+END_SRC
>
> #+RESULTS: add_one
> : 1
>
> Test it:
>
> #+CALL: add_one(data=42)
>
> #+RESULTS:
> : 43
>
> Can I use =add_one= to modify data passed elsewhere?
>
> For example, given 
>
> #+NAME: table
> | 42 |
>
> I'm having trouble defining a =print_table= function that prints 43, using 
> the =add_one= either via :prologue or <> or some other method. 
> Preferably prologue because then the add_one function could be in a different 
> language.
>
>
> I can get halfway to what I want with a :post option, but need this to be a 
> :pre or :prologue. Example using :post
>
> #+NAME: python_using_add_one
> #+BEGIN_SRC python :results output values :post add-one(data=*this*) 
> print(42)
> #+END_SRC
>
> #+RESULTS: python_using_add_one
> : 43
>
> Any suggestions how to use this feature with :pre or :prologue?
>
> Thanks,
>
>   -k




  1   2   3   4   5   >