Re: tags-todo org-agenda-custom-command weirdness

2020-09-05 Thread Stig Brautaset
Bastien  writes:
> Stig Brautaset  writes:
>> Thank you for looking into this. I'm going to try to come up with some
>> tests for the behaviour, and with the help of your references see if I
>> can get those tests to pass.
>
> did you manage to find the time to look into this?

I didn't manage to make the time, no. I still may, but if someone else
beats me to it I would certainly welcome it! I'm finding it hard to set
aside time to dig into it given I have a functioning workaround.

Stig



Re: tags-todo org-agenda-custom-command weirdness

2020-06-16 Thread Stig Brautaset
Kyle Meyer  writes:

> Stig Brautaset writes:
>
>> For me a2 and a4 returns the same, but a1 and a3 just returns TODO h2.
>> However, I can reproduce what you're seeing by setting this:
>>
>> (setq org-agenda-todo-ignore-scheduled nil)
>
> So, provided you've configured org-agenda-todo-ignore-scheduled and
> org-agenda-tags-todo-honor-ignore-options away from their default values
> of nil, the a1-4 behavior you described is as advertised, correct?

I'm not sure. I would have expected that my configured values of
org-agenda-todo-ignore-scheduled and
org-agenda-tags-todo-honor-ignore-options would apply for all a1-4, so
whatever I configure those to the result of a1-4 should be consistent.
It looks like `tags-todo` takes my configured values into account, but
`tags` does not.

>>> b1 and b3 are empty, which I think is expected given the tags-todo type.
>>
>> Well, I disagree :-)
>>
>> This behaviour of `tags-todo` seems inconsistent to me. If `todo` can
>> find DONE items, why shouldn't `tags-todo` do the same?
>
> Perhaps it should.  The behavior has been that way for a long time, and
> the code makes it look very deliberate.  That of course is not an
> argument that it should be that way, just one basis for expectations
> (and a reason to be wary of breaking workflows).
>
> And it looks like it was actually supposed to change to your preference
> in 2017.  There was a report [0] that essentially boils down to what
> you're saying, I think.  In response, 942b6267a (org-agenda: `tags-todo'
> command type includes DONE keywords, 2017-04-18) was applied, but then
> reverted for reasons not related to the intended change in behavior [1].
>
> There was then a follow-up in 2fb129b5c (`org-scan-tags' retrieve all
> TODO keywords, not only not-done ones, 2017-08-17).  As far as I can
> tell, that was supposed to achieve the behavior you're after but didn't.
> I don't have time to dig much at the moment, but quickly stepping
> through org-scan-tags, I think the issue is that the MATCHER argument
> still filters out done states.
>
>
> [0] 
> https://orgmode.org/list/caf96xx0xxhpkjaxy0dqmoiy3rnt+duok4p1y71f1awyjanl...@mail.gmail.com/
> [1] https://orgmode.org/list/874lt89fi2@free.fr/

Thank you for looking into this. I'm going to try to come up with some
tests for the behaviour, and with the help of your references see if I
can get those tests to pass.

Stig



Re: tags-todo org-agenda-custom-command weirdness

2020-06-15 Thread Stig Brautaset
Kyle Meyer  writes:

> Stig Brautaset writes:
>
>> I'm seeing some weirdness with tags-todo vs tags custom agenda commands.
>> Below is the smallest case I've managed to narrow it down to. I would
>> *expect* that all the a1-4 commands return the same results, and that
>> the b1-4 return the same results. That is not what I'm seeing, however.
>>
>> (setq-default org-agenda-custom-commands
>> '(("a1" "A1" tags-todo "-PROJ/TODO")
>>   ("a2" "A2" tags "-PROJ/TODO")
>>   ("a3" "A3" ((tags-todo "-PROJ/TODO")))
>>   ("a4" "A4" ((tags "-PROJ/TODO")))
>>   
>>   ("b1" "B1" tags-todo "-PROJ/DONE")
>>   ("b2" "B2" tags "-PROJ/DONE")
>>   ("b3" "B3" ((tags-todo "-PROJ/DONE")))
>>   ("b4" "B4" ((tags "-PROJ/DONE")
>>
>
> I agree with your expectation that a1-4 should be the same.  Why do you
> expect that b1-4 would be?  Shouldn't tags-todo consider only none-DONE
> todo items, in the same spirit as m versus M?  In other words, I'd
> expect b1 and b3 to be empty by definition.

I expected b1-4 to all yield the same result because I expect
`tags-todo` to search all TODO-items, not just TODO items where the
state is "TODO".


>> The effect of a1 & a2 appears identical to eachother, and a3 & a4 too,
>> but a1-2 and a3-4 differ (in that the former seems to include scheduled
>> items, but the latter does not.)
>
> It's helpful if you provide a minimal test file.  I've tried to come up
> with one that I think should capture what you're describing.

Mea culpa, I should have done this. 

>
> --8<---cut here---start->8---
> * TODO h1   :PROJ:
> * TODO h2
> * DONE h3   :PROJ:
> * DONE h4
> * TODO h5   :PROJ:
> SCHEDULED: <2020-06-14 Sun>
> * TODO h6
> SCHEDULED: <2020-06-14 Sun>
> * DONE h7   :PROJ:
> SCHEDULED: <2020-06-14 Sun>
> * DONE h8
> SCHEDULED: <2020-06-14 Sun>
> --8<---cut here---end--->8---
>
> With that, a1-4 all show:
>
> scratch:TODO h2
> scratch:TODO h6
>
> That doesn't match what you're seeing.  I'm testing with 706970 checked
> out, the commit you reported in your follow-up message.

For me a2 and a4 returns the same, but a1 and a3 just returns TODO h2.
However, I can reproduce what you're seeing by setting this:

(setq org-agenda-todo-ignore-scheduled nil)


>> What I'm seeing for b1-4 is even weirder. Here I observe b1, b2 and b4
>> have identical behaviour[*], but b3 is the odd one out: while the other
>> three return a list of DONE non-project tasks, b3 doesn't find anything.
>>
>> [*] I suspect the reason b2 and b4 are identical is that I have no
>> scheduled DONE tasks.
>
> For b2 and b4, I see
>
> scratch:DONE h4
> scratch:DONE h8
>
> b1 and b3 are empty, which I think is expected given the tags-todo type.

Well, I disagree :-)

This behaviour of `tags-todo` seems inconsistent to me. If `todo` can
find DONE items, why shouldn't `tags-todo` do the same?

Stig



Re: tags-todo org-agenda-custom-command weirdness

2020-06-13 Thread Stig Brautaset
Stig Brautaset  writes:

> Hi,
>
> I'm seeing some weirdness with tags-todo vs tags custom agenda commands.

I forgot to mention my Emacs / Org versions:

- GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin19.4.0, NS appkit-1894.40 
Version 10.15.4 (Build 19E287)) of 2020-04-18
- Org mode version 9.3.7 (9.3.7-2-g706970-elpaplus @ 
/Users/stig/.emacs.d/elpa/org-plus-contrib-20200608/)

Stig



tags-todo org-agenda-custom-command weirdness

2020-06-13 Thread Stig Brautaset


Hi,

I'm seeing some weirdness with tags-todo vs tags custom agenda commands.
Below is the smallest case I've managed to narrow it down to. I would
*expect* that all the a1-4 commands return the same results, and that
the b1-4 return the same results. That is not what I'm seeing, however.

(setq-default org-agenda-custom-commands
  '(("a1" "A1" tags-todo "-PROJ/TODO")
("a2" "A2" tags "-PROJ/TODO")
("a3" "A3" ((tags-todo "-PROJ/TODO")))
("a4" "A4" ((tags "-PROJ/TODO")))

("b1" "B1" tags-todo "-PROJ/DONE")
("b2" "B2" tags "-PROJ/DONE")
("b3" "B3" ((tags-todo "-PROJ/DONE")))
("b4" "B4" ((tags "-PROJ/DONE")


The effect of a1 & a2 appears identical to eachother, and a3 & a4 too,
but a1-2 and a3-4 differ (in that the former seems to include scheduled
items, but the latter does not.)

What I'm seeing for b1-4 is even weirder. Here I observe b1, b2 and b4
have identical behaviour[*], but b3 is the odd one out: while the other
three return a list of DONE non-project tasks, b3 doesn't find anything.

[*] I suspect the reason b2 and b4 are identical is that I have no
scheduled DONE tasks.

I also see this with =m= vs =M= in the org-agenda menu. I see it even
when starting emacs with -q, so it appears to not be some spectactular
breakage on my part. Is anyone else seing this?


Stig



Re: [random sorting] (was: org table: one column of random numbers (but natural ones))

2020-05-29 Thread Stig Brautaset
Uwe Brauer  writes:

>>>> "SB" == Stig Brautaset  writes:
>
>>> > In row 67 you would have a random integer in the range [0..67)
>>> > f0 format removes any fractional part leaving only an integer number
>>> 
>>> Aha thanks, a minor thing, which I thank, cannot be really done:
>>> 
>>> Is it possible to avoid number repetition?
>>> 
>>> So I want a random sequence of the column 67 but I don't want numbers to
>>> be repeated.
>
>> To avoid duplicates you could generate a sequence from [0..67), shuffle
>> it[1], then use the row number as an index into that list. (Or pop off 
> the
>> front.) How to do that from an org table function I have no idea,
>> however.
>
> Thanks I tried in a row of 33
> $5=random([0..34]);f0
> $5=random([0..34));f0
> $5=random([0..33));f0
>
> But random repeats, however org-table-sort-lines sorts anyway
> And what I truly needed is a random sorting of sorts.

Right, I think I failed to make myself understood so here's an example
of what I had in mind. It's not convenient to use (need to execute
a source code block) but hopefully what I mean is a bit clearer, and
someone can clean it up a little :-)

First we need to generate a randomised sequence of unique integer in a
range, using the Knuth shuffle I pointed to earlier. Every time you run
tihs you get a new sequence. I've kept the output more to verify that
the results have unique output, as the table formula later will read
from the lisp variable, IIUC.

#+name: random-seq
#+begin_src emacs-lisp :var length=10 :results list
(defun nshuffle (sequence)
  (loop for i from (length sequence) downto 2
do (rotatef (elt sequence (random i))
(elt sequence (1- i
  sequence)

(setq random-seq (nshuffle (number-sequence 0 (1- length
#+end_src

#+RESULTS: random-seq
- 5
- 9
- 6
- 0
- 7
- 8
- 3
- 2
- 1
- 4

And now for the table that uses the variable. As we compute the
randomised sequence ahead of time for each invocation of the column
formula, and we can use each row number as an index into the sequence to
assign a unique, randomised integer from a range to each column.

| 0 | 5 |
| 1 | 9 |
| 2 | 6 |
| 3 | 0 |
| 4 | 7 |
| 5 | 8 |
| 6 | 3 |
| 7 | 2 |
| 8 | 1 |
| 9 | 4 |
#+TBLFM: $2='(nth (string-to-number $1) random-seq)


Possible improvements (that I don't think I'm up to making):

1. Don't require the column of indices to use as index into the sequence
2. Show how to do this without having the separate pre-compute step of
   the index (possibly with memoizing a sequence on first use?)

Hope this helps!

Regards,

Stig



Re: org table: one column of random numbers (but natural ones)

2020-05-28 Thread Stig Brautaset
>> In row 67 you would have a random integer in the range [0..67)
>> f0 format removes any fractional part leaving only an integer number
>
> Aha thanks, a minor thing, which I thank, cannot be really done:
>
> Is it possible to avoid number repetition?
>
> So I want a random sequence of the column 67 but I don't want numbers to
> be repeated.

To avoid duplicates you could generate a sequence from [0..67), shuffle
it[1], then use the row number as an index into that list. (Or pop off the
front.) How to do that from an org table function I have no idea,
however.

[1]: Emacs lisp "Knuth shuffle" implementation: 
https://stackoverflow.com/a/49505968/5950

Regards,
Stig




Re: Feature request: org-agenda-clockreport-mode to omit files with no clocked time

2020-04-26 Thread Stig Brautaset
Kyle Meyer  writes:
>> I often end up with empty files in my org-agenda-clockreport-mode,
>> [...]
>> I would have liked it to hide all the uninteresting files (i.e. files
>> with no clocked time) and instead shown me:
>
> I haven't tried, but can you already do this via
> org-agenda-clockreport-parameter-plist, in particular by adding
> `:fileskip0 t'?

That works for me. Thank you!

Stig



Feature request: org-agenda-clockreport-mode to omit files with no clocked time

2020-04-26 Thread Stig Brautaset
Hello,

I often end up with empty files in my org-agenda-clockreport-mode,
something like this. (For the avoidance of doubt: this is an ECM ;-) )

| File | Headline | Time   |   |
|--+--++---|
|  | ALL *Total time* | *0:42* |   |
|--+--++---|
| maybe.org| *File time*  | *0:00* |   |
|--+--++---|
| projects.org | *File time*  | *0:00* |   |
|--+--++---|
| tasks.org| *File time*  | *0:42* |   |
|  | Foo  | 0:08   |   |
|  | Bar  | 0:24   |   |
|  | Quux | 0:10   |   |

I would have liked it to hide all the uninteresting files (i.e. files
with no clocked time) and instead shown me:


| File | Headline | Time   |   |
|--+--++---|
|  | ALL *Total time* | *0:42* |   |
|--+--++---|
| tasks.org| *File time*  | *0:42* |   |
|  | Foo  | 0:08   |   |
|  | Bar  | 0:24   |   |
|  | Quux | 0:10   |   |

It seems like a small-ish change I may brave to implement--unless
someone beats me to it, which I'm fine with! I would appreciate some
pointers:

1. Would I need to introduce an option, in case anyone relies on the
   empty sections? (I *think* not, as I gather the prevailing wind is to
   reduce the number of options.)
2. Would this likely be best implemented as a post-processing filter? Or
   when generating the table in the first place?
3. Any helpful hints you can think of? :-)


Stig



Re: org-rss feed title is concatenation of all post titles? (ECM included)

2020-04-13 Thread Stig Brautaset
Nicolas Goaziou  writes:

> Stig Brautaset  writes:
>
>> Doh! Thanks for that. I tried working around this behaviour ~:lines
>> "1-"~, to skip the included file's #+title line, but that didn't seem to
>> work either. E.g. like this:
>>
>> : #+include: first-post.org :lines "1-"
>
> Doesn't "1-" mean the whole document?

...

Yeees, it does. And using 2- makes it work as I expect. 


PS: Can we pretend this whole thread didn't happen? :-)

Regards,
Stig



Re: org-rss feed title is concatenation of all post titles? (ECM included)

2020-04-12 Thread Stig Brautaset
Nicolas Goaziou  writes:
> Indeed. According to the manual, in (info "(org)Export settings")
>
>   ‘TITLE’
>Org displays this title.  For long titles, use multiple ‘#+TITLE’
>lines.
>
> Multiple TITLE keywords are concatenated to create a document title.

Doh! Thanks for that. I tried working around this behaviour ~:lines
"1-"~, to skip the included file's #+title line, but that didn't seem to
work either. E.g. like this:

: #+include: first-post.org :lines "1-"

Regards,
Stig



org-rss feed title is concatenation of all post titles? (ECM included)

2020-04-12 Thread Stig Brautaset
Hi,

I'm using org-rss.el to generate an RSS feed for my blog. I use a
separate file, ~feed.org~, which uses ~#+include:~ to source entries.
This works well for each item in the feed, but not for the main feed
title and feed image title, which appears to be a concatenation of the
feed and all the titles in all the items.

If I export RSS for the below ~feed.org~, the RSS title becomes:

: The Feed Title Title of first post Title of second post

However I *expect* it to be just:

: The Feed Title

The feed image title also is similarly affected:

#+begin_src xml
  
https://orgmode.org/img/org-mode-unicorn-logo.png
The Feed Title Title of first post Title of second post

  
#+end_src



Below is the Org files used in this example.

feed.org:

#+begin_src org
,#+title: The Feed Title
,* First Post
:PROPERTIES:
:RSS_PERMALINK: first-post.html
:END:
,#+include: first-post.org
,* Second Post
:PROPERTIES:
:RSS_PERMALINK: second-post.html
:END:
,#+include: second-post.org
#+end_src

first-post.org:

#+begin_src org
,#+title: Title of first post
First post content.
#+end_src

second-post:

#+begin_src org
,#+title: Title of second post
Second post content.
#+end_src


Software Versions:

- macOS 10.15.3
- Org mode version 9.3.2 (9.3.2-24-g5c72d6-elpaplus @ 
/Users/stig/.emacs.d/elpa/org-plus-contrib-20200203/)
- GNU Emacs 26.3 (build 1, x86_64-apple-darwin18.2.0, NS appkit-1671.20 Version 
10.14.3 (Build 18D109)) of 2019-09-02


Regards,
Stig



Best strategy for sharing agenda between two machines?

2020-02-24 Thread Stig Brautaset
Hi,

I use Org mode & agenda on both my personal and work machines, in a
private git repo repository. I use auto-commit and push automatically
from each machine. It works alright. New items go in inbox.org, and I
refile most to tasks.org, which has a structure a little like this:

* Home :@home:
** TODO Some task to do at home
** TODO Another task to do at home
* Work :@work:
** TODO A task to do at work
** TODO Another work task
* TODO Some task that is not inherently work/home
* WAITING Another task that blurs the barriers

The different sections for Home and Work means that there are not too
many merge conflicts. However, inbox.org is a different matter. My todo
template adds a LOGBOOK with an `Added' property, and it's almost
impossible to resolve the conflicts that result.

I see that
https://orgmode.org/worg/org-contrib/gsoc2012/student-projects/git-merge-tool/
sadly never produced a tool. But I'm wondering if people have some
strategy for how to best deal with git conflicts (perhaps a non-default
merge strategy works better with Org?) or maybe even better: how not to
create conflicts in the first place! 

I could use a different default agenda file for each machine, since the
inbox.org is worst affected. Is anyone doing this? I could extend this
to use {work,home}_tasks.org too, but I kinda like having that "neither
@work nor @home" option... Decisions decisions.

Stig



Re: Step by step tutorial on Worg on how to create a new export backend

2020-02-20 Thread Stig Brautaset
Bastien  writes:
> Then, after you commit an edited version of these instructions, maybe
> Robert and Marcin can help reviewing and enhancing it to ensure it is
> self-sufficient and explicit enough?

I have pushed a (ever so) slightly edited version as new file in a
branch to worg here:

https://code.orgmode.org/bzg/worg/src/org-export-backend-tutorial/org-tutorials/org-export-backend.org

Would Robert/Marcin like to take it from here?

Stig



Re: Step by step tutorial on Worg on how to create a new export backend

2020-02-16 Thread Stig Brautaset
Bastien  writes:

> We have a good reference documentation for creating export backends:
> https://orgmode.org/worg/dev/org-export-reference.html
>
> But we *badly* need a step by step tutorial on Worg.
>
> Anyone would like to volunteer for writing such a tutorial?

The primary source of `ox-jira.el' was once[1] an Org tutorial (to
myself) for creating an Org export backend. If this is broadly what you
had in mind, I can dig that out of Git history and put it on Worg. I
won't be able to do substantial edits or updates, as I made it 4 years
ago and it is still my only attempt at creating a backend. (So I have
forgotten most of it.) I still use it and it does pretty much what I
need it to, however.

https://github.com/stig/ox-jira.el/blob/c4b8fd30c3bc48621759c9d128644d2d386e591e/ox-jira.org

Stig

[1] Contributors got confused about the tangle step, probably because
melpa required me to commit the tangled .el as well as the .org source
file, so to make it simpler for them I since changed to shipping only
the tangled file. 



Re: Possible to exclude/include tags for agenda custom commands?

2020-02-13 Thread Stig Brautaset


Hi Bastien,

Bastien  writes:
>> I can easily do this in the list of TODOs, with a tag search. However, I
>> haven't figured out how to do this for the agenda. Is it possible? If
>> so, how?
>
> From what I understand, check `org-agenda-tag-filter' to see how to
> use it within an agenda custom command.

Thank you! That did indeed do it. 

FWIW my stanza looks like this now:

(setq org-agenda-custom-commands
 '(("w" "Work Agenda"
((agenda "" ((org-agenda-span 'day)))
 (todo "TODO"
   ((org-agenda-max-entries 5)
(org-agenda-todo-ignore-scheduled 'all)
(org-agenda-todo-ignore-deadlines 'all)
(org-agenda-todo-ignore-timestamp 'all
((org-agenda-tag-filter '("-@home" "-MAYBE"
   ("h" "Home Agenda"
((agenda "")
 (todo "TODO"
   ((org-agenda-max-entries 5)
(org-agenda-todo-ignore-scheduled 'all)
(org-agenda-todo-ignore-deadlines 'all)
(org-agenda-todo-ignore-timestamp 'all
((org-agenda-tag-filter '("-@work" "-MAYBE"
   ("m" "Maybe"
((todo "PROJ")
 (tags-todo "-PROJ/TODO"))
((org-agenda-tag-filter '("MAYBE"
   ("P" "Projects" tags-todo "-MAYBE/PROJ"
   
Stig



Possible to exclude/include tags for agenda custom commands?

2020-02-12 Thread Stig Brautaset


I use Org agenda to manage both work and non-work TODOs. I tend to use
the tags @home, @work. When at work I don't want to distractions from
@home stuff, and vice versa.

In a work context I would like an agenda view that excludes anything
tagged with @home, and a list of the 5 highest priority non-@home tasks.
Vice versa for a home context I want to exclude @work stuff. Items with
neither tag should show up in both views.

I can easily do this in the list of TODOs, with a tag search. However, I
haven't figured out how to do this for the agenda. Is it possible? If
so, how? If it's not possible, can I skip the agenda and instead create
a separate tags-todo search that shows a list of only those scheduled /
timestamped / deadlined for today in a separate stanza, so they stand
out from the unscheduled ones?

Here's what I'm currently using. The tags-todo search works as I like,
but I can't figure out how to exclude agenda items with certain tags
from the agendas.

(setq org-agenda-custom-commands
  '(("w" "Work Agenda"
 ((agenda "" ((org-agenda-span 'day)))
  (tags-todo "-@home-MAYBE/TODO"
 ((org-agenda-max-entries 5)
  (org-agenda-todo-ignore-scheduled 'all)
  (org-agenda-todo-ignore-deadlines 'all)
  (org-agenda-todo-ignore-timestamp 'all)
("h" "Home Agenda"
 ((agenda "")
  (tags-todo "-@work-MAYBE/TODO"
 ((org-agenda-max-entries 5)
  (org-agenda-todo-ignore-scheduled 'all)
  (org-agenda-todo-ignore-deadlines 'all)
  (org-agenda-todo-ignore-timestamp 'all)
("m" "Maybe"
 ((tags-todo "MAYBE/PROJ")
  (tags-todo "MAYBE-PROJ/TODO")))
("P" "Projects" tags-todo "-MAYBE/PROJ")))

Stig



Re: [O] org-id fixups and minor changes

2019-09-01 Thread Stig Brautaset
Hi Gustav,

Gustav Wikström  writes:
> [...] I also wonder how common it will be to try to batch-add ID’s…?

Not especially uncommon, I think.  Both the org-rss and org-drill
packages batch-add IDs on first use.

Regards,
Stig



Re: [O] RFC: changes to the way prefix arguments work for the command org-todo

2019-08-13 Thread Stig Brautaset
Carsten Dominik  writes:
> 3. I want to make `C-u C-c C-t' to switch the TODO state and force logging
> a time stamp and taking a note.  I am already using that functionality (now
> harder to access, on `C-u C-u C-u C-c C-t'), I find it very natural and I
> think it is often better than configuring automatic note-taking for every
> change, at least for my working environment.  Automatic note-taking slows
> me down too often.

I am in favour of this.  I want to take notes when changing states
_some_ of the time, and thus activate it but end up hitting `C-c C-k' to
omit the note most of the time.  I could omit automatic notes and
manually add notes with `C-c C-z`, but I think what you propose here is
better.

Stig



Re: [O] org-drill futures

2019-06-19 Thread Stig Brautaset
phillip.l...@russet.org.uk (Phillip Lord) writes:
>> To that end I've created a branch[1] for adding your fork to MELPA.
>> Based on your previous messages in this thread, I assume I have your
>> permission to submit a PR? Or is there a good reason to wait with this
>> for the moment?
>
> I already did this.
>
> https://github.com/melpa/melpa/pull/6207

Ah, I'm sorry I missed it! Relieved I didn't submit a duplicate without
checking with you first though :-)

> They may or may not want to accept this at the moment; org-drill falls
> short of their coding standards, and it will take a while to fix.

I have added a comment of support to your PR, and hope that helps. I
agree that it would make sense to merge already as is useful right now,
even if it needs a bit more love to conform to current coding standards.

> On the flip side, I have automated GUI testing working now which is
> helping with the refactoring. It's also rather cute and I've not seen it
> done with Emacs before. Have a look if you are interested!

I might!

Stig



Re: [O] org-drill futures

2019-06-18 Thread Stig Brautaset
>> phillip.l...@russet.org.uk (Phillip Lord) writes:
>>
>>> I've launched an fork of org-drill. I have tried to reach Paul Sexton,
>>> the original author, and had some feedback (he was happy for my take
>>> over), but not managed to get the repository moved.
>>>
>>> https://gitlab.com/phillord/org-drill/
>>>
...
>> I would suggest the opposite: move it to GNU ELPA, for example, so we
>> can remove it from contrib.
>
> Yes, I am quite happy with that also -- it would save the effort of
> syncing it. It would have to be MELPA though, because I don't think we
> have papers (I can check). This does have the disadvantage of requiring
> people to update their config/installed packages, but it's probably
> okay.

I would love to see org-drill available in MELPA. It's the most
important package I use from contrib. Moving it to MELPA means I'm
closer to being able to live with the version of Org that ships with
Emacs, and would not have to install org-plus-contrib.

To that end I've created a branch[1] for adding your fork to MELPA.
Based on your previous messages in this thread, I assume I have your
permission to submit a PR? Or is there a good reason to wait with this
for the moment?

Stig

[1]: https://github.com/stig/melpa/compare/master...stig:org-drill



Re: [O] Coloured source code examples in --batch exports?

2019-06-13 Thread Stig Brautaset
Nick Dokos  writes:

> Stig Brautaset  writes:
>
>> ...
>> Adding a ~--batch~ flag to the command makes the command run on
>> CircleCI, but I get a less colourful (and less pleasing) result. The
>> markup appears to only use /italic/ and *bold* styles now.
>>
>
> --batch skips your initialization file. You will have to provide a minimal
> load file that does the initializations you need and then use -l to load it:

Thank you. I did have a separate init file, but at the time I hadn't
figured out what to put in it! (I simplified my ECM too much!) However,
I've since discovered the magic org-html-htmlize-output-type variable
that does what I need.

My apologies for wasting people's time. I should have spent a bit more
time searching the archives, and less time building an ECM to
demonstrate something documented not to work!

Stig



[O] Coloured source code examples in --batch exports?

2019-06-13 Thread Stig Brautaset
Consider a file =foo.org= with the following content:

#+begin_src org :tangle foo.org
,#+begin_src emacs-lisp
  (defun foo (a b c)
"A metasyntactic function that doesn't do much."
(interactive)
(message "foo"))
,#+end_src
#+end_src

I can export that to HTML and get a nicely colourized export like so:

#+begin_src sh :results output verbatim
/Applications/Emacs.app/Contents/MacOS/Emacs --file foo.org --eval '(progn 
(package-initialize) (org-html-export-to-html nil nil nil t) (kill-emacs))'
cat foo.html
#+end_src

#+RESULTS:
: 
: (defun foo (a b c)
:   "A metasyntactic function that doesn't do 
much."
:   (interactive)
:   (message "foo"))
: 
: 

However, I can't run it like that because I'm trying to run it headless
on CirleCI, where neither DISPLAY nor TERM environment variables are
set. (Yes, I'm trying to automate my blog publishing.)

Adding a ~--batch~ flag to the command makes the command run on
CircleCI, but I get a less colourful (and less pleasing) result. The
markup appears to only use /italic/ and *bold* styles now.

#+begin_src sh :results output verbatim
/Applications/Emacs.app/Contents/MacOS/Emacs --batch --file foo.org --eval 
'(progn (package-initialize) (org-html-export-to-html nil nil nil t) 
(kill-emacs))'
cat foo.html
#+end_src

#+RESULTS:
: 
: (defun foo (a b c)
:   "A metasyntactic function that doesn't do 
much."
:   (interactive)
:   (message "foo"))
: 
: 

Is there a way I can get the nicely coloured output while exporting in
~--batch~ mode?

Stig


PS: In reality I'm using Org's publishing setup, but it was easier to
create a minimal example using export than an ECM that involves having
to configure ~org-publish-project-alist~...



Re: [O] Bug: org-map-drill-entries fails in org-tags-expand on empty string

2019-02-01 Thread Stig Brautaset
Robert Irelan  writes:

> Patch to fix attached.

I can confirm that this patch is required to make `org-drill' work for me in 
Org 9.2

Regards,

Stig



> From a3af9004fbc5a8a86ba8f990d393403ec671f9bf Mon Sep 17 00:00:00 2001
> From: Robert Irelan 
> Date: Wed, 23 Jan 2019 11:11:14 -0800
> Subject: [PATCH] org-drill: Fix tag match in org-map-drill-entries
>
> * contrib/lisp/org-drill.el: Change MATCH argument to ORG-MAP-ENTRIES
> from "" to nil.
>
> Without this, org-tags-expand will throw an error on the empty string.
> ---
>  contrib/lisp/org-drill.el | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/lisp/org-drill.el b/contrib/lisp/org-drill.el
> index c7f509bff..895003395 100644
> --- a/contrib/lisp/org-drill.el
> +++ b/contrib/lisp/org-drill.el
> @@ -1483,10 +1483,10 @@ the current topic."
>   (when (and (not (org-invisible-p))
>  (> (org-current-level) drill-entry-level))
> (when (or (/= (org-current-level) (1+ drill-entry-level))
> -(funcall test))
> + (funcall test))
>   (hide-subtree))
> (push (point) drill-sections)))
> -   "" 'tree))
> +   nil 'tree))
>  (reverse drill-sections)))



Re: [O] [PATCH] Add feature to org-drill to auto pronounce word

2019-02-01 Thread Stig Brautaset


stardiviner  writes:

[...]

> @@ -1486,7 +1521,7 @@ the current topic."
>  (funcall test))
>   (hide-subtree))
> (push (point) drill-sections)))
> -   "" 'tree))
> +   nil 'tree))
>  (reverse drill-sections)))

Could we have this part of the patch applied separately? org-drill on
Org 9.2 doesn't work for me without it. Other people have this problem
too, as I found a reference to this fix here:
https://emacs.stackexchange.com/a/46961/10625


Stig





Re: [O] Making an agenda that includes scheduled-for-later tasks?

2019-01-25 Thread Stig Brautaset


Leo Gaspard  writes:
> Hello all!
>
> I am trying to make an agenda view of all tasks that don't have the
> :Effort: property set, including tasks that are scheduled for later.
>
> My init.el files includes the following lines (of interest is the "E"
> agenda):
> ```
> (setq org-agenda-custom-commands
>   '(("U" "Unscheduled tasks"
>todo '("TODO" "WAITING")
>((org-agenda-overriding-header "Unscheduled tasks")
> (org-agenda-skip-function '(org-agenda-skip-entry-if 'scheduled
>   ("E" "Effortless tasks"
>todo '("TODO" "WAITING")
>((org-agenda-overriding-header "Effortless tasks")
> (org-agenda-skip-function '(org-agenda-skip-entry-if 'regexp 
> ":Effort:" 'todo '("APPT")))
> ```
>
> However, for some reason only tasks that are either not scheduled or
> scheduled for some time in the past show up in this agenda.

Does changing your "E" entry to this help at all?

,
| (setq org-agenda-custom-commands
|   '(("U" "Unscheduled tasks"
|todo '("TODO" "WAITING")
|((org-agenda-overriding-header "Unscheduled tasks")
| (org-agenda-skip-function '(org-agenda-skip-entry-if 'scheduled
|   ("E" "Effortless tasks"
|todo '("TODO" "WAITING")
|((org-agenda-overriding-header "Effortless tasks")
| (org-agenda-skip-function '(org-agenda-skip-entry-if 'regexp 
":Effort:" 'todo '("APPT")))
| (org-agenda-todo-ignore-scheduled nil)
| (org-agenda-todo-ignore-deadlines nil)
| (org-agenda-todo-ignore-timestamp nil)
`

By the way, the documentation for the `org-agenda-custom-commands'
variable says that the third entry should be "a single keyword for TODO
keyword searches", so the '("TODO" "WAITING") you have may be partly why
things are not working how you expect? You may want to try a compound
one like this:

,
| (setq org-agenda-custom-commands
|   '(("U" "Unscheduled tasks"
|todo '("TODO" "WAITING")
|((org-agenda-overriding-header "Unscheduled tasks")
| (org-agenda-skip-function '(org-agenda-skip-entry-if 'scheduled
|   ("E" "Effortless tasks"
|((todo "TODO")
| (todo "WAITING"))
|((org-agenda-overriding-header "Effortless tasks")
| (org-agenda-skip-function '(org-agenda-skip-entry-if 'regexp 
":Effort:" 'todo '("APPT")))
| (org-agenda-todo-ignore-scheduled nil)
| (org-agenda-todo-ignore-deadlines nil)
| (org-agenda-todo-ignore-timestamp nil)
`

Regards,

Stig



[O] Task repeat every weekday?

2019-01-23 Thread Stig Brautaset


Hi! I have some work tasks that I need to get into the habit of doing
every day. (Reviewing PRs / Jira, ...)

Currently I do this with a calendar-style repeater, like so:

,
| * Recurring Tasks
| ** Review PRs
|:LOGBOOK:
|:END:
|<%%(sb/weekday-p date)>
| 
|- https://github.com/pulls
`

Where init.el contains:

,
| (defun sb/weekday-p (date)
|   "Is `date' a weekday?"
|   (let ((dayname (calendar-day-of-week date)))
| (memq dayname '(1 2 3 4 5
`

While this allows me to clock in, and add comments, it doesn't give me that 
nice buzz from closing a task. And it doesn't get it out of my agenda once I've 
completed it that day.

Is there a way to make this into a repeating TODO that shows only on weekdays?

-- 
Kind regards,

Stig



[O] Confusing interaction when typing leading * for headings when org-hide-emphasis-markers is on

2017-11-25 Thread Stig Brautaset

Hello,

I've got =(setq org-hide-emphasis-markers t)= in my config, and 
it's mostly great but it does confuse me when I manually start 
sub-sub headings. (Which perhaps is a silly thing to do, but 
getting over muscle memory is hard to change.) After typing the 
third =*= (and on any subsequent ones typed) the first and last 
asterisks are hidden and the remaining appear bolded, until I type 
a space when what I'm typing is suddenly recognised as a heading 
and snaps back to displaying all the typed asterisks as expected.


I couldn't figure out how to post a video, so visually, here is 
what I see. One character typed on each line (comments after =;=):


: *
: **
: *  ; this is in bold
: ** ; this is in bold
:    ; asterisks no longer bold after typing a space

I tried adding an asterisks to the BORDER characters in 
org-emphasis-regexp-components, but that didn't seem to help.


PS: I realise that ironing out all visual niggles here is perhaps 
not possible, and perhaps me just learning to use the Org 
functions for inserting headings would hide the problem from me, 
but I decided to report it in case it turns out to be simple to 
find an acceptable fix for someone.


Stig
--
; GNU Emacs 27.0.50, Org mode version 9.1.3



Re: [O] Ediff org files starts folded

2017-11-02 Thread Stig Brautaset

Oleh Krehel  writes:

> Here's what I use:
>
> (defun ora-ediff-prepare-buffer ()
>   (when (memq major-mode '(org-mode emacs-lisp-mode))
> (outline-show-all)))
>
> (add-hook 'ediff-prepare-buffer-hook 'ora-ediff-prepare-buffer)

Thank you! This works very well for me. It's been on my TODO list to
figure out how to do this for a while.

Stig



[O] running tests on macOS: 4 unexpected results

2017-09-19 Thread Stig Brautaset

Running tests using the following script:

,
| #!/bin/sh
| emacs -Q --batch \
|   -L lisp/ -L testing/ -L testing/lisp -l lisp/org.el \
|   -l lisp/org-id.el -l testing/org-test.el \
|   --eval "(progn (org-reload) (setq org-confirm-babel-evaluate nil) \
|   (org-babel-do-load-languages 'org-babel-load-languages \
| '((emacs-lisp . t) (shell . t) (org . t" \
|   -f org-test-run-batch-tests
`

I get this result:

,
| Ran 578 tests, 574 results as expected, 4 unexpected (2017-09-19 
23:39:11+0100)
| 19 expected failures
| 
| 4 unexpected results:
|FAILED  ob-exp/evaluate-all-executables-in-order
|FAILED  ob-exp/export-call-line-information
|FAILED  ob-shell/bash-uses-assoc-arrays
|FAILED  test-org-publish/resolve-external-link
`

I'm on macOS Sierra, and using

: GNU Emacs 26.0.50 (build 2, x86_64-apple-darwin16.7.0, NS appkit-1504.83 
Version 10.12.6 (Build 16G29)) of 2017-09-07

I've tried to figure out what the issue was myself, but couldn't make
head or tails of it :-/

Stig
-- 
; GNU Emacs 26.0.50, Org mode version 9.1



[O] [PATCH] org-columns-summary-types entries can take COLLECT function

2017-09-08 Thread Stig Brautaset
Hello!

I've taken a stab at adding support for allowing
org-columns-summary-types entries to contain an optional COLLECT
function that can be used to conditionally collect a property.

Please see the included patch. I added a NEWS entry, but wasn't sure
whether a manual entry is required.

I added a couple simple tests, which pass, but the test immediately
above the two I added fails when this patch is applied; I haven't been
able to figure out why. Any help appreciated.

Comments / feedback welcome :-)

>From 749c90afad4908cda5a4d2d6c93f2049860e2c4d Mon Sep 17 00:00:00 2001
From: Stig Brautaset <s...@brautaset.org>
Date: Thu, 7 Sep 2017 17:57:44 +0100
Subject: [PATCH] org-colview: Allow custom COLLECT functions for derived
 properties

In addition to (LABEL . SUMMARIZE), org-columns-summary-types now
accepts (LABEL SUMMARIZE COLLECT) entries. The new COLLECT function is
called with one argument, the property being summarized.
---
 etc/ORG-NEWS | 47 +
 lisp/org-colview.el  | 32 +
 testing/lisp/test-org-colview.el | 50 
 3 files changed, 125 insertions(+), 4 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index e6ad838a6..b555cf971 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -54,6 +54,53 @@ its previous state.
 Editing the column automatically expands the whole column to its full
 size.
 
+*** =org-columns-summary-types= entries can take an optional COLLECT function
+
+You can use this to make collection of a property from an entry
+conditional on another entry. E.g. given this configuration:
+
+#+BEGIN_SRC emacs-lisp
+  (defun custom/org-collect-confirmed (property)
+"Return `PROPERTY' for `CONFIRMED' entries"
+(let ((prop (org-entry-get nil property))
+	  (confirmed (org-entry-get nil "CONFIRMED")))
+  (if (and prop (string= "[X]" confirmed))
+	  prop
+	"0")))
+
+  (setq org-columns-summary-types
+	'(("X+" org-columns--summary-sum
+	   custom/org-collect-confirmed)))
+#+END_SRC
+
+You can have a file =bananas.org= containing:
+
+#+BEGIN_SRC org
+  ,#+columns: %ITEM %CONFIRMED %Bananas{+} %Bananas(Confirmed Bananas){X+}
+
+  ,* All shipments
+  ,** Shipment 1
+ :PROPERTIES:
+ :CONFIRMED: [X]
+ :Bananas:  4
+ :END:
+
+  ,** Shipment 2
+ :PROPERTIES:
+ :CONFIRMED: [ ]
+ :BANANAS:  7
+ :END:
+#+END_SRC
+
+... and when going to the top of that file and entering column view
+you should expect to see something like:
+
+| ITEM| CONFIRMED | Bananas | Confirmed Bananas |
+|-+---+-+---|
+| All shipments   |   |  11 | 4 |
+| Shipment 1  | [X]   |   4 | 4 |
+| Shipment 2  | [ ]   |   7 | 7 |
+
 #+BEGIN_EXAMPLE
   ,#+STARTUP: shrink
 #+END_EXAMPLE
diff --git a/lisp/org-colview.el b/lisp/org-colview.el
index 679cb5ab8..5ab5bf939 100644
--- a/lisp/org-colview.el
+++ b/lisp/org-colview.el
@@ -67,7 +67,8 @@ or nil if the normal value should be used."
 (defcustom org-columns-summary-types nil
   "Alist between operators and summarize functions.
 
-Each association follows the pattern (LABEL . SUMMARIZE) where
+Each association follows the pattern (LABEL . SUMMARIZE),
+or (LABEL SUMMARISE COLLECT) where
 
   LABEL is a string used in #+COLUMNS definition describing the
   summary type.  It can contain any character but \"}\".  It is
@@ -78,6 +79,12 @@ Each association follows the pattern (LABEL . SUMMARIZE) where
   The second one is a format string or nil.  It has to return
   a string summarizing the list of values.
 
+  COLLECT is a function called with one argument, a property
+  name. It is called in the context of a headline and must return
+  the collected property, or the empty string. You can use this
+  to only collect a property if a related conditional properties
+  is set, e.g. to return VACATION_DAYS only if CONFIRMED is true.
+
 Note that the return value can become one value for an higher
 order summary, so the function is expected to handle its own
 output.
@@ -299,13 +306,29 @@ integers greater than 0."
 (push ov org-columns-overlays)
 ov))
 
-(defun org-columns--summarize (operator)
-  "Return summary function associated to string OPERATOR."
+(defun org-columns--summary-type (operator)
+  "Return summary type function(s) associated to string OPERATOR."
   (if (not operator) nil
 (cdr (or (assoc operator org-columns-summary-types)
 	 (assoc operator org-columns-summary-types-default)
 	 (error "Unknown %S operator" operator)
 
+(defun org-columns--summarize (operator)
+  "Return summary function associated to string OPERATOR."
+  (let ((type (org-columns--summary-type operator)))
+(if (functionp type)
+	type
+  ;; got summary

[O] duplicated test names... are these bugs?

2017-09-07 Thread Stig Brautaset

Hello!

Running tests on master for me, with make test, results in a single test
failure in `ob-shell/bash-uses-assoc-arrays'. While looking into that I
found that there are _two_ definitions of that in the test-ob-shell.el
file. This strikes me as unlikely to be ideal, and I decided to look a
bit further and it turns out this is not unique. Running the following
command from the top-level org-mode directory

: $ ag --nogroup --nonumbers ert-deftest  | sort | uniq -d

Results in

: testing/lisp/test-ob-lilypond.el:(ert-deftest ob-lilypond/ly-gen-html ()
: testing/lisp/test-ob-shell.el:(ert-deftest ob-shell/bash-uses-assoc-arrays ()
: testing/lisp/test-ob-shell.el:(ert-deftest 
ob-shell/generic-uses-no-assoc-arrays ()
: testing/lisp/test-ob.el:(ert-deftest 
test-ob/commented-last-block-line-with-var ()
: testing/lisp/test-ob.el:(ert-deftest 
test-ob/org-babel-remove-result--results-default ()
: testing/lisp/test-ob.el:(ert-deftest 
test-ob/org-babel-remove-result--results-list ()
: testing/lisp/test-ob.el:(ert-deftest 
test-ob/org-babel-remove-result--results-pp ()
: testing/lisp/test-org-table.el:(ert-deftest test-org-table/align ()

I'm not super familiar with ert, but I _assume_ that this will lead to
only the last definition of the test with the duplicate names being run
by 'make test'?

Stig


--
; GNU Emacs 26.0.50, Org mode version 9.1



Re: [O] Conditional summing in column-mode?

2017-08-31 Thread Stig Brautaset

Nicolas Goaziou  writes:

>> Is there a hook I can use that is called before the property values
>> are extracted? (I wasn't able to find one.)
>
> There isn't.
>
> But here is an idea: `org-columns-summary-types' could also accept
> entries like:
>
>   (LABEL SUMMARIZE COLLECT)
>
> where COLLECT is a function called on each summarized entry. SUMMARIZE
> is applied on the values returned by COLLECT. When not provided, COLLECT
> default to `org-entry-get' as it is the case already.
>
> WDYT?

I think I like it. So I could then do something like:

(defun sb/org-collect-confirmed-days ()
  "Return `DAYS' for `CONFIRMED' entries, otherwise return 0"
  (let ((days (org-entry-get nil "DAYS"))
(confirmed (org-entry-get nil "CONFIRMED")))
(if (and days (string= "[X]" confirmed))
days
  "0")))

(setq org-columns-summary-types
  '(("X+" org-columns--summary-sum sb/org-collect-confirmed-days)))


That seems quite elegant! I guess the COLLECT function would be called
in `org-agenda-colview-summarize' such that the existing summary
functions would not need to change?

Though, there will then be a tight coupling between the "X+" label and
the column name, which is not ideal. Perhaps the COLLECT function could
(optionally?) take the column name (or the whole column spec) as an
argument so we could do something like:

(defun sb/org-collect-confirmed-things (thing)
  "Return `THING for `CONFIRMED' entries, otherwise return 0"
  (let ((thing (org-entry-get nil thing))
(confirmed (org-entry-get nil "CONFIRMED")))
(if (and thing (string= "[X]" confirmed))
thing
  "0")))

Then we could use =X+= to calculate both confirmed Days and Bananas:

#+COLUMNS: %TIMESTAMP(When) %ITEM(What) %CONFIRMED(Confirmed?){X/} 
%Days(X+) %Bananas(X+)

Does this make sense?

I don't mind having a go at adding support for this, though I admit I'm
slightly terrified of the code in `org-agenda-colview-summarize' :-)


Stig



Re: [O] Conditional summing in column-mode?

2017-08-28 Thread Stig Brautaset

Nicolas Goaziou <m...@nicolasgoaziou.fr> writes:

> Stig Brautaset <s...@brautaset.org> writes:
>
>> However, I would like to add an advice around =org-columns-compute-all=
>> to run the =sb/org-map-confirmed-days= function, and this I have not
>> been successful at. I've tried doing this:
>>
>> : (add-function :before org-columns-compute-all #'sb/org-map-confirmed-days)
>>
>> However, I keep getting the following error:
>>
>> : Use of gv-ref probably requires lexical-binding
>> : advice--add-function: Symbol’s value as variable is void: 
>> org-columns-compute-all
>>
>> I would appreciate if anyone has any insight into solving this.
>
> Not really your question but since you can define your own summary
> function (see `org-columns-summary-types'), just make sure the summary
> function first refreshes the new property in headlines below the node
> you're currently summarizing.

Thanks! This _almost_ works:

,
| (defun sb/org-columns--summary-sum (values printf)
|   (org-map-entries #'sb/org-calc-confirmed-days nil 'tree)
|   (org-columns--summary-sum values printf))
|
| (setq org-columns-summary-types
|   '(("X+" . sb/org-columns--summary-sum)))
`

Unfortunately it doesn't quite: the functions in
=org-columns-summary-types= are passed a list of values already
extracted from the properties, so my calculation of "confirmed days"
only takes effect on the _next_ call to the summary function. Is there a
hook I can use that is called before the property values are extracted?
(I wasn't able to find one.)

Stig



Re: [O] Conditional summing in column-mode?

2017-08-25 Thread Stig Brautaset

Nicolas Goaziou <m...@nicolasgoaziou.fr> writes:

> Hello,
>
> Stig Brautaset <s...@brautaset.org> writes:
>
>> I have the following column-mode defined in =~/org/Holidays.org=:
>>
>> #+BEGIN_SRC org
>>   ,#+COLUMNS: %TIMESTAMP(When) %ITEM(What) %CONFIRMED(Confirmed?){X/} 
>> %DAYS(Days){+}
>>   ,#+Confirmed_ALL: "[ ]" "[X]"
>>   ,#+TODO: TODO | DONE CANCELLED
>> #+END_SRC
>>
>> Is it possible to have the =%DAYS(Days){+}= part only sum up rows that
>> have an =[X]= in their =Confirmed?= property?
>
> Not out of the box. But you could write a function creating and updating
> another property, e.g., CHECKED_DAYS and have columns view display this
> instead.

Thank you! That's a great idea. I've managed to come up with the
following, which works interactively:

#+BEGIN_SRC emacs-lisp
  (defun sb/org-calc-confirmed-days ()
"For an entry with both a `CONFIRMED' and `DAYS' property, calculate 
`CONFIRMED_DAYS'"
(let ((days (org-entry-get nil "DAYS"))
  (confirmed (org-entry-get nil "CONFIRMED")))
  (when (and days
 (string= "[X]" confirmed))
(org-entry-put nil "CONFIRMED_DAYS" days

  (defun sb/org-map-confirmed-days ()
"Map over entries and calculate confirmed days"
(interactive)
(org-map-entries #'sb/org-calc-confirmed-days))
#+END_SRC

However, I would like to add an advice around =org-columns-compute-all=
to run the =sb/org-map-confirmed-days= function, and this I have not
been successful at. I've tried doing this:

: (add-function :before org-columns-compute-all #'sb/org-map-confirmed-days)

However, I keep getting the following error:

: Use of gv-ref probably requires lexical-binding
: advice--add-function: Symbol’s value as variable is void: 
org-columns-compute-all

I would appreciate if anyone has any insight into solving this.

Stig

PS: I'm using Emacs and Org both installed from Git, on macOS.



[O] Conditional summing in column-mode?

2017-08-24 Thread Stig Brautaset

I have the following column-mode defined in =~/org/Holidays.org=:

#+BEGIN_SRC org
  ,#+COLUMNS: %TIMESTAMP(When) %ITEM(What) %CONFIRMED(Confirmed?){X/} 
%DAYS(Days){+}
  ,#+Confirmed_ALL: "[ ]" "[X]"
  ,#+TODO: TODO | DONE CANCELLED
#+END_SRC

Is it possible to have the =%DAYS(Days){+}= part only sum up rows that
have an =[X]= in their =Confirmed?= property?

Stig

-- 
; GNU Emacs 26.0.50, Org mode version 9.0.9



[O] [PATCH] convert htmlize.el to use cl-lib rather than cl

2017-07-14 Thread Stig Brautaset
Did a rather mechanical translation here, but test results seems to be
the same as before. Are patches like these something you're interested
in?

>From 68310479b615c80fb53aa112d274e2b76c0e2b70 Mon Sep 17 00:00:00 2001
From: Stig Brautaset <s...@brautaset.org>
Date: Fri, 14 Jul 2017 20:49:01 +0100
Subject: [PATCH 3/3] htmlize.el: use prefixed functions from cl-lib.el rather
 than cl.el

---
 contrib/lisp/htmlize.el | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/contrib/lisp/htmlize.el b/contrib/lisp/htmlize.el
index 8358830a4..f49d29a51 100644
--- a/contrib/lisp/htmlize.el
+++ b/contrib/lisp/htmlize.el
@@ -91,7 +91,7 @@
 
 ;;; Code:
 
-(require 'cl)
+(require 'cl-lib)
 (eval-when-compile
   (defvar unresolved)
   (if (string-match "XEmacs" emacs-version)
@@ -1071,7 +1071,7 @@ If no rgb.txt file is found, return nil."
 	  until (or (not f) (eq f 'unspecified))
 	  for h = (face-attribute f :height)
 	  collect (if (eq h 'unspecified) nil h
-(reduce 'htmlize-merge-size (cons nil size-list
+(cl-reduce 'htmlize-merge-size (cons nil size-list
 
 (defun htmlize-face-css-name (face)
   ;; Generate the css-name property for the given face.  Emacs places
@@ -1169,8 +1169,8 @@ If no rgb.txt file is found, return nil."
 	 ;; return it.
 	 (car fstruct-list))
 	(t
-	 (reduce #'htmlize-merge-two-faces
-		 (cons (make-htmlize-fstruct) fstruct-list)
+	 (cl-reduce #'htmlize-merge-two-faces
+		(cons (make-htmlize-fstruct) fstruct-list)
 
 ;; GNU Emacs 20+ supports attribute lists in `face' properties.  For
 ;; example, you can use `(:foreground "red" :weight bold)' as an
@@ -1412,7 +1412,7 @@ property and by buffer overlays that specify `face'."
 That means that GENERATOR will be evaluated and returned the first time
 it's called with the same value of KEY.  All other times, the cached
 \(memoized) value will be returned."
-  (let ((value (gensym)))
+  (let ((value (cl-gensym)))
 `(let ((,value (gethash ,key htmlize-memoization-table)))
(unless ,value
 	 (setq ,value ,generator)
@@ -1593,7 +1593,7 @@ it's called with the same value of KEY.  All other times, the cached
   (unwind-protect
   (let* ((buffer-faces (htmlize-faces-in-buffer))
  (face-map (htmlize-make-face-map (adjoin 'default buffer-faces)))
- (places (gensym))
+ (places (cl-gensym))
  (title (if (buffer-file-name)
 (file-name-nondirectory (buffer-file-name))
   (buffer-name
-- 
2.11.0 (Apple Git-81)


Stig
--
; GNU Emacs 26.0.50, Org mode version 9.0.9


[O] [PATCH] Use cl-lib rather than cl variants in org-drill

2017-07-14 Thread Stig Brautaset
org-drill requires only cl-lib rather than cl, so should use cl-gensym
rather than gensym I believe.

>From 1eef99d550e467bf4a3eaf6bdbe4d3a482f6c187 Mon Sep 17 00:00:00 2001
From: Stig Brautaset <s...@brautaset.org>
Date: Fri, 14 Jul 2017 20:45:37 +0100
Subject: [PATCH 2/3] org-drill.el: use cl-gensym rather than gensym

cl-lib is already required by this file, but cl is not.
---
 contrib/lisp/org-drill.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/lisp/org-drill.el b/contrib/lisp/org-drill.el
index fb578ab86..7c4a29930 100644
--- a/contrib/lisp/org-drill.el
+++ b/contrib/lisp/org-drill.el
@@ -622,7 +622,7 @@ regardless of whether the test was successful.")
 
 
 (defmacro pop-random (place)
-  (let ((idx (gensym)))
+  (let ((idx (cl-gensym)))
 `(if (null ,place)
  nil
(let ((,idx (random* (length ,place
-- 
2.11.0 (Apple Git-81)


Stig
-- 
; GNU Emacs 26.0.50, Org mode version 9.0.9


[O] [PATCH] use cl-lib functions rather than cl ones in org-test

2017-07-14 Thread Stig Brautaset
>From ead36e862d150e3a83d363bdead850a2e3ec281d Mon Sep 17 00:00:00 2001
From: Stig Brautaset <s...@brautaset.org>
Date: Fri, 14 Jul 2017 20:43:11 +0100
Subject: [PATCH 1/3] org-test.el: use prefixed functions from cl-lib.el rather
 than cl.el

---
 testing/org-test.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testing/org-test.el b/testing/org-test.el
index 844178e5a..5989907dd 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -104,7 +104,7 @@ org-test searches this directory up the directory tree.")
 This can be used at the top of code-block-language specific test
 files to avoid loading the file on systems without the
 executable."
-  (unless (reduce
+  (unless (cl-reduce
 	   (lambda (acc dir)
 	 (or acc (file-exists-p (expand-file-name exe dir
 	   exec-path :initial-value nil)
@@ -200,7 +200,7 @@ otherwise place the point at the beginning of the inserted text."
 (defmacro org-test-with-temp-text-in-file (text  body)
   "Run body in a temporary file buffer with Org mode as the active mode."
   (declare (indent 1))
-  (let ((results (gensym)))
+  (let ((results (cl-gensym)))
 `(let ((file (make-temp-file "org-test"))
 	   (kill-buffer-query-functions nil)
 	   (inside-text (if (stringp ,text) ,text (eval ,text)))
-- 
2.11.0 (Apple Git-81)


Stig
-- 
; GNU Emacs 26.0.50, Org mode version 9.0.9


Re: [O] [PATCH] Add missing require in org-test.el

2017-07-14 Thread Stig Brautaset

Nicolas Goaziou  writes:
>>(require 'cl-lib)
>> +  (require 'cl)
>
> Thank you.
>
> Actually, the proper fix would be to replace functions not working with
> (require 'cl-lib).
>
> Would you want to look into it?

Sure! I'll try that.

Stig



[O] [PATCH] Add missing require in org-test.el

2017-07-14 Thread Stig Brautaset

This is required for me to be able to run tests on master with GNU Emacs
26.0.50 on macOS.

>From f8959cd59e1f9ba5b6752d3d76f042c89553c7a3 Mon Sep 17 00:00:00 2001
From: Stig Brautaset <s...@brautaset.org>
Date: Fri, 14 Jul 2017 14:48:37 +0100
Subject: [PATCH] org-test: add missing require for cl.el

---
 testing/org-test.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/testing/org-test.el b/testing/org-test.el
index 844178e5a..7897e07e5 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -58,6 +58,7 @@
 			   (cons (expand-file-name "jump" org-test-dir)
  load-path
   (require 'cl-lib)
+  (require 'cl)
   (require 'ert)
   (require 'ert-x)
   (when (file-exists-p (expand-file-name "jump/jump.el" org-test-dir))
-- 
2.11.0 (Apple Git-81)


Stig


Re: [O] Saving org-capture buffer while writing it

2017-02-20 Thread Stig Brautaset

Narendra Joshi  writes:
>> Dunno about backups, but I experience this problem too. (Another
>> annoyance I have is accidentally hitting `C-c C-c' to tick a check box
>> and having my in-progress work being moved.) It can help to use the
>> `:immediate-finish' and `:jump-to-captured' settings like so:
>>
>> #+BEGIN_SRC emacs-lisp
>>   ("n" "Note" entry (file "Notes.org")
>>(file "tpl-note.org")
>>:empty-lines 1
>>:immediate-finish t
>>:jump-to-captured t)
>> #+END_SRC
>
> Do you write your email with Org-mode?

I do! (Sometimes.) I have bound `C-c x' in message-mode to swap to
`org-mode', and `C-c x' in org mode to swap to message-mode. Mostly I do
it for the outlining, but using babel to properly indent source code
snippets is very nice too.

> I have seen a lot of people writing the source code blocks and
> surprising they are syntax highlighted in Gnus. This makes me wonder
> if `org-mode' has support for writing emails too.

It does! Obviously Org markup is already perfectly readable as plain
text emails. And if you want to send HTML emails, check out
`org-mime-htmlize' which is part of `org-mime' from org-plus-contrib
(see: http://orgmode.org/elpa.html)

Stig

--
; GNU Emacs 25.1.1, Org mode version 9.0.5



Re: [O] Saving org-capture buffer while writing it

2017-02-20 Thread Stig Brautaset

Narendra Joshi  writes:

> Hi,
>
> Sometimes when I am taking notes, I end up spending a lot of time in a
> capture buffer. If I happen to switch to something else, I end up
> loosing the capture buffer. I probably just kill the buffer
> accidentally, or do `C-c C-k'.
>
> Is there a way I can take backups of the buffer to a file?

Dunno about backups, but I experience this problem too. (Another
annoyance I have is accidentally hitting `C-c C-c' to tick a check box
and having my in-progress work being moved.) It can help to use the
`:immediate-finish' and `:jump-to-captured' settings like so:

#+BEGIN_SRC emacs-lisp
  ("n" "Note" entry (file "Notes.org")
   (file "tpl-note.org")
   :empty-lines 1
   :immediate-finish t
   :jump-to-captured t)
#+END_SRC

Stig

--
; GNU Emacs 25.1.1, Org mode version 9.0.5



Re: [O] [Ann] Tool to hack time

2017-02-08 Thread Stig Brautaset

Hi Marco,

Marco Wahl  writes:

> Dear Orgers,
>
> https://gitlab.com/marcowahl/hack-time is a little tool to forge the
> `current-time' in Emacs.  This allows to mark todo-items done
> conveniently at another date.
>
> Maybe you want to play with that time forgery.
>
> Comments welcome, as always.

I gave it a quick spin. The first thing that struck me was sadness at
not finding an elpa package :-(

Anyway, I obtained it from its repo and I positioned calendar on 7th of
February, and invoked it on an entry I forgot to mark as done yesterday.
This is the result:

,
| ** TODO Practice guitar
|SCHEDULED: <2017-02-08 Wed ++1d/3d>
|:PROPERTIES:
|:STYLE:habit
|:LAST_REPEAT: [2017-02-08 Tue 12:01]
|:END:
|:LOGBOOK:
|- State "DONE"   from "TODO"   [2017-02-07 Tue 11:55] \\
`

Note that:

- new scheduled time is correct
- logbook entry is correct
- LAST_REPEAT property is *incorrect*; I expect this too to be
  [2017-02-07 Tue 11:55]


Stig



Re: [O] org-capture does copy selected marked text

2017-02-01 Thread Stig Brautaset

Uwe Brauer  writes:
>
> I have used org-capture a long time ago and do not recall the details,
> but I thought I could select a text and then org-capture would copy that
> selected text to a file of my choice in a format I can customize. A bit
> like good old remember does/did.
>
> For example I have set
>
> ("j" "Journal Entry"
>  entry (file+datetree "~/ALLES/journal.org")
>  "* %?"
>  :empty-lines 1)

Try adding "%i" to the capture template, for example like so:

 ("j" "Journal Entry"
  entry (file+datetree "~/ALLES/journal.org")
  "* %?\n\n  %i"
  :empty-lines 1)

Stig



Re: [O] git and orgmode: teaching git a bit of orgmode syntax

2017-01-24 Thread Stig Brautaset

Karl Voit  writes:

> Unfortunately, git does not handle diffs in a meaningful way. For
> example, when there are sub-hierarchies added or removed, it ends up
> with many diff-lines like the following:
>
> -* NEXT test with DAVdroid
> +* Lesestoff [1/26]:2read:
>  :PROPERTIES:
> -:CREATED:  [2016-05-08 Sun 12:51]
> +:CREATED: [2012-04-17 Tue 10:39]
> +:ARCHIVE:  %s_archive::* Lesestoff
> +:CATEGORY: reading
>  :END:
>
> The two headings being compared by git are totally unrelated. Git
> did find a match for the :PROPERTIES: and :END: lines and therefore
> assumed that I modified the level five heading "NEXT test with
> DAVdroid" into the first level heading "Lesestoff", not recognizing
> that in fact, there were many org-mode lines moved to the archive
> file, resulting in many deleted lines instead of modified ones.

You may want to try setting =diff.algorithm= (see =man git-config=) to
either =patience= or its variant =histogram=. This Stack Overflow answer
contains an example of how the effects of the diff created with the
patience algorithm, and it looks similar to the case you're describing:
http://stackoverflow.com/questions/4045017/what-is-git-diff-patience-for#4045087

You may also want to check out the option =diff.compactionHeuristic=,
which is described thus:

,
| Set this option to true to enable an experimental heuristic that
| shifts the hunk boundary in an attempt to make the resulting patch
| easier to read.
`

Stig



Re: [O] Org release_9.0 hangs

2017-01-17 Thread Stig Brautaset

Shiyuan  writes:

> Hi all,
> I am using emacs 24.5 (shipped with Ubuntu 16.04 LTS). When I try to
> switch to org release 9.0 from git repos, emacs hangs when starting up,

I don't know about tracking down, but I've not experienced any hangs
since I turned off the element cache a couple days ago so that might be
worth a try in the absence of anything else:

: (setq org-element-use-cache nil)

Stig



[O] refiling from capture dialogue demoting subsequent heading

2017-01-15 Thread Stig Brautaset
Hi,

I've found a couple times that some of my top-level sections have been
demoted one level. From my git history (I do a commit for each save in
Agenda) it looks like this has happened when refiling to a particular
section directly from the capture session. The demoted section is the
top-level heading immediately after where the entry was refiled to. I
have, however, not been able to reproduce the issue.

Stig



Re: [O] Emacs hangs sometimes for no reason

2017-01-15 Thread Stig Brautaset

Stig Brautaset <s...@brautaset.org> writes:

> Eric S Fraga <e.fr...@ucl.ac.uk> writes:
>
>> On Saturday, 14 Jan 2017 at 18:33, Sebastian Christ wrote:
>>> in the last couple weeks (perhaps months?) Emacs hangs for no specific
>>> reason for me. The single constant is, that when it hangs, it hangs
>>> while I'm in org-mode. This occurs on multiple circumstance as
>>
>> Just to say that I experience the same.  However, I track emacs as well
>> as org so I never know if the problem is emacs or org.  In my case, all
>> hangs are when in org mode but that could be because I'm in org mode
>> 90% of the time... :-)
>
> Just to say that I too experience the same. I'm convinced it started
> happening since I upgraded to Org 9 (but I also started using Org's
> Agenda more around the same time, I think). My versions:

I just saw Nicolas suggesting disabling org cache, and will try that.
(My stack traces from hangs did include references to the cache.) Will
report back if the hangs disappear, though it might take a while before
I'm confident they really are...

Stig



Re: [O] Emacs hangs sometimes for no reason

2017-01-15 Thread Stig Brautaset

Eric S Fraga  writes:

> On Saturday, 14 Jan 2017 at 18:33, Sebastian Christ wrote:
>> in the last couple weeks (perhaps months?) Emacs hangs for no specific
>> reason for me. The single constant is, that when it hangs, it hangs
>> while I'm in org-mode. This occurs on multiple circumstance as
>
> Just to say that I experience the same.  However, I track emacs as well
> as org so I never know if the problem is emacs or org.  In my case, all
> hangs are when in org mode but that could be because I'm in org mode
> 90% of the time... :-)

Just to say that I too experience the same. I'm convinced it started
happening since I upgraded to Org 9 (but I also started using Org's
Agenda more around the same time, I think). My versions:

- GNU Emacs 25.1.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 
(Build 13F1911)) of 2016-09-21
- Org mode version 9.0.3 (9.0.3-elpaplus @ - 
/Users/stig/.emacs.d/elpa/org-plus-contrib-20161224/)

I can go a few days without encountering it, but then it will suddenly
hit. I have a feeling that it's triggered by refiling, or closing
TODOs towards the end of the file. My agenda file is big, but not
monstrous. (I think.) C-= reports: "Region has 2025 lines, 9592 words,
and 67513 characters." There are 333 headings, most of them
TODO/NEXT/PROJECT, and I use lots of tags. I also use a few categories
on top-level headings.

I've set the following to try to speed up agenda, but it hasn't made any
discernible difference as far as I can tell:

: (setq org-agenda-use-tag-inheritance '(todo))

I've tried to turn on debug on quit, and sent a few stack traces here in
the past but to no avail. I cannot reproduce it with =emacs -q=, but
that uses Org 8 anyway, so I would not expect it to. Nor do I have a
sure-fire way to reproduce the issue, and I am not keen on being without
my regular config for days while hoping to reproduce the hang.

I do think it's related to Emacs having run for a while, because once
the hang manifests I can just quit Emacs and restart what I was doing
and no hang will manifest (for a while). When last I managed to capture
a stack trace during one of these the stack trace started  with:

: Debugger entered--Lisp error: (quit)
:  avl-tree--do-delete(org-element--cache-compare [[nil nil
: (property-drawer (:begin 18463 :end 18529 :contents-begin 18479
: :contents-end 18519 :post-blank 1 :post-affiliated 18463 :parent nil))
: 0] [nil nil (plain-list (:type unordered :begin 18547 :end 18749
: :contents-begin 18574 :contents-end 18748 :structure ... :post-blank 1
: :post-affiliated 18574 :name "candidate-names" :parent nil)) 0]
: (paragraph (:begin 18529 :end 18547 :contents-begin 18529
: :contents-end 18546 :post-blank 1 :post-affiliated 18529 :parent nil))
: 0] [[nil nil (keyword (:key "RESULTS" :value "" :begin 18905 :end
: 18920 :post-blank 1 :post-affiliated 18905 :parent nil)) 0] [nil nil
: (paragraph (:begin 19570 :end 19586 :contents-begin 19570
: :contents-end 19585 :post-blank 1 :post-affiliated 19570 :parent nil))
: 0] (table (:begin 18920 :end 19570 :type org :tblfm nil
: :contents-begin 18920 :contents-end 19568 :value nil :post-blank 2
: :post-affiliated 18920 :parent nil)) 0] (src-block (:language "sh"
: :switches nil :parameters ":var names=candidate-names :results table"
: :begin 18749 :end 18905 :number-lines nil :preserve-indent nil
: :retain-labels t :use-labels t :label-fmt nil :value "   echo $names |
: xargs -n1 | perl  -MList::Util -e
: 'print List::Util::shuffle <>'\n" :post-blank 1 :post-affiliated
: 18749 :parent nil)) 0

Further, I do notice this stack trace is full of `:drawer-name
"LOGBOOK"' entries too, like this:

: (:begin 9624 :end 9714 :drawer-name "LOGBOOK" :contents-begin 9638
: :contents-end 9704 :post-blank 0 :post-affiliated 9624 :parent nil))
: 0] nil nil ... 0] [nil nil ... 0] ... 0] [[nil nil ... 0] [nil nil
: ... 0] ... 0] (drawer ...) 0] [[[nil nil ... 0] [nil nil ... 0] ... 0]
: [[[nil nil ... 0] nil ... -1] [[nil nil ... 0] [nil nil ... 0] ... 0]
: ... 0] (item ...) 1] (drawer (:begin 15202 :end 15582 :drawer-name
: "LOGBOOK" :contents-begin 15216 :contents-end 15572 :post-blank 0
: :post-affiliated 15202 :parent nil)) 1] (drawer (:begin 11498 :end
: 11629 :drawer-name "LOGBOOK" :contents-begin 11512 :contents-end 11619
: :post-blank 0 :post-affiliated 11498 :parent nil)) 1] (property-drawer
: (:begin 7832 :end 7900 :contents-begin 7849 :contents-end 7890
: :post-blank 0 :post-affiliated 7832 :parent nil)) 1] [[nil nil ...
: 0] [nil nil ... 0] ... 0] [[nil nil ... 0] [nil nil ... 0] ... 0]
: (src-block ...) 0] [[[nil nil ... 0] [nil nil ... 0] ... 0] [[nil nil
: ... 0] [nil nil ... 0] ... 0] (drawer ...) 0] (paragraph (:begin 19586
: :end 19669 :contents-begin 19586 :contents-end 19668 :post-blank 1
: :post-affiliated 19586 :parent nil)) 0] nil nil ... 0] [nil nil
: ... 0] ... 0] [[nil nil ... 0] [nil nil ... 0] ... 0] (drawer ...) 0]
: [[[nil nil ... 0] [nil nil ... 0] ... 0] 

Re: [O] mark as done on a previous date?

2016-12-30 Thread Stig Brautaset

Marco Wahl  writes:

> Hi!
>
>> I'm trying to use org-habit to track my habits and sometimes I don't
>> get around to mark stuff as done on the day I do them. I've found two
>> different functions for marking stuff as done in the past, but I can't
>> get either of them to work.
>> [...]

[...]

Interesting. I couldn't get yours to work as I expected either, and
decided to try =org-todo-yesterday=, and couldn't get _that_ to work as
I expected either, which I thought was strange so I dug a bit deeper. I
tested with =emacs -q foo.org= and added the following entry (I did this
on the 30th of December):

,
| * TODO Testing 123
|   SCHEDULED: <2016-12-27 Tue .+1m>
|   :PROPERTIES:
|   :STYLE:habit
|   :END:
`

After using =org-todo-yesterday= I ended up with:

,
| * TODO Testing 123
|   SCHEDULED: <2017-01-29 Sun .+1m>
|   - State "DONE"   from "TODO"   [2016-12-30 Fri 16:29]
|   :PROPERTIES:
|   :STYLE:habit
|   :LAST_REPEAT: [2016-12-30 Fri 16:29]
|   :END:
`

I now see (finally!) that the *re-scheduling* works as I would expect,
but the LAST_REPEAT and state change logging still uses the actual time.
I would have expected both those to use the 29th rather than the 30th as
well. Perhaps this is just my expectation that needs adjusting, but this
breaks org-habit's graphing of my consistency. Perhaps I just have to
get in the habit of ticking stuff off on the day I do them... :-)

Stig



[O] mark as done on a previous date?

2016-12-29 Thread Stig Brautaset

I'm trying to use org-habit to track my habits and sometimes I don't
get around to mark stuff as done on the day I do them. I've found two
different functions for marking stuff as done in the past, but I can't
get either of them to work.

Here are the two different approaches I found. The first was at
https://www.emacswiki.org/emacs/OrgMode#toc22 and is the most general:

#+BEGIN_SRC emacs-lisp
  (defun org-todo-at-date (date)
(interactive (list (org-time-string-to-time (org-read-date
(cl-flet ((org-current-effective-time ( r) date)
  (org-today ( r) (time-to-days date)))
  (org-todo)))
#+END_SRC

The second is from
https://joelmccracken.github.io/entries/emacs-hack-set-todo-done-yesterday/
and looks like this:

#+BEGIN_SRC emacs-lisp
  (defun org-todo-toggle-yesterday ()
(interactive)
(let ((time-in-question (decode-time))) 
  (decf (nth 3 time-in-question))
  (setq time-in-question (apply 'encode-time time-in-question))
  (flet ((current-time () time-in-question))
(org-todo
#+END_SRC

Unfortunately, I haven't been able to get either to work. I've tested
with Org 9, and with =emacs -Q= (which gives me Org 8.2) but can't get
it to work in either. Perhaps the tricks employed do not work in Emacs
25?

FWIW:

: GNU Emacs 25.1.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 
(Build 13F1911)) of 2016-09-21
: Org mode version 9.0.3 (9.0.3-elpaplus @ 
/Users/stig/.emacs.d/elpa/org-plus-contrib-20161224/)

Stig



Re: [O] use-package with ox-latex

2016-12-27 Thread Stig Brautaset

Dushyant Juneja  writes:

> Hi all,
>
> I was trying to wrap ox-latex in a use-package configuration. My
> use-package statement is super simple:
>
> (use-package ox-latex
> :defer t)

ox-latex is part of org, which ships with Emacs. You should be able to
just use:

,
| (require 'ox-latex)
`

Alternatively:

,
| (use-package org
|   :config
|   (require 'ox-latex))
`

Finally, if you prefer org-plus-contrib you can do:

,
| (use-package org
|   :ensure org-plus-contrib
|   :config
|   (require 'ox-latex))
`

Hope this helps!

Stig



Re: [O] show only top level TODO in agenda and ignore sub level TODOS in agenda?

2016-12-24 Thread Stig Brautaset

Xebar Saram  writes:

> Thx stig. while thats an option i would prefer to keep the actual TODOS and
> not use lists for this

Another option is to use a different keyword, for example "PROJECT", for
things that have sub-TODOs, e.g.

,
| * PROJECT start writing paper
| ** TODO Collect data
| ** TODO add references
`

For that to work you may want to put something like this at the top of
the file:

,
| #+TODO: TODO(t) PROJECT(p) | DONE(d@) CANCELLED(c@)
`

Finally, a third option is to add a TODO (or TOPLEVEL) *TAG* and do
something like this at the top:

,
| #+TAGS: { TOPLEVEL(t) SUBTASK(t) } 
`

Then, you can do

,
| * TODO start writing paper :TOPLEVEL:
| ** TODO Collect data:SUBTASK:
| ** TODO add references  :SUBTASK:
`

You can filter for :TOPLEVEL: or :SUBTASK: from the agenda view. Of
course, you don't need both and it may be easier to just add one or the
other.

Hope this helps!

Stig



Re: [O] property drawers mysteriously have become right aligned

2016-12-22 Thread Stig Brautaset

Stig Brautaset writes:

> I just noticed that all my property drawers have become
> right-aligned, except the contents _inside_ them, which is still
> where it previously was. All my agenda entries now have their
> start/end markers right-aligned like this. (I only just learnt
> about org-habit.el)

Doh! Looks like format-flowed mangled my message. Let me try that
example again:

,
| ** TODO Write short paragraph for christmas cards
|SCHEDULED: <2017-03-01 Wed .+1m>
| 
:PROPERTIES:
|:LAST_REPEAT: [2016-12-19 Mon 12:44]
|:STYLE:habit
|
:END:
| 
|
:LOGBOOK:
|- Added: [2016-12-10 Sat 21:33]
|
:END:
| 
`

> I actually quite like it, as it makes the properties inside stand
> out a bit more, but I would like to know what I did, if anything,
> to make this happen. Also, I don't like that TAB to indent
> immediately such property drawers indents to same column as the
> :END: marker.

Stig



[O] property drawers mysteriously have become right aligned

2016-12-22 Thread Stig Brautaset


I just noticed that all my property drawers have become 
right-aligned, except the contents _inside_ them, which is still 
where it previously was. All my agenda entries now have their 
start/end markers right-aligned like this. (I only just learnt 
about org-habit.el)


,
| ** TODO Write short paragraph for christmas cards
|SCHEDULED: <2017-03-01 Wed .+1m>
| 
:PROPERTIES:

|:STYLE:habit
| 
:END:

|
| 
:LOGBOOK:

|- Added: [2016-12-10 Sat 21:33]
| 
:END:

`

I actually quite like it, as it makes the properties inside stand 
out a bit more, but I would like to know what I did, if anything, 
to make this happen. Also, I don't like that TAB to indent 
immediately such property drawers indents to same column as the 
:END: marker.


Stig



[O] trying to fix link in worg faq

2016-12-14 Thread Stig Brautaset

Hi,

I tried to fix the link to the "agenda-optimization" article in in 
worg's FAQ, but it didn't make much of a difference. My commit 
was: 
http://orgmode.org/cgit.cgi/worg.git/commit/?id=1e9e6a336eb28a705dd61f205378dc19f73f5ad5


For your convenience the content of that is:


diff --git a/org-faq.org b/org-faq.org
index 5a8c388..5bff186 100644
--- a/org-faq.org
+++ b/org-faq.org
@@ -2784,7 +2784,7 @@ variable =org-capture-templates= to 
"understand" (i.e. evaluate)


** My agenda commands are slow.  What to do?

-See the dedicated page about 
[[file:~/install/git/agenda-optimization.org][agenda speed up and 
optimization]].
+See the dedicated page about 
[[file:agenda-optimization.org][agenda speed up and 
optimization]].


** How can I change the advanced warning time for deadlines?
   :PROPERTIES:


As an aside I've tried to build worg locally for preview, but I've 
not been able to do so. Can anyone direct me to instructions, if 
such exists, of how to do that please?




[O] agenda hangs with Org 9

2016-12-08 Thread Stig Brautaset

Hi,

After upgrading to Org 9 I am experiencing hangs in agenda, 
particularly
after refiling. I've got only one Agenda file, though it is quite 
big:


: Region has 1185 lines, 5887 words, and 41293 characters.

I've activated `debug-on-quit' and capturing some stack traces. 
I'm afraid
they don't mean much to me, but perhaps they will mean something 
to someone

with more knowledge of the internals than I:

#+BEGIN_EXAMPLE
Debugger entered--Lisp error: (quit)
 avl-tree--do-delete(org-element--cache-compare [[nil nil 
 (property-drawer (:begin 18463 :end 18529 :contents-begin 18479 
 :contents-end 18519 :post-blank 1 :post-affiliated 18463 :parent 
 nil)) 0] [nil nil (plain-list (:type unordered :begin 18547 :end 
 18749 :contents-begin 18574 :contents-end 18748 :structure ... 
 :post-blank 1 :post-affiliated 18574 :name "candidate-names" 
 :parent nil)) 0] (paragraph (:begin 18529 :end 18547 
 :contents-begin 18529 :contents-end 18546 :post-blank 1 
 :post-affiliated 18529 :parent nil)) 0] [[nil nil (keyword (:key 
 "RESULTS" :value "" :begin 18905 :end 18920 :post-blank 1 
 :post-affiliated 18905 :parent nil)) 0] [nil nil (paragraph 
 (:begin 19570 :end 19586 :contents-begin 19570 :contents-end 
 19585 :post-blank 1 :post-affiliated 19570 :parent nil)) 0] 
 (table (:begin 18920 :end 19570 :type org :tblfm nil 
 :contents-begin 18920 :contents-end 19568 :value nil :post-blank 
 2 :post-affiliated 18920 :parent nil)) 0] (src-block (:language 
 "sh" :switches nil :parameters ":var names=candidate-names 
 :results table" :begin 18749 :end 18905 :number-lines nil 
 :preserve-indent nil :retain-labels t :use-labels t :label-fmt 
 nil :value "   echo $names | xargs -n1 | perl  -MList::Util -e 
 'print List::Util::shuffle <>'\n" :post-blank 1 :post-affiliated 
 18749 :parent nil)) 0] [[[nil nil (paragraph (:begin 19669 :end 
 19686 :contents-begin 19669 :contents-end 19685 :post-blank 1 
 :post-affiliated 19669 :parent nil)) 0] [nil nil (drawer (:begin 
 19930 :end 20489 :drawer-name "LOGBOOK" :contents-begin 19943 
 :contents-end 20480 :post-blank 0 :post-affiliated 19930 :parent 
 nil)) 0] (quote-block (:begin 19686 :end 19930 :contents-begin 
 19703 :contents-end 19914 :post-blank 1 :post-affiliated 19686 
 :parent nil)) 0] [[nil nil (drawer (:begin 22024 :end 22336 
 :drawer-name "LOGBOOK" :contents-begin 22038 :contents-end 22325 
 :post-blank 1 :post-affiliated 22024 :parent nil)) 0] [nil nil 
 (drawer (:begin 22475 :end 22823 :drawer-name "LOGBOOK" 
 :contents-begin 22489 :contents-end 22812 :post-blank 1 
 :post-affiliated 22475 :parent nil)) 0] (planning (:closed nil 
 :deadline nil :scheduled (timestamp ...) :begin 22443 :end 22475 
 :post-blank 0 :post-affiliated 22443 :parent nil)) 0] (drawer 
 (:begin 20555 :end 20613 :drawer-name "LOGBOOK" :contents-begin 
 20568 :contents-end 20603 :post-blank 1 :post-affiliated 20555 
 :parent nil)) 0] (paragraph (:begin 19586 :end 19669 
 :contents-begin 19586 :contents-end 19668 :post-blank 1 
 :post-affiliated 19586 :parent nil)) 0] nil nil (drawer 
 (:begin 23180 :end 23313 :drawer-name "LOGBOOK" :contents-begin 
 23194 :contents-end 23302 :post-blank 1 :post-affiliated 23180 
 :parent nil)) 0] [nil nil (drawer (:begin 23673 :end 23731 
 :drawer-name "LOGBOOK" :contents-begin 23686 :contents-end 23721 
 :post-blank 1 :post-affiliated 23673 :parent nil)) 0] (planning 
 (:closed nil :deadline nil :scheduled (timestamp ...) :begin 
 23641 :end 23673 :post-blank 1 :post-affiliated 23641 :parent 
 nil)) 0] [[nil nil (drawer (:begin 24008 :end 24066 :drawer-name 
 "LOGBOOK" :contents-begin 24021 :contents-end 24056 :post-blank 
 1 :post-affiliated 24008 :parent nil)) 0] [nil nil (drawer 
 (:begin 25208 :end 25269 :drawer-name "LOGBOOK" :contents-begin 
 25222 :contents-end 25258 :post-blank 1 :post-affiliated 25208 
 :parent nil)) 0] (drawer (:begin 24886 :end 24947 :drawer-name 
 "LOGBOOK" :contents-begin 24900 :contents-end 24936 :post-blank 
 1 :post-affiliated 24886 :parent nil)) 0] (drawer (:begin 23879 
 :end 23937 :drawer-name "LOGBOOK" :contents-begin 23892 
 :contents-end 23927 :post-blank 1 :post-affiliated 23879 :parent 
 nil)) 0] [[[nil nil (drawer (:begin 25800 :end 25858 
 :drawer-name "LOGBOOK" :contents-begin 25813 :contents-end 25848 
 :post-blank 1 :post-affiliated 25800 :parent nil)) 0] [nil nil 
 (drawer (:begin 26660 :end 26777 :drawer-name "LOGBOOK" 
 :contents-begin 26674 :contents-end 26766 :post-blank 1 
 :post-affiliated 26660 :parent nil)) 0] (drawer (:begin 26173 
 :end 26231 :drawer-name "LOGBOOK" :contents-begin 26186 
 :contents-end 26221 :post-blank 1 :post-affiliated 26173 :parent 
 nil)) 0] [[nil nil (drawer (:begin 26947 :end 27005 :drawer-name 
 "LOGBOOK" :contents-begin 26960 :contents-end 26995 :post-blank 
 1 :post-affiliated 26947 :parent nil)) 0] [[nil nil (drawer ...) 
 0] nil (drawer (:begin 27382 :end 27440 :drawer-name "LOGBOOK" 
 :contents-begin 27395 :contents-end 27430 :post-blank 1 
 :post-affiliated 27382 

Re: [O] writing letters using the latex letters class?

2016-12-08 Thread Stig Brautaset


Eric S Fraga writes:

Stig,

maybe post an ECM?  Koma letters work fine with me with org 9. 
I just

tried.


Yeah, this is a bit embarrassing but it works fine here too now 
that I
use the koma exporter rather than the latex one as Sebastian 
pointed

out...

Stig



Re: [O] writing letters using the latex letters class?

2016-12-08 Thread Stig Brautaset


Sebastian Christ writes:

You need to load `ox-koma-letter' and make sure you're not using 
the
latex exporter. For letters there is (after loading 
`ox-koma-letter' of

course) a separate koma exporter.


Doh! I used the latex exporter. Thanks, I'll give koma another try 
:-)


Stig



Re: [O] writing letters using the latex letters class?

2016-12-08 Thread Stig Brautaset


Sebastian Christ writes:


On 2016-12-08 0:46, Stig Brautaset <s...@brautaset.org> wrote:
 > That at least got me past the "Unknow LaTeX class 'letter'" 
 > error,
 > but it doesn't produce a nice letter. I only get my lorem 
 > ipsum
 > text. I can't figure out how to get the \begin{letter}{...} 
 > stuff
 > inside the \begin{document} part automatically, nor how to 
 > inject

 > text from #+recipient: into the second block of the
 > \begin{letter}{...} macro.

I can't actually help in using the letter class, but have you 
checked
"Creating letters with KOMA-Script scrlttr2 and Org-mode" [1]? 
I've been
using it excursively for all  my /formal/ letter writing and it 
works
great. Maybe you can give that a try? Plus it produces really 
nice

letters :)



It looks promising but I can't get it to work as I expect; is it 
perhaps
not fully compatible with Org 9? After following the instructions 
on
that page to the best of my abilities, and using their example 
document,
my output contains lots of stuff that I expect to be hidden. (E.g. 
all

the to/from special headings etc).

Stig



[O] writing letters using the latex letters class?

2016-12-07 Thread Stig Brautaset


I've tried to get a simple letter to export to PDF using the latex 
letters
class, but I can't get it to work in any satisfactory way. I want 
to get

something like the following generated:

,
| \documentclass{letter}
| \signature{Sender McSenderface}
| 
| \address{My address \\ My town \\ My country}
| 
| \begin{document}
| \begin{letter}{Recipient name \\ Recipient address \\ Recipient 
 country}
| 
| \opening{Dear Sir or Madam:}
| 
| Aliquam erat volutpat. Nunc eleifend leo vitae magna. In id erat 
 non orci
| commodo lobortis. Proin neque massa, cursus ut, gravida ut, 
 lobortis eget,

| lacus. Sed diam.
| 
| \closing{Yours Sincerely,}
| 
| \end{letter}

| \end{document}
`

I was hoping I could generate that from (something like) the 
following org

document:

,
| #+latex_class: letter
| #+signature: Sender McSenderface
| #+address: My address \\ My town \\ My country
| #+recipient: Recipient name \\ Recipient address \\ Recipient 
  country

| #+opening: Dear Sir or Madam
| #+closing: Yours Sincerely,
| 
| Aliquam erat volutpat. Nunc eleifend leo vitae magna. In id erat 
 non orci
| commodo lobortis. Proin neque massa, cursus ut, gravida ut, 
 lobortis eget,

| lacus. Sed diam.
`

Is this a pipe dream? I tried mucking about with 
org-latex-classes, and got as

far as this:

,
| (add-to-list 'org-latex-classes
|  '("letter"
|"\\documentclass{letter}
| \\usepackage{hyperref}
|[NO-DEFAULT-PACKAGES]
|[NO-PACKAGES]"
|("\\section{%s}" . "\\section*{%s}")
|("\\subsection{%s}" . "\\subsection*{%s}")
|("\\subsubsection{%s}" . "\\subsubsection*{%s}")
|("\\paragraph{%s}" . "\\paragraph*{%s}")
|("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
`

That at least got me past the "Unknow LaTeX class 'letter'" error, 
but it
doesn't produce a nice letter. I only get my lorem ipsum text. I 
can't figure
out how to get the \begin{letter}{...} stuff inside the 
\begin{document} part
automatically, nor how to inject text from #+recipient: into the 
second block

of the \begin{letter}{...} macro.

Any help appreciated.

Stig



Re: [O] renumber/resort footnotes?

2016-11-16 Thread Stig Brautaset
Hi Sharon,

Sharon Kimble writes:

> How can I renumber or resort my footnotes please? 

=C-u C-c C-x f= (=org-footnote-action=) offers an action to sort footnotes, in
the footnotes section. You can also re-number them throughout the document
from here.

Stig



Re: [O] Org mode osx

2016-11-11 Thread Stig Brautaset

Matthew Pritchard writes:

> Does anyone know if org mode is pre installed on OS X or not.

Yes, but it's /very/ old:

: GNU Emacs 22.1.1 (mac-apple-darwin) of 2016-10-14 on osx314.apple.com
: Org-mode version 4.67c

It's trivial to install Emacs + Org mode on OS X though. You can get a DMG
here, for example: https://emacsformacosx.com 

Stig



Re: [O] [RFC] Change visibility for bracket links

2016-10-21 Thread Stig Brautaset
Clément Pit--Claudel  writes:

> On 2016-10-13 08:30, Nicolas Goaziou wrote:
>> I understand what `prettify-symbols-mode' is. My real problem is
>> understanding how it can help with links in Org. In particular, I'd like
>> to see it, or any other mechanism, turn
>> 
>>   [[http://orgmode.org][Org mode]]
>> 
>> displayed as
>> 
>>   Org mode
>> 
>> into
>> 
>>   [Org mode]
>> 
>> when point is near _any_ of the boundaries and doesn't trigger anything
>> on anything not related to an Org link.
>> 
>> I don't know if that would be sufficient to make it useful, but it needs
>> to be as subtle as possible. We already have a not-so-subtle solution
>> with visible square brackets.
>
> Hey Nicolas,
>
> Something like this?
>
> (defvar-local org-show-link--beg nil)
> (defvar-local org-show-link--end nil)
>
> (defun org-show-link--reveal-at-point ( _)
>   "Possibly reveal link markup around point."
>   (unless (and org-show-link--beg org-show-link--end)
> (setq org-show-link--beg (make-marker)
>   org-show-link--end (make-marker)))
>   (when (and (marker-position org-show-link--beg)
>  (marker-position org-show-link--end))
> (unless (<= org-show-link--beg (point) org-show-link--end)
>   (save-excursion (font-lock-fontify-region org-show-link--beg 
> org-show-link--end))
>   (set-marker org-show-link--beg nil)
>   (set-marker org-show-link--end nil)))
>   (save-excursion
> (when (org-in-regexp org-bracket-link-regexp 1)
>   (set-marker org-show-link--beg (match-beginning 0))
>   (set-marker org-show-link--end (match-end 0))
>   (with-silent-modifications
> (remove-text-properties (match-beginning 2) (1+ (match-beginning 
> 2)) '(invisible))
> (remove-text-properties (1- (match-end 2)) (match-end 2) 
> '(invisible)
>   (message "%S" org-show-link--end))
>
> (defun org-show-link-setup ()
>   (add-hook 'post-command-hook #'org-show-link--reveal-at-point t t))
>
> (add-hook 'org-mode-hook #'org-show-link-setup)
>
> Running it before opening an Org buffer with links should be enough to
> make it work (links brackets will be hidden until point is next to or
> inside the link). It's a quick draft, of course — there are still
> small issues. But it should give an idea of what my original proposal
> was about.

I love this! I have had problems with editing links at the start of
lines etc, and this seems to solve it. I would love something similar
for *bold* and /italics/ too.

Stig



[O] [PATCH] Clarify documentation for the %\1, .., %\N template expansion

2016-10-18 Thread Stig Brautaset

Hello! I failed to understand this part of the template expansion, and
I'm hoping you will consider this an improvement. I mistook the %\n for
a newline and glossed over the description. I'm hoping this makes it
clearer that it's a sequence of placeholders.

I haven't signed the CLA, but I'm hoping this change is small enough for
that not to be necessary. (Although I don't have a problem with signing
the CLA if you prefer that.)

diff --git a/contrib/orgmanual.org b/contrib/orgmanual.org
index 8b8ae1e..5a7904d 100644
--- a/contrib/orgmanual.org
+++ b/contrib/orgmanual.org
@@ -7060,10 +7060,10 @@ here:
   ~%^{prompt|default|completion2|completion3...}~.  The arrow keys access
   a prompt-specific history.
 
-- %\n ::
+- %\1, %\2, ..., %\N ::
 
-  Insert the text entered at the nth %^{PROMPT}, where ~n~ is
-  a number, starting from 1.
+  Insert the text entered at the Nth %^{PROMPT}, where ~N~ is
+  a number starting from 1.
 
 - %? ::  
 
-- 
2.8.4 (Apple Git-73)





[O] Blogging with Orgmode + Jekyll on GitHub Pages?

2016-10-13 Thread Stig Brautaset
Hi All,

I made a PR to add the https://github.com/eggcaker/jekyll-org plugin to
GitHub Pages' whitelist, allowing people to use Orgmode style posts with
GitHub Pages without checking in generated HTML documents. If this
sounds like something you would be interested in, head over to
https://github.com/github/pages-gem/pull/335 and put in a good word.

Stig



[O] trying to automatically refresh inline images after org-babel-execute:ditaa

2016-10-11 Thread Stig Brautaset
Hello!

I'm trying to automatically update inline ditaa images, by adding this
advice:

,
|   (advice-add 'org-babel-execute:ditaa
|   :after
|   (lambda (a  b)
| (message "my sage advice")
| (org-redisplay-inline-images)))
`

When hitting =C-c C-c= in a =#+begin_src ditaa= block I *do* get my sage
advice printed to *Messages*, but inline images just blinks out of
existence. Is the image overlay removed at a higher level?

Any advice (hah!) welcome.

Stig

-- 
: Stig Brautaset, GNU Emacs 25.1.1, Org-mode version 8.3.6




Re: [O] Misc. questions

2016-10-04 Thread Stig Brautaset
Peter Davis <p...@pfdstudio.com> writes:

> I apologize in advance for the flood of questions, but I'm using org in
> new ways now for creating documentation, and running into a lot of
> issues.
>
> 1) Is there a way to automatically say "yes" to all the "Evaluate code
> block...?" questions 

Yes, I believe so. Try

: M-x customize-variable RET org-export-babel-evaluate RET

> 2) How does the export menu get set? 

I noticed there's a variable to control it, but whether that's the whole
story I don't know. Anyway, try:

: M-x customize-variable RET org-export-backends

I'm afraid I can't help with the remaining questions.

Stig
-- 
: Stig Brautaset, GNU Emacs 25.1.1, Org-mode version 8.3.6




Re: [O] is it possible to reuse a capture template expansion?

2016-10-04 Thread Stig Brautaset
Nicolas Goaziou <m...@nicolasgoaziou.fr> writes:

> Hello,
>
> Stig Brautaset <s...@brautaset.org> writes:
>
>> I've got a capture template where I want to prompt for a string and use
>> it in two places, but I end up being prompted twice. 

[...]

> You can use %1, %2... to reuse the first string, the second one...

Thanks! I now managed to get it to work, but had to add more
backslashes: %\1, %\2 etc, not %1, %2. BTW, the manual[1] actually says
%\\n, so adds _too many_ backslashes :-)

[1] http://orgmode.org/manual/Template-expansion.html#Template-expansion 


Stig

-- 
: Stig Brautaset, GNU Emacs 25.1.1, Org-mode version 8.3.6




[O] is it possible to reuse a capture template expansion?

2016-10-04 Thread Stig Brautaset
 
I've got a capture template where I want to prompt for a string and use
it in two places, but I end up being prompted twice. I want a template
something like the below, and be prompted only once each for Title and
Abstract. Is that possible somehow? Any help appreciated.


: * TODO Write %^{Title} Blog post
: #+begin_html
: ---
: title: %^{Title}
: layout: post
: abstract: %^{Abstract}
: ---
: #+end_html
:
: %^{Abstract}
:
: %?

Stig

-- 
: Stig Brautaset, GNU Emacs 25.1.1, Org-mode version 8.3.6




[O] [ANN] ob-applescript

2016-09-16 Thread Stig Brautaset

I've just made `ob-applescript', a backend to execute AppleScript from
Org Babel source code blocks available on Melpa. It's my first attempt
at making a babel backend, so any comments and criticism welcome. Here
are some things it does support though:

- No arguments, no code – just return a string.

#+BEGIN_SRC applescript
  "Hello World"
#+END_SRC

#+RESULTS:
: Hello World

- You can pass variable to a block:

#+BEGIN_SRC applescript :var subject="World"
  "Hello " & subject
#+END_SRC

#+RESULTS:
: Hello World

- You can use either apples or applescript as the language designation,
  to cater for two competing major modes. This example also shows you
  can do interactive stuff.
  
#+BEGIN_SRC apples
display alert "Danger! The WHAM is overheating!"
#+END_SRC

#+RESULTS:
: button returned:OK

- If the result of the evaluation looks like a table, it’ll become a table:

#+BEGIN_SRC apples
"fi fo
1 2
3 4"
#+END_SRC

#+RESULTS:
| fi | fo |
|  1 |  2 |
|  3 |  4 |

Hope this is useful to someone!

Stig




Re: [O] using rgrep, ag, etc in folded org files?

2016-09-13 Thread Stig Brautaset
Clément Pit--Claudel  writes:

> On 2016-09-12 11:36, Aaron Ecay wrote:
>> (Arguably this hook function should be added to org-mode, if enough
>> people find it useful).
>
> That would be brilliant.

Adding my +1 to this, particularly if that would expand stuff in ediff
merge situations also! 

Stig




Re: [O] Export to pdf when path name has ~

2016-09-01 Thread Stig Brautaset
Stig Brautaset <s...@brautaset.org> writes:

> Nicolas Goaziou <m...@nicolasgoaziou.fr> writes:
>>> Fabulous. I wanted to test it, but even though I think I have the latest
>>> Org I can't get this to work. =M-x org-version= says:
>>>
>>> Org-mode version 8.3.4 (8.3.4-79-gbd4948-elpaplus @
>>> /Users/stig/.emacs.d/elpa/org-plus-contrib-20160606/)
>>
>> The change was introduced in master, whereas you're using stable branch.
>
> Oh right! Thanks for that. Well, I have now installed the master branch
> and confirmed that this fixes my issue. Thanks :-)


When could I hope for this change to reach elpa plus? I would really
like to be able to use Org installed by package.el (as I'm only set up
for development on one machine), but as of yet this change has not made
it in:

Org-mode version 8.3.5 (8.3.5-1-g589e96-elpaplus @ 
/Users/stig/.emacs.d/elpa/org-plus-contrib-20160822/)

Stig




[O] ob-sql: setting :dbhost from a variable

2016-07-06 Thread Stig Brautaset
Hello!

I have an Org document that does several SQL queries against two different
PostgreSQL databases. Currently I set the =:dbhost= header argument for each
source block, like this:
  
#+BEGIN_SRC sql :dbhost db1.example.com
  SELECT 1;
#+END_SRC

#+header: 
#+BEGIN_SRC sql :dbhost db2.example.com
  SELECT 2;
#+END_SRC

... many other queries against both dbs omitted ...

Having the hosts all over my org document is a bit annoying. I would like to
specify them in a property section at header/buffer level, but haven't figured
out how to do this. I would *love* to be able to do something like this:

#+property: header-args :var db1="db1.example.com" db2="db2.example.com"

#+BEGIN_SRC sql :dbhost $db1
  SELECT 1;
#+END_SRC

#+BEGIN_SRC sql :dbhost $db2
  SELECT 2;
#+END_SRC

However, that does not appear to work. I also tried using macros, but this did
not work either:

#+macro: db1 db1.example.com
#+macro: db2 db2.example.com

#+BEGIN_SRC sql :dbhost {{{db1}}}
  SELECT 1;
#+END_SRC

#+BEGIN_SRC sql :dbhost {{{db2}}}
  SELECT 2;
#+END_SRC


I got this error:

: psql: could not translate host name "{{{db1}}}" to address: Name or service 
not known

Finally I tried to do this by using :session, setting the :dbhost only
on the first instance, but did not work either.

Does anyone have any tips for how I can consolidate all my explicit (and
duplicated) :dbhost stanzas?

Stig




Re: [O] Export to pdf when path name has ~

2016-06-10 Thread Stig Brautaset
Nicolas Goaziou  writes:
>> Fabulous. I wanted to test it, but even though I think I have the latest
>> Org I can't get this to work. =M-x org-version= says:
>>
>> Org-mode version 8.3.4 (8.3.4-79-gbd4948-elpaplus @
>> /Users/stig/.emacs.d/elpa/org-plus-contrib-20160606/)
>
> The change was introduced in master, whereas you're using stable branch.

Oh right! Thanks for that. Well, I have now installed the master branch
and confirmed that this fixes my issue. Thanks :-)

Stig




Re: [O] Export to pdf when path name has ~

2016-06-10 Thread Stig Brautaset
Nicolas Goaziou  writes:
>> I also agree that the best way would be to change the meaning of %f.
>
> Done in 3d0ade9. Thank you for the feedback.

Fabulous. I wanted to test it, but even though I think I have the latest
Org I can't get this to work. =M-x org-version= says:

Org-mode version 8.3.4 (8.3.4-79-gbd4948-elpaplus @ 
/Users/stig/.emacs.d/elpa/org-plus-contrib-20160606/)

Stig




Re: [O] Export to pdf when path name has ~

2016-05-26 Thread Stig Brautaset
Nicolas Goaziou <m...@nicolasgoaziou.fr> writes:

> Stig Brautaset <s...@brautaset.org> writes:

[...]

>> pdflatex chockes on the filename:
>>
>> #+begin_example
>> 17:27:25 /tmp> pdflatex "/Users/stig/Library/Mobile 
>> Documents/com~apple~CloudDocs/Org/TODO.tex"
>> This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded 
>> format=pdflatex)
>>  restricted \write18 enabled.
>> entering extended mode
>> ! I can't find file `"/Users/stig/Library/Mobile Documents/com"'.
>>  
>>\protect 
>> <*> "/Users/stig/Library/Mobile Documents/com~
>>   apple~CloudDocs/Org/TODO.tex"
>
> Indeed. It seems pdflatex doesn't like the ~ sign excepted at the
> beginning of the filename. It doesn't seem to be Org related though.

No, it does not seem to be Org related. I thought that at first, but
found it failed in a regular terminal too.

> In any case, I'm wondering if we really need to send the full canonical
> path (as returned by `file-truename') of the tex file to the pdflatex
> process.
>
> For example, we could set `default-directory' to the directory of the
> tex file and provide only relative filename with %f. If needed, %F may
> be used for the full path. I don't think it would introduce
> incompatibilities.
>
> WDYT?

That sounds like it would solve my issue, and is what I was hoping to hear :-)

Stig




[O] populating macros by parsing file name?

2016-05-25 Thread Stig Brautaset
Hello!

Currently I have these three lines at the start of my invoices:

#+BEGIN_EXAMPLE
#+macro: invoice-no 11
#+date: 2016-06-01
#+title: Invoice #{{{invoice-no}}}
#+END_EXAMPLE

However, sometimes I forget to update the invoice number or date when copying
the old invoice. Since I name my invoices in the format =NN_-mm-dd.org=
I'm wondering if there's any way I can automatically populate the =invoice-no=
and date macros by parsing the file name? I found the {{{input-file}}}
macro, but I haven't been able to do anything useful with it.

Any help appreciated!

Stig




[O] Export to pdf when path name has ~

2016-05-24 Thread Stig Brautaset

Hello!

I'm on OS X and use their iCloud Drive to sync Org documents. I save my
documents to =~/Org=, which is a symlink to =~/Library/Mobile
Documents/com~apple~CloudDocs/Org=. This generally work fine, but launching
pdflatex fails. The *Messages* buffer has this to say:

#+BEGIN_EXAMPLE
Saving file /Users/stig/Org/TODO.tex...
Wrote /Users/stig/Org/TODO.tex
Processing LaTeX file ./TODO.tex...
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded 
format=pdflatex)
 restricted \write18 enabled.
entering extended mode
! I can't find file `"/Users/stig/Library/Mobile Documents/com"'.
 
   \protect 
<*> "/Users/stig/Library/Mobile Documents/com~
  apple~CloudDocs/Org/TODO.tex"
(Press Enter to retry, or Control-D to exit)
Please type another input file name
! Emergency stop.
 
   \protect 
<*> "/Users/stig/Library/Mobile Documents/com~
  apple~CloudDocs/Org/TODO.tex"

[...]

!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on .//texput.log.
org-latex-compile: PDF file ./TODO.pdf wasn't produced
#+END_EXAMPLE

However, looking at the directory the =.tex= file is created:

#+begin_example
17:03:45 ~> ls -l ~/Library/Mobile\ Documents/com~apple~CloudDocs/Org/TODO*
-rw-r--r--  1 stig  staff   8080 24 May 16:07 /Users/stig/Library/Mobile 
Documents/com~apple~CloudDocs/Org/TODO.org
-rw-r--r--  1 stig  staff  10870 24 May 17:02 /Users/stig/Library/Mobile 
Documents/com~apple~CloudDocs/Org/TODO.tex
#+end_example

And, indeed, running pdflatex on that file works perfectly fine from the shell:

#+BEGIN_EXAMPLE
17:37:57 /tmp> /Library/TeX/texbin/pdflatex ~/Org/TODO.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded 
format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(/Users/stig/Org/TODO.tex
LaTeX2e <2015/01/01>

[...]

Output written on TODO.pdf (10 pages, 206446 bytes).
Transcript written on TODO.log.
#+END_EXAMPLE


... except if you use the full path (rather than the symlink), in which case
pdflatex chockes on the filename:

#+begin_example
17:27:25 /tmp> pdflatex "/Users/stig/Library/Mobile 
Documents/com~apple~CloudDocs/Org/TODO.tex"
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded 
format=pdflatex)
 restricted \write18 enabled.
entering extended mode
! I can't find file `"/Users/stig/Library/Mobile Documents/com"'.
 
   \protect 
<*> "/Users/stig/Library/Mobile Documents/com~
  apple~CloudDocs/Org/TODO.tex"
(Press Enter to retry, or Control-D to exit)
Please type another input file name: ^D
! Emergency stop.
 
   \protect 
<*> "/Users/stig/Library/Mobile Documents/com~
  apple~CloudDocs/Org/TODO.tex"
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on texput.log.
#+END_EXAMPLE

Any suggestions for making =C-c C-e l p= work? I suppose I could migrate to
use DropBox rather than iCloud Drive, but I would really like to avoid that,
so any suggestions for work-arounds that lets me continue to use iCloud Drive
would be nice :-)

Stig




Re: [O] eval code snippet before tangling config file

2016-05-11 Thread Stig Brautaset
"Charles C. Berry" <ccbe...@ucsd.edu> writes:
> On Wed, 11 May 2016, Stig Brautaset wrote:
>>
>> I'm trying to evaluate a line of shell code and put its output into a
>> snippet that will be tangled to a file. My best attempt so far:

[...]

> Try `<<hostname()>>'.
>
> See (info "(org) Noweb reference syntax")
>
> ... <<code-block-name(optional arguments)>> ...
>
> HTH,

It does indeed! Thank you. I clearly missed that section of the manual.

Stig




[O] eval code snippet before tangling config file

2016-05-11 Thread Stig Brautaset

Hi,

I'm trying to evaluate a line of shell code and put its output into a
snippet that will be tangled to a file. My best attempt so far:

  #+NAME: hostname
  #+BEGIN_SRC sh
hostname -s
  #+END_SRC

  #+BEGIN_SRC conf :tangle /usr/local/etc/leafnode/config :noweb tangle
expire = 20
server = news.gmane.org
initialfetch = 100
hostname = <>.superloopy.io
  #+END_SRC

However the result of that tangle includes the shell snippet in
verbatim: 

  #+RESULTS:
  : expire = 20
  : server = news.gmane.org
  : initialfetch = 100
  : hostname = hostname -s.superloopy.io

I suspect this is because it will be executed in the context of "conf"
mode, which does not really have an execution mode. Syntax highlighting
etc works fine, however. I could change to make a shell script to write
the config, but it's not as nice really.

PS: this is an improvement to my existing setup of Leafnode on OS X, if
anybody's interested:
http://github.com/stig/dot-files/tree/master/Leafnode.org

Stig




Re: [O] How to reorder a footnote list?

2016-04-28 Thread Stig Brautaset

Sharon Kimble  writes:

> [...] I looked at the footnote references *in* the document and found
> that they were all [1] [2] etc. Somehow it had lost 'fn:*' before each
> reference number

Could it be that you at some point did `C-u C-c C-x n'? This removes the
fn: from the footnotes. I have been bitten by doing exactly that in the
past. The manual has more: http://orgmode.org/manual/Footnotes.html 

Stig




Re: [O] feature proposal. Kill and yank columns

2016-04-28 Thread Stig Brautaset
Uwe Brauer  writes:

> Hi
>
> I know that I can delete columns but I miss a function which would
> *kill* a column,  put it in the some ring (or register) and paste it.

Does `org-table-move-column' help, or do you mean to move the column to
a different table?

Stig




Re: [O] State of things: Email with orgmode?

2016-04-26 Thread Stig Brautaset
Eric Abrahamsen  writes:
>>> 1) do I have to load something to have this function? I don't seem to
>>> have it
>>
>> org-mime.el is in org contrib package.  I am not sure how you might be
>> able to get this as it will depend on how you get org in the first
>> place.  Are you using org from git or melpa or from the web site
>> directly?
>
> I'm using Org from Melpa -- how do we get contrib packages in this case?

You need to install Org from their special Elpa:

http://orgmode.org/elpa.html

Stig




Re: [O] how to suppress extra newline between paragraphs in export?

2016-04-19 Thread Stig Brautaset
Nicolas Goaziou  writes:

[...]

>>(paragraph
>> (:begin 1 :end 5 :contents-begin 1 :contents-end 4 :post-blank 1 
>> :post-affiliated 1 :parent #1)
> 
> ^^^
>   
> blank line
>
> [...]
>
>> So there's an extra newline before =fo= that no transpose functions are
>> responsible for, as far as I can see. Is it possible to get at this
>> somehow?
>
> You can set the :post-blank value to 0 using a parse tree filter. See
> for example `org-md-separate-elements'.

Perfect. That seems to be exactly what I'm after.

Stig




[O] how to suppress extra newline between paragraphs in export?

2016-04-18 Thread Stig Brautaset


Hello!

I've got a question I hope you might be able to answer. I'm trying to
add multi-paragraph item support to plain lists to my ox-jira.el
package. c.f. https://github.com/stig/ox-jira.el/issues/17

The issue I have is that I want to replace the blank line between
paragraphs in list items (which in JIRA ends the list and starts a new
paragraph) with the string =\\=. However, even when instrumenting
paragraph to check if its parent is an item (I'm being simplistic here)
there's a blank line I can't get at.

You can see it in an org document as simple as this, actually:

#+BEGIN_EXAMPLE
fi

fo
#+END_EXAMPLE

Then do =M-x pp-eval-expression RET (org-element-parse-buffer) RET=

The output is:

#+BEGIN_EXAMPLE
(org-data nil
  (section
   (:begin 1 :end 7 :contents-begin 1 :contents-end 7 :post-blank 0 
:post-affiliated 1 :parent #0)
   (paragraph
(:begin 1 :end 5 :contents-begin 1 :contents-end 4 :post-blank 1 
:post-affiliated 1 :parent #1)
#("fi\n" 0 3
  (:parent #2)))
   (paragraph
(:begin 5 :end 7 :contents-begin 5 :contents-end 7 :post-blank 0 
:post-affiliated 5 :parent #1)
#("fo" 0 2
  (:parent #2)
#+END_EXAMPLE

However, if you actually generate the output (for ascii, for example) you get:

#+BEGIN_EXAMPLE
fi

fo
#+END_EXAMPLE

So there's an extra newline before =fo= that no transpose functions are
responsible for, as far as I can see. Is it possible to get at this
somehow?

Alternatively, do anyone have suggestions for how to support
multi-paragraph list items?

Stig






[O] ANN: ox-jira -- JIRA Backend for Org Export Engine

2016-04-12 Thread Stig Brautaset

I wrote a simplistic JIRA backend for Org Export so that I can draft
JIRA tickets & comments in Org mode and export to JIRA markup.

Credits: most of this was produce by means of cargo-cult programming,
using ox-latex and ox-ascii as inspiration.

Code:

   https://github.com/stig/ox-jira.el

It is available from melpa:

   M-x package-install RET ox-jira RET


What (sort of) works:

- Internal linebreaks in paragraphs are removed, so that JIRA reflows
  text properly
- Simple text transforms: =code=, *bold*, /emphasis/, _underline_,
  sub^{script}, super^{script}
- Simple lists, both ordered, unordered, and nested
- Checkboxes & statistics cookies
- Tables
- Source code & example blocks
- Fixed-width
- Footnotes

More details in the test cases:

 https://github.com/stig/ox-jira.el/blob/master/test/ox-jira-test.org



A minor plea for help:

I noticed recently that list items with multiple paragraphs does not
work. e.g.

  - fi

fo
  - fa
  - fum

Also, probably by extension, lists with a blank line between items does
not work, e.g.

  - fi

  - fo

  - fa

I first thought I could just hack it by wrapping list item in an
invisible panel, but that does not appear to work for nested lists. Any
ideas / advice for how to deal with this?


Additionaly, [fn:: inline footnotes] does not work. Patches welcome! (I
have no idea where to start.)

Stig