Re: [O] Bug: org-paste-subtree displaces folded content [9.1.6 (9.1.6-48-gfe7619-elpaplus @ /home/ionasal/.emacs.d/elpa/org-plus-contrib-20180212/)]

2018-02-28 Thread Allen Li
On Wed, Feb 28, 2018 at 12:25 AM Nicolas Goaziou 
wrote:

> Hello,

> Allen Li  writes:

> >> > I modified the example a bit and made the undesired behavior unclear.
> >> >
> >> > * foo
> >> > :PROPERTIES:
> >> > :ID: a
> >> > :END:
> >> > * bar
> >> > :PROPERTIES:
> >> > :ID: b
> >> > :END:
> >> >
> >> > Folded, this looks like
> >> >
> >> > * foo...
> >> > * bar...
> >> >
> >> > With point on the f in foo, press C-c C-x C-w.  With point on the b
in
> > bar,
> >> > press C-c C-x C-y.  Results in
> >> >
> >> > * bar
> >> > * foo...
> >> >
> >> > Unfolded, this looks like
> >> >
> >> > * bar
> >> > * foo
> >> > :PROPERTIES:
> >> > :ID: a
> >> > :END:
> >> > :PROPERTIES:
> >> > :ID: b
> >> > :END:
> >> >
> >> > I would expect C-c C-x C-y to work like C-RET rather than M-RET, that
> > is to
> >> > always append after the heading and body rather than splitting it.
> >
> >> I changed the behaviour of `org-paste-subtree' in master. Does it solve
> >> the issue?
> >
> > No, the issue still exists.

> Applying the recipe above, I get:

>  * bar
>  :PROPERTIES:
>  :ID: b
>  :END:
>  * foo
>  :PROPERTIES:
>  :ID: a
>  :END:

Sorry, I made a silly mistake.  I can also confirm that the issue is fixed
on master.

Thanks for the quick fix.




> Regards,

> --
> Nicolas Goaziou



Re: [O] Numbering only second-level headlines in export

2018-02-28 Thread Jarmo Hurri

>> What - if any - would be the recommended way to implement numbering only
>> second-level headlines in an exported document with running numbering
>> (resets with first-level headline change)?
>
> You haven't said what export target you are using.  In any case, I would
> suggest you look at using a counter.  See section 12.5 of the org manual
> but specifically:
>
> ‘{{{n}}}’
> ‘{{{n(NAME)}}}’
> ‘{{{n(NAME,ACTION)}}}’
>  This macro implements custom counters by returning the number of
>  times the macro has been expanded so far while exporting the
>  buffer.  You can create more than one counter using different NAME
>  values.  If ACTION is ‘-’, previous value of the counter is held,
>  i.e.  the specified counter is not incremented.  If the value is a
>  number, the specified counter is set to that value.  If it is any
>  other non-empty string, the specified counter is reset to 1.  You
>  may leave NAME empty to reset the default counter.
>
> I would turn off numbering of headings (num:nil option) and then have
> the counter in each second level heading.

Brilliant, that worked like a charm on first trial. Thanks!

(BTW, my export target is html.)

Jarmo




Re: [O] Need help understanding how to limit a function to a tree

2018-02-28 Thread John Kitchin
You probably want this:

#+BEGIN_SRC emacs-lisp
(defun my-redo ()
  (interactive)
  (org-map-entries
   (lambda ()
 (org-todo "TODO"))
   "TODO=\"DONE\""  ;; the match argument
   'tree))  ;; the scope
#+END_SRC

Then call:

M-x my-redo

in the tree you want to reset.



John

---
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu


On Wed, Feb 28, 2018 at 4:36 PM, mediapathic steen 
wrote:

> I have a subtree that contains a daily list of things to do (which I keep
> as TODOs rather than checklist form for more granular time tracking). I
> want to reset all of the DONE to TODO every day when I start it. Right now
> I have this piece of code I copypasted from somewhere now lost (possibly
> this very group):
>
> (org-map-entries (lambda ()
>   (when
>   (string=
>(nth 2 (org-heading-components)) "DONE")
>(org-todo "TODO"
>
> This more or less makes sense to me. I have this code sitting in the
> subtree, and  in order to do my daily reset, I edit the subtree in an
> indirect buffer, eval-region the code, then kill the buffer.
>
> What I would like to accomplish:
> 1) Can you help me understand how to modify this code so that it only
> applies to the subtree it's run in (parents also would be fine in this case
> but not necessary and seems more of a challenge)? Doing the indirect buffer
> thing seems more hassle than is reasonable.
>
> 2) I think I understand how to put this in my init in such a way that I
> can C-x invoke it, rather than having to eval-region it, but I'm not
> certain. Can you point me toward a reasonable tutorial or hints on how to
> do that in general?
>
> Thanks in advance,
> -- Steen
>


Re: [O] How to keep correct filepaths when using the #+INCLUDE derivative?

2018-02-28 Thread Daniel P Gomez
If there is any interest, I've created a patch adding support for a
:absolute-paths functionality.
As I said, I don't have much experience writing Elisp, so any
suggestions on how to improve the code would be appreciated. If there
is any interest in adding this feature to Org I could try to clean it
up.

Patch attached.


On Wed, Feb 28, 2018 at 9:11 PM, Daniel P Gomez  wrote:
> Sorry for the ignorance, but where could I look up how to use a parse
> tree filter? And where would these modifications make sense?
> Any pointers towards documentation, functions, or any help of any kind
> would be appreciated. I must say I am a bit lost.
>
> Thank you in advance,
>
> Daniel
>
> On Wed, Feb 28, 2018 at 6:51 PM, Nicolas Goaziou  
> wrote:
>> Hello,
>>
>> Daniel P Gomez  writes:
>>
>>> If I include a file child.org in parent.org using the #+INCLUDE
>>> derivative, and the following two conditions are true:
>>>
>>> 1. child.org and parent.org are not in the same directory nor share
>>> directory structure,
>>> 2. child.org contains file links with relative file paths,
>>>
>>> then exporting parent.org will produce a file with broken links.
>>>
>>> Is there a way to have org sort this out?
>>>
>>> Or even make this optional,
>>> say by using:
>>>
>>> #+INCLUDE: child.org :fix-paths t
>>>
>>> I guess the quickest (but perhaps not cleanest) way to have this
>>> feature would be to convert relative paths in file links into absolute
>>> paths within `org-export-expand-include-keyword`. I'm not that well
>>> versed in Elisp yet to do this yet, though.
>>>
>>> Are there any known solutions to this, or suggestions on how to get it
>>> working?
>>
>> As you suggest, I would use a parse tree filter that turns every
>> relative file link into an absolute one.
>>
>> Regards,
>>
>> --
>> Nicolas Goaziou


0001-Add-support-for-absolute-paths-in-INCLUDE-derivative.patch
Description: Binary data


[O] Need help understanding how to limit a function to a tree

2018-02-28 Thread mediapathic steen
I have a subtree that contains a daily list of things to do (which I keep as 
TODOs rather than checklist form for more granular time tracking). I want to 
reset all of the DONE to TODO every day when I start it. Right now I have this 
piece of code I copypasted from somewhere now lost (possibly this very group):

(org-map-entries (lambda ()
  (when
  (string=
   (nth 2 (org-heading-components)) "DONE")
   (org-todo "TODO"

This more or less makes sense to me. I have this code sitting in the subtree, 
and  in order to do my daily reset, I edit the subtree in an indirect buffer, 
eval-region the code, then kill the buffer. 

What I would like to accomplish: 
1) Can you help me understand how to modify this code so that it only applies 
to the subtree it's run in (parents also would be fine in this case but not 
necessary and seems more of a challenge)? Doing the indirect buffer thing seems 
more hassle than is reasonable. 

2) I think I understand how to put this in my init in such a way that I can C-x 
invoke it, rather than having to eval-region it, but I'm not certain. Can you 
point me toward a reasonable tutorial or hints on how to do that in general?

Thanks in advance,
-- Steen


Re: [O] 2-column mode for many cooking recipes

2018-02-28 Thread Eric S Fraga
On Wednesday, 28 Feb 2018 at 16:33, Sharon Kimble wrote:

[...]

> However with Eric's code snippet the footnotes are shown at the end of
> '#+end_ingredients', so how can I get it back at the foot of the page
> when exported to latex and built into a PDF again please?

Untested but see my other reply: it may be that mdframed works better
than minipages.

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-191-g90607d


signature.asc
Description: PGP signature


Re: [O] 2-column mode for many cooking recipes

2018-02-28 Thread Eric S Fraga
On Wednesday, 28 Feb 2018 at 15:16, Sharon Kimble wrote:

[...]

> Thanks very much Eric, its working perfectly.

You're welcome.  Glad it worked!  Might be fragile, especially because
of the use of minipages and if you have long recipes, so you might like
to look at using the mdframed package: https://www.ctan.org/pkg/mdframed

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-191-g90607d


signature.asc
Description: PGP signature


Re: [O] How to keep correct filepaths when using the #+INCLUDE derivative?

2018-02-28 Thread Daniel P Gomez
Sorry for the ignorance, but where could I look up how to use a parse
tree filter? And where would these modifications make sense?
Any pointers towards documentation, functions, or any help of any kind
would be appreciated. I must say I am a bit lost.

Thank you in advance,

Daniel

On Wed, Feb 28, 2018 at 6:51 PM, Nicolas Goaziou  wrote:
> Hello,
>
> Daniel P Gomez  writes:
>
>> If I include a file child.org in parent.org using the #+INCLUDE
>> derivative, and the following two conditions are true:
>>
>> 1. child.org and parent.org are not in the same directory nor share
>> directory structure,
>> 2. child.org contains file links with relative file paths,
>>
>> then exporting parent.org will produce a file with broken links.
>>
>> Is there a way to have org sort this out?
>>
>> Or even make this optional,
>> say by using:
>>
>> #+INCLUDE: child.org :fix-paths t
>>
>> I guess the quickest (but perhaps not cleanest) way to have this
>> feature would be to convert relative paths in file links into absolute
>> paths within `org-export-expand-include-keyword`. I'm not that well
>> versed in Elisp yet to do this yet, though.
>>
>> Are there any known solutions to this, or suggestions on how to get it
>> working?
>
> As you suggest, I would use a parse tree filter that turns every
> relative file link into an absolute one.
>
> Regards,
>
> --
> Nicolas Goaziou



Re: [O] Numbering only second-level headlines in export

2018-02-28 Thread Eric S Fraga
On Wednesday, 28 Feb 2018 at 18:04, Jarmo Hurri wrote:
> Greetings.
>
> What - if any - would be the recommended way to implement numbering only
> second-level headlines in an exported document with running numbering
> (resets with first-level headline change)?

You haven't said what export target you are using.  In any case, I would
suggest you look at using a counter.  See section 12.5 of the org manual
but specifically:

‘{{{n}}}’
‘{{{n(NAME)}}}’
‘{{{n(NAME,ACTION)}}}’
 This macro implements custom counters by returning the number of
 times the macro has been expanded so far while exporting the
 buffer.  You can create more than one counter using different NAME
 values.  If ACTION is ‘-’, previous value of the counter is held,
 i.e.  the specified counter is not incremented.  If the value is a
 number, the specified counter is set to that value.  If it is any
 other non-empty string, the specified counter is reset to 1.  You
 may leave NAME empty to reset the default counter.

I would turn off numbering of headings (num:nil option) and then have
the counter in each second level heading.

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-191-g90607d


signature.asc
Description: PGP signature


Re: [O] How to keep correct filepaths when using the #+INCLUDE derivative?

2018-02-28 Thread Nicolas Goaziou
Hello,

Daniel P Gomez  writes:

> If I include a file child.org in parent.org using the #+INCLUDE
> derivative, and the following two conditions are true:
>
> 1. child.org and parent.org are not in the same directory nor share
> directory structure,
> 2. child.org contains file links with relative file paths,
>
> then exporting parent.org will produce a file with broken links.
>
> Is there a way to have org sort this out?
>
> Or even make this optional,
> say by using:
>
> #+INCLUDE: child.org :fix-paths t
>
> I guess the quickest (but perhaps not cleanest) way to have this
> feature would be to convert relative paths in file links into absolute
> paths within `org-export-expand-include-keyword`. I'm not that well
> versed in Elisp yet to do this yet, though.
>
> Are there any known solutions to this, or suggestions on how to get it
> working?

As you suggest, I would use a parse tree filter that turns every
relative file link into an absolute one.

Regards,

-- 
Nicolas Goaziou



Re: [O] 2-column mode for many cooking recipes

2018-02-28 Thread Sharon Kimble
Eric S Fraga  writes:

> On Wednesday, 28 Feb 2018 at 09:56, Sharon Kimble wrote:
>> I have this as a recipe -
>
> [...]
>
>> How can I have the ingredients in a left-most column and the method in a
>> right-most column please? So that everything below the index entries is
>> in 2-column mode which ends after the citation. And it can then be
>> renewed below the next index entries of the next entry, ad infinitum.
>>
>> This is for an org-mode document that is exported to latex and built
>> into a pdf file.
>
> You could use special blocks (section 12.10.10 of org manual).  See
> attached example for your recipe.  Does require LaTeX magic...

Unfortunately I spoke too soon.

With this recipe -

--8<---cut here---start->8---
** Macaroon Tart
\index[pies]{Macaroon 
tart}\index[menu]{Tart!macaroon}\index[cook]{Bake!macaroon tart}
#+begin_ingredients
/\uline{short pastry} [fn:4]/\\
/jam/\\
/1 teacupful sugar/\\
/almond essence/\\
/1 teacupful semolina/\\
/1 reconstituted powdered egg/\\
/3 ounces margarine/
#+end_ingredients
#+begin_steps
- Line the sandwich tin with short pastry.
- Spread jam over it and fill with mixture creamed together from all of the 
above ingredients.
- Bake in fairly hot oven for over 20 minutes (cite:0186).
#+end_steps

[fn:4] See \uline{Short Pastry+} in Part 1 - Basics, Biscuits, Bread & Pastries
--8<---cut here---end--->8---

Using this code snippet from my init file -

--8<---cut here---start->8---
#+BEGIN_SRC emacs-lisp
(setq org-footnote-section nil)
(setq org-footnote-auto-adjust t)
#+END_SRC
--8<---cut here---end--->8---

All footnotes are shown at the end of the page.

However with Eric's code snippet the footnotes are shown at the end of
'#+end_ingredients', so how can I get it back at the foot of the page
when exported to latex and built into a PDF again please?

Also the footnote has changed from a numerical superscript to an
alphabetical superscript! How could I get them back to numerical ones
please?

Thanks
Sharon.
-- 
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk  
Debian 9.3, fluxbox 1.3.7, emacs 25.3.2, org-mode 9.1.6-10-g0c9329-elpaplus


signature.asc
Description: PGP signature


[O] Numbering only second-level headlines in export

2018-02-28 Thread Jarmo Hurri

Greetings.

What - if any - would be the recommended way to implement numbering only
second-level headlines in an exported document with running numbering
(resets with first-level headline change)?

BTW, here is a full programming course (used to teach kids of different
ages) written almost entirely with org:

https://www.syk.fi/ohjelmointi/

The generation of the front page utilizes a couple of shell scripts,
some javascript and R, but it's all org otherwises. The entire source
code can be found here:

https://github.com/jarmohurri/ohjelmointi

All the best,

Jarmo




Re: [O] 2-column mode for many cooking recipes

2018-02-28 Thread Sharon Kimble
Eric S Fraga  writes:

> On Wednesday, 28 Feb 2018 at 09:56, Sharon Kimble wrote:
>> I have this as a recipe -
>
> [...]
>
>> How can I have the ingredients in a left-most column and the method in a
>> right-most column please? So that everything below the index entries is
>> in 2-column mode which ends after the citation. And it can then be
>> renewed below the next index entries of the next entry, ad infinitum.
>>
>> This is for an org-mode document that is exported to latex and built
>> into a pdf file.
>
> You could use special blocks (section 12.10.10 of org manual).  See
> attached example for your recipe.  Does require LaTeX magic...

This is what Eric has suggested -

--8<---cut here---start->8---
* Recipes
#+begin_export latex
\definecolor{verypaleblue}{rgb}{0.95,0.95,1}
\makeatletter\newenvironment{ingredients}{\begin{lrbox}{\@tempboxa}\begin{minipage}{0.3\textwidth}}{\end{minipage}\end{lrbox}\colorbox{verypaleblue}{\usebox{\@tempboxa}}}\makeatother
\makeatletter\newenvironment{steps}{\begin{lrbox}{\@tempboxa}\begin{minipage}{0.6\textwidth}\centering}{\end{minipage}\end{lrbox}\usebox{\@tempboxa}}\makeatother
#+end_export

** Date Bread
#+begin_ingredients
/12 ounces stoned dates/\\
/1 teaspoonful bicarbonate of soda/\\
/1 cupful boiling water/\\
/4 ounces margarine/\\
/1 egg/\\
/2 cups flour/\\
/$\frac{1}{2}$ cup sugar/\\
/pinch of salt/
#+end_ingredients
#+begin_steps
- Cut dates into pieces, shake soda over the dates, and pour water over.
- Add margarine cut into small pieces and stir well.
- Break egg into mixture, then add sugar and flour.
- Divide into two loaf tins and bake 90 minutes in moderate oven, Regulo 4.
#+end_steps
--8<---cut here---end--->8---

And to use these two blocks I've written 2 new snippets -

--8<---cut here---start->8---
# -*- mode: snippet -*-
# name: 2 column, part 1, recipes
# key: xin
# --
#+begin_ingredients
$0
#+end_ingredients
--8<---cut here---end--->8---

and -

--8<---cut here---start->8---
# -*- mode: snippet -*-
# name: 2 column, part 2, recipes
# key: xst
# --
#+begin_steps
$0
#+end_steps
--8<---cut here---end--->8---

And its now all working very well, and greatly enhances the look of the
printed page.

Thanks very much Eric, its working perfectly.

Thanks
Sharon.
-- 
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk  
Debian 9.3, fluxbox 1.3.7, emacs 25.3.2, org-mode 9.1.6-10-g0c9329-elpaplus


signature.asc
Description: PGP signature


Re: [O] superscript footnote number underlined?

2018-02-28 Thread Sharon Kimble
Akater  writes:

> Sharon Kimble  writes:
>
>> How can I have the footnote number in an org-mode file, exported to
>> latex and then built as a PDF file, be underlined please?
>
> Try adding the following LaTeX directive.
>
> #+latex_header: \renewcommand{\thefootnote}{\underline{\arabic{footnote}}}
>
> Note: both footnote number in text and in the footnote itself will be
> underlined.

Thanks Akater, this works perfectly. 

Thanks
Sharon.
-- 
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk  
Debian 9.3, fluxbox 1.3.7, emacs 25.3.2, org-mode 9.1.6-10-g0c9329-elpaplus


signature.asc
Description: PGP signature


[O] How to keep correct filepaths when using the #+INCLUDE derivative?

2018-02-28 Thread Daniel P Gomez
Dear org users,

If I include a file child.org in parent.org using the #+INCLUDE
derivative, and the following two conditions are true:

1. child.org and parent.org are not in the same directory nor share
directory structure,
2. child.org contains file links with relative file paths,

then exporting parent.org will produce a file with broken links.

Is there a way to have org sort this out? Or even make this optional,
say by using:

#+INCLUDE: child.org :fix-paths t

I guess the quickest (but perhaps not cleanest) way to have this
feature would be to convert relative paths in file links into absolute
paths within `org-export-expand-include-keyword`. I'm not that well
versed in Elisp yet to do this yet, though.

Are there any known solutions to this, or suggestions on how to get it working?

Thanks in advance,

Daniel



Re: [O] superscript footnote number underlined?

2018-02-28 Thread Akater
Sharon Kimble  writes:

> How can I have the footnote number in an org-mode file, exported to
> latex and then built as a PDF file, be underlined please?

Try adding the following LaTeX directive.

#+latex_header: \renewcommand{\thefootnote}{\underline{\arabic{footnote}}}

Note: both footnote number in text and in the footnote itself will be
underlined.


signature.asc
Description: PGP signature


Re: [O] superscript footnote number underlined?

2018-02-28 Thread Akater
Sharon Kimble  writes:

> How can I have the footnote number in an org-mode file, exported to
> latex and then built as a PDF file, be underlined please?

Try adding the following LaTeX directive:

#+latex_header: \renewcommand{\thefootnote}{\underline{\arabic{footnote}}}

Note: both footnote number in text and in the footnote itself will be
underlined.


signature.asc
Description: PGP signature


Re: [O] 2-column mode for many cooking recipes

2018-02-28 Thread Eric S Fraga
On Wednesday, 28 Feb 2018 at 09:56, Sharon Kimble wrote:
> I have this as a recipe -

[...]

> How can I have the ingredients in a left-most column and the method in a
> right-most column please? So that everything below the index entries is
> in 2-column mode which ends after the citation. And it can then be
> renewed below the next index entries of the next entry, ad infinitum.
>
> This is for an org-mode document that is exported to latex and built
> into a pdf file.

You could use special blocks (section 12.10.10 of org manual).  See
attached example for your recipe.  Does require LaTeX magic...
#+title: Recipes
#+author: Professor Eric S Fraga
#+macro: lastchange 2018.02.26 11:14
#+options: toc:nil num:nil

* Recipes
#+begin_export latex
\definecolor{verypaleblue}{rgb}{0.95,0.95,1}
\makeatletter\newenvironment{ingredients}{\begin{lrbox}{\@tempboxa}\begin{minipage}{0.3\textwidth}}{\end{minipage}\end{lrbox}\colorbox{verypaleblue}{\usebox{\@tempboxa}}}\makeatother
\makeatletter\newenvironment{steps}{\begin{lrbox}{\@tempboxa}\begin{minipage}{0.6\textwidth}\centering}{\end{minipage}\end{lrbox}\usebox{\@tempboxa}}\makeatother
#+end_export

** Date Bread
#+begin_ingredients
/12 ounces stoned dates/\\
/1 teaspoonful bicarbonate of soda/\\
/1 cupful boiling water/\\
/4 ounces margarine/\\
/1 egg/\\
/2 cups flour/\\
/$\frac{1}{2}$ cup sugar/\\
/pinch of salt/
#+end_ingredients
#+begin_steps
- Cut dates into pieces, shake soda over the dates, and pour water over.
- Add margarine cut into small pieces and stir well.
- Break egg into mixture, then add sugar and flour.
- Divide into two loaf tins and bake 90 minutes in moderate oven, Regulo 4.
#+end_steps

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-191-g90607d


signature.asc
Description: PGP signature


[O] Feature suggestion and code review request: org-babel-cycle-src-block-header

2018-02-28 Thread Akater
When I have a chance, I enjoy the following development workflow: the
code is written in org files and is tangled into conventional source
code files more or less regularly.

I find that source blocks mostly fall into three categories, numbered
here for further reference:
- examples/test cases/desiderata, like
  `(my-implemented-or-desired-function x y)' (type 1) 
- drafts, failed attempts at implementations and other snippets better
  left as is, or as a warning (type 2)
- working implementations, to be tangled (type 3)

Hence I end up using only a handful of header argument strings. An
example corresponding to this 3-cases setup is found below. So it would
be nice to have a function that cycles between those, much like we can
cycle through org TODO sequence now using a standard function, and set
up this sequence per Org file.

I'm fairly bad at Emacs Lisp, so I'm interested in feedback about my
implementation of cycling function. It operates with strings, mostly
because I failed to make it work with lists of alists of header
arguments as ob-core.el suggests. On the other hand, given that Emacs
Lisp is more string-oriented than it is object-oriented, it might not be
a really bad idea.

So what do you think? How can this implementation be improved? (Sans
using rotate and tracking position in a smarter way.) Does it make sense
to include this feature in Org mode? Maybe I missed some existing
well-estabilished solutions? This is something akin to “literate
programming”; I'm not a fan of this idea---at least the way it is
usually presented---but it is somewhat popular a topic. I have some
other feature in mind I'd love to see implemented in Org-Babel:
convenient export of src blocks of type 1 (see above) into unit tests
(as test cases) and into documentation sources (as examples) but this
one is heavily target-language dependent and probably deserves its own
thread.

#+begin_src emacs-lisp
(cl-defun next-maybe-cycled (elem list  (test #'equal))
  "Returns the element in `list' next to the first `elem' found. If `elem' is 
found at `list''s very tail, returns `list''s car. `next-maybe-cycled' provides 
no way to distinguish between \"found nil\" and \"found nothing\"."
  (let ((sublist (cl-member elem list :test test)))
(and sublist
 (if (cdr sublist)
 (cadr sublist)
   (car list)

(defun shrink-whitespace (string)
  "Transforms all whitespace instances into single spaces. Trims whitespace at 
beginning and end. No argument type checking."
  (cl-reduce (lambda (string rule)
   (replace-regexp-in-string (car rule) (cdr rule) string))
 '(("[[:blank:]]+" . " ") ("^[[:blank:]]*" . "") ("[[:blank:]]*$" . 
""))
 :initial-value string))

(defun string-equal-modulo-whitespace (x y)
  (string-equal (shrink-whitespace x) (shrink-whitespace y)))

(defun org-babel-cycle-src-block-header-string (header-strings)
  "Cycle through given `header-strings' if currently in Org Babel source code 
block. If current src-block header is not found in `header-strings', switch 
header to the car of `header-strings'.

`header-strings' must be a non-empty list of strings. All whitespace in them is 
shrinked.

If UNDO-ed, cursor position is not guaranteed to be preserved."
  (interactive)
  (cond
   ((not (and header-strings (listp header-strings)))
(error "No Org Babel header strings list found to cycle through. %S found 
intstead." header-strings))
   ((not (every #'stringp header-strings))
(error "Malformed list of Org Babel header strings: not all elements are 
strings in %S." header-strings))
   (t
(let ((initial-position (point)))
  (org-babel-goto-src-block-head)
  ;; here we rely on `org-babel-goto-src-block-head'
  ;; signalling an error if not in source code block
  (forward-char (length "#+BEGIN_SRC"))
  (let* ((fallback-position (point))
 (we-were-before-replacement-zone (<= initial-position
  fallback-position)))
(let ((default-position-to-return-to initial-position)
  (old-header-string (delete-and-extract-region (point)

(line-end-position
  (unless we-were-before-replacement-zone
(incf default-position-to-return-to (- (length old-header-string
  (let ((new-header-string
 (concatenate 'string
  " "
  (shrink-whitespace
   (or (next-maybe-cycled old-header-string
  header-strings
  :test 
#'string-equal-modulo-whitespace)
   (car header-strings))
(insert new-header-string)
(unless we-were-before-replacement-zone
  (incf default-position-to-return-to (length new-header-string)))
  

[O] 2-column mode for many cooking recipes

2018-02-28 Thread Sharon Kimble

I have this as a recipe -

--8<---cut here---start->8---
** Date Bread
\index[pies]{Date bread}\index[menu]{Bread!date}\index[cook]{Bake!date 
bread}\index{Fruit!dates}
/12 ounces stoned dates/\\
/1 teaspoonful bicarbonate of soda/\\
/1 cupful boiling water/\\
/4 ounces margarine/\\
/1 egg/\\
/2 cups flour/\\
/$\frac{1}{2}$ cup sugar/\\
/pinch of salt/

Cut dates into pieces, shake soda over the dates, and pour water over. Add 
margarine cut into small
pieces and stir well. Break egg into mixture, then add sugar and flour. Divide 
into two loaf tins
and bake 90 minutes in moderate oven, Regulo 4 (cite:0187).
--8<---cut here---end--->8---

How can I have the ingredients in a left-most column and the method in a
right-most column please? So that everything below the index entries is
in 2-column mode which ends after the citation. And it can then be
renewed below the next index entries of the next entry, ad infinitum.

This is for an org-mode document that is exported to latex and built
into a pdf file.

Thanks
Sharon.
-- 
A taste of linux = http://www.sharons.org.uk
TGmeds = http://www.tgmeds.org.uk
DrugFacts = https://www.drugfacts.org.uk  
Debian 9.3, fluxbox 1.3.7, emacs 25.3.2, org-mode 9.1.6-10-g0c9329-elpaplus


signature.asc
Description: PGP signature


Re: [O] Bug: org-paste-subtree displaces folded content [9.1.6 (9.1.6-48-gfe7619-elpaplus @ /home/ionasal/.emacs.d/elpa/org-plus-contrib-20180212/)]

2018-02-28 Thread Nicolas Goaziou
Hello,

Allen Li  writes:

>> > I modified the example a bit and made the undesired behavior unclear.
>> >
>> > * foo
>> > :PROPERTIES:
>> > :ID: a
>> > :END:
>> > * bar
>> > :PROPERTIES:
>> > :ID: b
>> > :END:
>> >
>> > Folded, this looks like
>> >
>> > * foo...
>> > * bar...
>> >
>> > With point on the f in foo, press C-c C-x C-w.  With point on the b in
> bar,
>> > press C-c C-x C-y.  Results in
>> >
>> > * bar
>> > * foo...
>> >
>> > Unfolded, this looks like
>> >
>> > * bar
>> > * foo
>> > :PROPERTIES:
>> > :ID: a
>> > :END:
>> > :PROPERTIES:
>> > :ID: b
>> > :END:
>> >
>> > I would expect C-c C-x C-y to work like C-RET rather than M-RET, that
> is to
>> > always append after the heading and body rather than splitting it.
>
>> I changed the behaviour of `org-paste-subtree' in master. Does it solve
>> the issue?
>
> No, the issue still exists.

Applying the recipe above, I get:

* bar
:PROPERTIES:
:ID: b
:END:
* foo
:PROPERTIES:
:ID: a
:END:


Regards,

-- 
Nicolas Goaziou