Re: [O] Org speed keys anywhere

2018-08-02 Thread Kyle Meyer
orguser  writes:

[...]

> A few days ago a method was posted to emacs-devel which allows
> the user to use single key bindings in editor buffers too:
>
> https://lists.gnu.org/archive/html/emacs-devel/2018-07/msg01136.html

Looks like a nice idea.  I hope someone does take the time to make it
into a package.

> Could this method be added to org, so if the user sets an additional
> config variable like "org-use-speed-commands-everywhere" besides
> "org-use-speed-commands" then speed commands can be used anywhere
> in an org buffer, not just at the beginning of a headline?

IMO that'd work well as a separate package.

-- 
Kyle



[O] BUG in ob-scheme WAS: Re: Babel: verbatim results yield a table

2018-08-02 Thread Berry, Charles



> On Aug 2, 2018, at 5:19 AM, Jarmo Hurri  wrote:
> 
> 
> Greetings.
> 
> The org manual states that in the :results header argument of a block
> 
> verbatim Interpret literally and insert as quoted text. Do not create a
> table. Usage example: :results value verbatim

Unfortunately, `org-babel-scheme--table-or-string' does not honor :results 
verbatim. :-(


> 
> The quote above is from https://orgmode.org/manual/results.html
> 
> Given this description, I am trying to understand the result below from
> a Scheme snippet (this is an exercise in the good old SICP). In
> particular, why is the table created from the (nested) list?
> 
> Jarmo
> 
>   #+BEGIN_SRC scheme :exports both :results value verbatim
> (define (deep-reverse lst)
>   (define (deep-iter lst result)
> (if (null? lst)
> result
> (let ((first (car lst)) (rest (cdr lst)))
>   (deep-iter rest
>  (cons (if
> (pair? first)
> (deep-reverse first)
> first)
>result)
>   (deep-iter lst '()))
> 
> (deep-reverse (list (list 1 2 3 4) (list (list 5 6) 7 8)))
>   #+END_SRC
> 
>   #+RESULTS:
>   | 8 | 7 | (6 5) |   |
>   | 4 | 3 | 2 | 1 |
> 

HTH,

Chuck





Re: [O] Org src blocks and multiline macros

2018-08-02 Thread Berry, Charles



> On Aug 2, 2018, at 5:32 AM, Jarmo Hurri  wrote:
> 

>> 
>> Org macros don't get evaluated inside src blocks as far as I know. But
>> Noweb might help you. Look for this feature in Org manual. I use Noweb as
>> "macros for src blocks".
> 

Me, too. But maybe Jarmo just wants a template for some text element. ??

> Yep, that will give me something similar:
> 
> #+name: val1
> #+BEGIN_SRC org :exports none
> foo
> #+END_SRC
> 
> #+name: val2
> #+BEGIN_SRC org :exports none
> bar
> #+END_SRC
> 
> #+BEGIN_SRC org :noweb yes
>  Currently this gives me ~<><>~ indeed!
> #+END_SRC
> 
> Compared to multiline macros, though, having to (re)define bunch of src
> blocks for variables does seem like an overkill.
> 
> BTW, does anyone know how I could enforce the standard
> Org-interpretation of '~' in the resulting, exported Org.
> 
> Jarmo

There are some limitations on noweb expansion. C-c C-v C-v in a src block will 
show you what the expansion looks like and how :var args are handled.

ob-org does not provide for variables AFAICS. But using emacs-lisp with a 
:results drawer to render the output as org should help:


--8<---cut here---start->8---
#+header: :results drawer :exports results
#+begin_src emacs-lisp :var val1="foo" :var val2="bar" 
   (concat "Currently this gives me ~" val1 val2 "~ indeed!")
#+END_SRC

#+RESULTS:
:results:
Currently this gives me ~foobar~ indeed!
:end:
--8<---cut here---end--->8---


BTW, if you really do need a long or multiline MACRO, there is the possibility 
of using an `eval' style macro with a custom elisp function. e.g.

#+MACRO: longish-macro (eval (my-really-long-macro-def $1 $2 $3))

See

(info "(org) Macro Replacement")

But this carries the burden of having to defun `my-really-long-macro-def' 
before exporting your document.
 
HTH,

Chuck






Re: [O] [solved] target file of capture template does not save

2018-08-02 Thread tom
On Thu, Aug 2, 2018 at 8:13 AM tom  wrote:

> You guys are so skillful and awesome you helped me without saying a word!
>
> After looking around at
>
> https://emacs.stackexchange.com/questions/477/how-do-i-automatically-save-org-mode-buffers
>
> I just added a third hook,
> (add-hook 'org-capture-mode-hook 'org-save-all-org-buffers)
>
> I'll mark this solved. Org rocks, I don't rock.
>
>
> On Wed, Aug 1, 2018 at 8:41 AM tom  wrote:
>
>> Me again. Let me try to provide a bit more info. I'm using xdotool to
>> call "emacsclient -c -e '(org-capture)'". In my init.el, I have both
>>
>> (add-hook 'org-capture-mode-hook 'make-frame)
>> and
>> (add-hook 'org-capture-mode-hook 'delete-frame)
>>
>> my capture template writes to, say, "beans.org."
>>
>> I swoop in with the mouse, choose the template, finish, and the capture
>> frame goes away. perfect. I don't open or ever see beans.org. But when I
>> do visit the file, it is sitting there unsaved. How can I have it
>> automatically save for me? Modify the org-capture-mode hook? If that's the
>> case, may I have some help with the modification? Or am I missing something
>> else?
>>
>> Thanks.
>>
>> On Fri, Jul 27, 2018 at 7:42 PM tom  wrote:
>>
>>> Hey guys, I have a capture template set up pretty much the way I want
>>> it,  but the file it writes to does not save afterwards. It's a table line
>>> template with some prompts, :prepend, :table-line-position, and
>>> :kill-buffer.
>>>
>>> Why doesn't the file save? Is it supposed to?
>>> thanks
>>>
>>


Re: [O] target file of capture template does not save

2018-08-02 Thread tom
You guys are so skillful and awesome you helped me without saying a word!

After looking around at
https://emacs.stackexchange.com/questions/477/how-do-i-automatically-save-org-mode-buffers

I just added a third hook,
(add-hook 'org-capture-mode-hook 'org-save-all-org-buffers)

I'll mark this solved. Org rocks, I don't rock.


On Wed, Aug 1, 2018 at 8:41 AM tom  wrote:

> Me again. Let me try to provide a bit more info. I'm using xdotool to call
> "emacsclient -c -e '(org-capture)'". In my init.el, I have both
>
> (add-hook 'org-capture-mode-hook 'make-frame)
> and
> (add-hook 'org-capture-mode-hook 'delete-frame)
>
> my capture template writes to, say, "beans.org."
>
> I swoop in with the mouse, choose the template, finish, and the capture
> frame goes away. perfect. I don't open or ever see beans.org. But when I
> do visit the file, it is sitting there unsaved. How can I have it
> automatically save for me? Modify the org-capture-mode hook? If that's the
> case, may I have some help with the modification? Or am I missing something
> else?
>
> Thanks.
>
> On Fri, Jul 27, 2018 at 7:42 PM tom  wrote:
>
>> Hey guys, I have a capture template set up pretty much the way I want
>> it,  but the file it writes to does not save afterwards. It's a table line
>> template with some prompts, :prepend, :table-line-position, and
>> :kill-buffer.
>>
>> Why doesn't the file save? Is it supposed to?
>> thanks
>>
>


Re: [O] Org src blocks and multiline macros

2018-08-02 Thread Jarmo Hurri


>> I am once again facing a situation where I would like to define a
>> multiline org macro.
>
>
> I'm not sure what that means, but based on your example a different
> solution might work for you.
>
> 2. If not, could we have this feature? This would give us immediate
>>multiline macros in the following style, where referring to the value
>>of the variable could be done macro-style.
>>
>> #+HEADER: :var val1=foo
>> #+BEGIN_SRC org :var val2=" bar"
>>   Currently this gives me nothing but {{{val1}}}{{{val2}}}.
>> ...
>>
>
> Org macros don't get evaluated inside src blocks as far as I know. But
> Noweb might help you. Look for this feature in Org manual. I use Noweb as
> "macros for src blocks".

Yep, that will give me something similar:

#+name: val1
#+BEGIN_SRC org :exports none
foo
#+END_SRC

#+name: val2
#+BEGIN_SRC org :exports none
bar
#+END_SRC

#+BEGIN_SRC org :noweb yes
  Currently this gives me ~<><>~ indeed!
#+END_SRC

Compared to multiline macros, though, having to (re)define bunch of src
blocks for variables does seem like an overkill.

BTW, does anyone know how I could enforce the standard
Org-interpretation of '~' in the resulting, exported Org.

Jarmo




[O] Babel: verbatim results yield a table

2018-08-02 Thread Jarmo Hurri


Greetings.

The org manual states that in the :results header argument of a block

verbatim Interpret literally and insert as quoted text. Do not create a
 table. Usage example: :results value verbatim

The quote above is from https://orgmode.org/manual/results.html

Given this description, I am trying to understand the result below from
a Scheme snippet (this is an exercise in the good old SICP). In
particular, why is the table created from the (nested) list?

Jarmo

   #+BEGIN_SRC scheme :exports both :results value verbatim
 (define (deep-reverse lst)
   (define (deep-iter lst result)
 (if (null? lst)
 result
 (let ((first (car lst)) (rest (cdr lst)))
   (deep-iter rest
  (cons (if
 (pair? first)
 (deep-reverse first)
 first)
result)
   (deep-iter lst '()))

 (deep-reverse (list (list 1 2 3 4) (list (list 5 6) 7 8)))
   #+END_SRC

   #+RESULTS:
   | 8 | 7 | (6 5) |   |
   | 4 | 3 | 2 | 1 |




[O] Org speed keys anywhere

2018-08-02 Thread orguser

Org has a speed keys feature, so that at the beginning of
headlines one can use single key commands:

 

https://orgmode.org/manual/Speed-keys.html

 

 

A few days ago a method was posted to emacs-devel which allows
the user to use single key bindings in editor buffers too:

 

https://lists.gnu.org/archive/html/emacs-devel/2018-07/msg01136.html

 

 

Could this method be added to org, so if the user sets an additional
config variable like "org-use-speed-commands-everywhere" besides
"org-use-speed-commands" then speed commands can be used anywhere
in an org buffer, not just at the beginning of a headline?




Re: [O] Org src blocks and multiline macros

2018-08-02 Thread Kaushal Modi
Hello,

On Thu, Aug 2, 2018, 2:34 AM Jarmo Hurri  wrote:

>
> Greetings.
>
> I am once again facing a situation where I would like to define a
> multiline org macro.


I'm not sure what that means, but based on your example a different
solution might work for you.

2. If not, could we have this feature? This would give us immediate
>multiline macros in the following style, where referring to the value
>of the variable could be done macro-style.
>
> #+HEADER: :var val1=foo
> #+BEGIN_SRC org :var val2=" bar"
>   Currently this gives me nothing but {{{val1}}}{{{val2}}}.
> ...
>

Org macros don't get evaluated inside src blocks as far as I know. But
Noweb might help you. Look for this feature in Org manual. I use Noweb as
"macros for src blocks".

> --

Kaushal Modi


[O] Org src blocks and multiline macros

2018-08-02 Thread Jarmo Hurri


Greetings.

I am once again facing a situation where I would like to define a
multiline org macro. If my memory is not failing me (it might well be),
this is not possible.

So this lead me to consider the use of Org source blocks in Babel. Which
might well be a discussion I have had here before, see the reference to
the state of my memory above.

1. Is it now possible to pass variables to these blocks?

2. If not, could we have this feature? This would give us immediate
   multiline macros in the following style, where referring to the value
   of the variable could be done macro-style.

#+HEADER: :var val1=foo
#+BEGIN_SRC org :var val2=" bar" 
  Currently this gives me nothing but {{{val1}}}{{{val2}}}.

  This property would really help me structure some org documents in a
  sensible way when common parts can be reused.
#+END_SRC

Jarmo