Re: [O] Restrict include to some backend

2016-09-12 Thread Clément Pit--Claudel
Sure thing :) Here it is:

(defun ~/filter-begin-only (type)
  "Remove BEGIN_ONLY %s blocks whose %s doesn't equal TYPE.
For those that match, only remove the delimiters."
  (goto-char (point-min))
  (while (re-search-forward " *#\\+BEGIN_ONLY \\([a-z]+\\)\n" nil t)
(let ((begin-block-type (match-string-no-properties 1))
  (begin-from (match-beginning 0))
  (begin-to (match-end 0)))
  (re-search-forward " *#\\+END_ONLY \\([a-z]+\\)\n")
  (let ((end-block-type (match-string-no-properties 1))
(end-from (match-beginning 0))
(end-to (match-end 0)))
(cl-assert (string= begin-block-type end-block-type))
(cond
 ((string= type begin-block-type)
  (delete-region end-from end-to)
  (delete-region begin-from begin-to))
 (t
  (message "Removing %s block" begin-block-type)
  (delete-region begin-from end-to)))

I call this before calling `org-latex-export-to-latex'.  The syntax it accepts 
is a bit weird:

#+BEGIN_ONLY tex
…
#+END_ONLY tex

Please share improvements :)

Cheers,
Clément.

On 2016-09-12 23:10, Kaushal Modi wrote:
> I am looking forward to the BEGIN_ONLY/END_ONLY kind of solution too.
> 
> @Clément Would you please share your draft solution?
> 
> Thanks.
> 
> On Tue, Sep 6, 2016 at 5:39 PM Nicolas Goaziou  > wrote:
> 
> Hello,
> 
> Clément Pit--Claudel  > writes:
> 
> > Do you think so? Wouldn't BEGIN_ONLY … END_ONLY work? It would be 
> similar to BEGIN_EXPORT, right?
> > Or it could even be an option to begin_export?
> 
> -- 
> 
> Kaushal Modi
> 



signature.asc
Description: OpenPGP digital signature


Re: [O] Restrict include to some backend

2016-09-12 Thread Kaushal Modi
I am looking forward to the BEGIN_ONLY/END_ONLY kind of solution too.

@Clément Would you please share your draft solution?

Thanks.

On Tue, Sep 6, 2016 at 5:39 PM Nicolas Goaziou 
wrote:

> Hello,
>
> Clément Pit--Claudel  writes:
>
> > Do you think so? Wouldn't BEGIN_ONLY … END_ONLY work? It would be
> similar to BEGIN_EXPORT, right?
> > Or it could even be an option to begin_export?
>
-- 

Kaushal Modi


Re: [O] [PATCH] org-mime supports emacs24

2016-09-12 Thread chen bin
On Tue, Sep 6, 2016 at 1:57 AM, Nicolas Goaziou  wrote:
> project, tho. It could be useful to add yours to any ELPA and have the

Sure, I will contact marmelade and melpa maintainer asap, for now,
There are also some pull request and bugs I need handle. So it could
take a few days.

-- 
help me, help you.



Re: [O] Trouble with capture template and prompt

2016-09-12 Thread Adam Porter
Bart Bunting  writes:

> The error that is shown in the messages buffer is:
>
> Template key: 
> Capture abort: (error Key sequence C-c ! starts with non-prefix key C-c) 

I think this means that you have tried to specify the capture template
key incorrectly.  It would be helpful if you could show us the elisp
code that defines the template rather than the customize-option screen.
:)  e.g.:

#+BEGIN_SRC elisp
'(("a" "Appointment" entry
   (file+datetree+prompt
(concat org-directory "/calendar.org")
"Calendar")
   "* %^{Description} %T %^G\n\n%U %?" :clock-in t :clock-resume t)
  ("t" "Task" entry
   (file "")
   "* TODO %^{Description}%^G\n\n%U %?" :clock-in t :clock-resume t))
#+END_SRC




Re: [O] capture with iceweasel/firefox -- nothing works

2016-09-12 Thread Adam Porter
Samuel, in case you missed it, you might find this message helpful:

Message-ID: 




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

2016-09-12 Thread Adam Porter
You might find this package useful (it's mine ;):

https://github.com/alphapapa/helm-org-rifle

Or you can install it from MELPA.

I have plans to look into using external tools to find matches someday.
git grep seems like the most promising, but maybe ag or agrep could work
too.  In the meantime, you may find the existing functionality useful.
It wouldn't be hard to customize it slightly to do what you want,
although you might like the feature to open selected subtrees in
indirect buffers.  Please feel free to give feedback on the tracker.  :)




Re: [O] Programmatically handling org files

2016-09-12 Thread Nick Dokos
Thorsten Jolitz  writes:

> ...
>
> If you feel you don't need the whole parse tree, but rather want to act
> locally on the Org element at point, you might want to look at 
> org-dp.el
> ...

Just a note for the benefit of newcomers to the list: Thorsten's
org-dp.el (and many other goodies) are on his github pages:

https://github.com/tj64/org-dp
https://github.com/tj64?tab=repositories

-- 
Nick




Re: [O] Programmatically handling org files

2016-09-12 Thread Joost Kremers

On Mon, Sep 12 2016, John Kitchin wrote:
>> I was wondering if there is some sort of (semi)official API for handling
>> org files programmatically. That's to say, is there a documented way for
>> non-org Emacs packages to manipulate (the contents of) org files?
>
> None that I know of. A non-elisp lib would have to be able to parse the
> org-files.

As you've already realised, I was asking about Elisp code that's not
part of or intended to extend orgmode.

>> Also, I was wondering if there's a way to hook into org-store-link. For
>> a particular major mode, I would like to be able to define what kind of
>> link is created when the user calls `org-store-link`. I looked at the
>> source of `org-store-link` and it looks like the answer is no, but I
>> thought I'd ask anyway. I could of course create the link myself and add
>> it to `org-stored-links` but that feels rather hackish and I suspect
>> will blow up in my face at some point in the future.
>
> You want to add a function to org-store-link-functions. The function
> should check if it is responsible for creating this link (for example by
> looking at the major mode). If not, it must exit and return nil. If yes,
> it should return a non-nil value after a calling `org-store-link-props'
> with a list of properties and values.

Great, thanks! I looked at the source of `org-store-link', but this
wasn't obvious to me. :-/


-- 
Joost Kremers
Life has its moments



Re: [O] Programmatically handling org files

2016-09-12 Thread Joost Kremers

On Mon, Sep 12 2016, John Kitchin wrote:
> indeed! Maybe I misunderstood the OP.
>
> You can find more on the API here:
>
> http://orgmode.org/worg/dev/org-element-api.html
>
> There are also a bunch of functions to do other things, e.g.
>
> (org-todo) (org-cut-subtree) (org-entry-put) and many others
>
> that let you change properties of headings, cut them, etc...
>
> These are documented in the org code. The best way to learn how to use them
> is to reverse engineer how you would make the change you want manually,
> e.g. which keys do you press, then use C-h k on those keys to see what
> commands get run.

Yes, I've been doing that and I've arrived at something that works, just
wasn't sure it was the Right Way™. :-)

-- 
Joost Kremers
Life has its moments



Re: [O] Programmatically handling org files

2016-09-12 Thread Joost Kremers

On Mon, Sep 12 2016, Thorsten Jolitz wrote:
> by "non-org Emacs packages" you mean Emacs packages written in Elisp,
> but not part of Org-mode? 

Yes, exactly. My wording wasn't entirely clear, I admit.

> The org-mode parser converts an Org document into a nested list and
> provides many convenience functions to work on this parse tree. So
> org-element.el (and maybe ox.el too) is the core library for converting
> an Org text document into an Elisp data structure and working with that,

So IIUC org-element.el is mainly for getting the contents of an org
buffer in such a way that a program can work with it, but not really for
modifying the contents of the buffer itself in such a way that it's
still a valid org document, right?

> If you feel you don't need the whole parse tree, but rather want to act
> locally on the Org element at point,

Yes. :-)

> you might want to look at 
> org-dp.el

Cool, I will do that!

> with just two core functions (create and rewire an Org
> element) and a mapping functions (plus quite a few utilities in
> org-dp.el and org-dp-lib.el):

[snip example]

> Using this system, creating or rewiring an Org Element from Elisp
> requires only to define the values of the interpreted parameters, all
> the low level stuff (actually creating and inserting the new/modified
> element in text form) is left to the interpreters (from org-element.el).
>
> You just declare what you want and don't worry anymore how it is done
> (=> dp stands for declarative programming, in this context at least ;-)

That sounds pretty cool, thanks!

-- 
Joost Kremers
Life has its moments



Re: [O] Programmatically handling org files

2016-09-12 Thread John Kitchin
indeed! Maybe I misunderstood the OP.

You can find more on the API here:

http://orgmode.org/worg/dev/org-element-api.html

There are also a bunch of functions to do other things, e.g.

(org-todo) (org-cut-subtree) (org-entry-put) and many others

that let you change properties of headings, cut them, etc...

These are documented in the org code. The best way to learn how to use them
is to reverse engineer how you would make the change you want manually,
e.g. which keys do you press, then use C-h k on those keys to see what
commands get run.

John

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


On Mon, Sep 12, 2016 at 2:21 PM, Thorsten Jolitz  wrote:

> Joost Kremers  writes:
>
> Hi,
>
> > I was wondering if there is some sort of (semi)official API for handling
> > org files programmatically. That's to say, is there a documented way for
> > non-org Emacs packages to manipulate (the contents of) org files?
> >
> > Specifically, I'm wondering about creating and deleting entries (by
> > entries I mean headers with their contents), changing TODO state, moving
> > entries, that sort of thing.
>
> by "non-org Emacs packages" you mean Emacs packages written in Elisp,
> but not part of Org-mode?
>
> The org-mode parser converts an Org document into a nested list and
> provides many convenience functions to work on this parse tree. So
> org-element.el (and maybe ox.el too) is the core library for converting
> an Org text document into an Elisp data structure and working with that,
> have a look at these two functions:
>
> ,
> | 3965:(defun org-element-parse-buffer ( granularity visible-only)
> | 4043:(defun org-element-map
> `
>
> If you feel you don't need the whole parse tree, but rather want to act
> locally on the Org element at point, you might want to look at
> org-dp.el with just two core functions (create and rewire an Org
> element) and a mapping functions (plus quite a few utilities in
> org-dp.el and org-dp-lib.el):
>
> ,
> | 523:(cl-defun org-dp-create
> |(elem-type  contents insert-p affiliated  args)
> | 642:(cl-defun org-dp-rewire
> |(elem-type  contents replace affiliated element 
> args)
> | 766:(defun org-dp-map
> |(fun-with-args rgxp  match-pos backward-search-p beg end
> | silent-p)
> `
>
> Note that I recently added 4 "Tempo" Templates (a bit like Yasnippets)
> to org-dp that make it easy to insert a 'create' or 'rewire' call with
> just those parameters the interpreter uses for the element to be created
> or rewired:
>
> ,
> | M-x tempo-template-org-dp-create
> | M-x tempo-template-org-dp-create-with-comments
> | M-x tempo-template-org-dp-rewire
> | M-x tempo-template-org-dp-rewire-lambda
> `
>
> e.g. calling the third one with elem type "headline" enters this template
>
> #+BEGIN_SRC emacs-lisp
>   (org-dp-rewire 'headline
>   "\n" ;cont
>   t ;ins
>   nil ;aff
>   nil ;elem
>   :level 1 ;1..8
>   :priority nil ;65|66|67
>   :todo-keyword TODO
>   :title ""
>   :tags '( )
>   :commentedp nil
>   :pre-blank 0
>   :footnote-section-p nil
>   )
> #+END_SRC
>
> while for elem type "example block" its only:
>
> #+BEGIN_SRC emacs-lisp
>   (org-dp-rewire 'example-block nil t ;cont ins
>   nil ;aff
>   nil ;elem
>   :switches ""
>   :preserve-indent ""
>   :value ""
>   )
> #+END_SRC
>
> since example-blocks have no content (:value is their content) and only
> 3 parameters that are actually interpreted.
>
> Using this system, creating or rewiring an Org Element from Elisp
> requires only to define the values of the interpreted parameters, all
> the low level stuff (actually creating and inserting the new/modified
> element in text form) is left to the interpreters (from org-element.el).
>
> You just declare what you want and don't worry anymore how it is done
> (=> dp stands for declarative programming, in this context at least ;-)
>
> --
> cheers,
> Thorsten
>
>
>


Re: [O] Programmatically handling org files

2016-09-12 Thread Thorsten Jolitz
Joost Kremers  writes:

Hi,

> I was wondering if there is some sort of (semi)official API for handling
> org files programmatically. That's to say, is there a documented way for
> non-org Emacs packages to manipulate (the contents of) org files?
>
> Specifically, I'm wondering about creating and deleting entries (by
> entries I mean headers with their contents), changing TODO state, moving
> entries, that sort of thing.

by "non-org Emacs packages" you mean Emacs packages written in Elisp,
but not part of Org-mode? 

The org-mode parser converts an Org document into a nested list and
provides many convenience functions to work on this parse tree. So
org-element.el (and maybe ox.el too) is the core library for converting
an Org text document into an Elisp data structure and working with that,
have a look at these two functions:

,
| 3965:(defun org-element-parse-buffer ( granularity visible-only)
| 4043:(defun org-element-map
`

If you feel you don't need the whole parse tree, but rather want to act
locally on the Org element at point, you might want to look at 
org-dp.el with just two core functions (create and rewire an Org
element) and a mapping functions (plus quite a few utilities in
org-dp.el and org-dp-lib.el):

,
| 523:(cl-defun org-dp-create
|(elem-type  contents insert-p affiliated  args)
| 642:(cl-defun org-dp-rewire
|(elem-type  contents replace affiliated element  args)
| 766:(defun org-dp-map
|(fun-with-args rgxp  match-pos backward-search-p beg end
| silent-p)
`

Note that I recently added 4 "Tempo" Templates (a bit like Yasnippets)
to org-dp that make it easy to insert a 'create' or 'rewire' call with
just those parameters the interpreter uses for the element to be created
or rewired:

,
| M-x tempo-template-org-dp-create
| M-x tempo-template-org-dp-create-with-comments
| M-x tempo-template-org-dp-rewire
| M-x tempo-template-org-dp-rewire-lambda
`
 
e.g. calling the third one with elem type "headline" enters this template

#+BEGIN_SRC emacs-lisp
  (org-dp-rewire 'headline
  "\n" ;cont
  t ;ins 
  nil ;aff 
  nil ;elem 
  :level 1 ;1..8
  :priority nil ;65|66|67
  :todo-keyword TODO
  :title ""
  :tags '( )
  :commentedp nil
  :pre-blank 0
  :footnote-section-p nil
  )
#+END_SRC

while for elem type "example block" its only:

#+BEGIN_SRC emacs-lisp
  (org-dp-rewire 'example-block nil t ;cont ins
  nil ;aff 
  nil ;elem 
  :switches ""
  :preserve-indent ""
  :value ""
  )
#+END_SRC

since example-blocks have no content (:value is their content) and only
3 parameters that are actually interpreted.

Using this system, creating or rewiring an Org Element from Elisp
requires only to define the values of the interpreted parameters, all
the low level stuff (actually creating and inserting the new/modified
element in text form) is left to the interpreters (from org-element.el).

You just declare what you want and don't worry anymore how it is done
(=> dp stands for declarative programming, in this context at least ;-)

-- 
cheers,
Thorsten




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

2016-09-12 Thread Clément Pit--Claudel
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.



signature.asc
Description: OpenPGP digital signature


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

2016-09-12 Thread Aaron Ecay
Hi Joakim,

The function org-reveal needs to be run after the search is executed.
If you are using the built-in emacs rgrep (for example), I think you
need to add a function to next-error-hook.  Grep for “add-hook
'occur-mode-find-occurrence-hook” in org.el for inspiration.

(Arguably this hook function should be added to org-mode, if enough
people find it useful).

-- 
Aaron Ecay



Re: [O] Programmatically handling org files

2016-09-12 Thread John Kitchin

Joost Kremers writes:

> Hi all,
>
> I was wondering if there is some sort of (semi)official API for handling
> org files programmatically. That's to say, is there a documented way for
> non-org Emacs packages to manipulate (the contents of) org files?

None that I know of. A non-elisp lib would have to be able to parse the
org-files. The grammar of org-files is documented here:
http://orgmode.org/worg/dev/org-syntax.html

There are libs that can parse org-mode, e.g.
http://orgmode.org/worg/org-tools/, some of them may also be able modify
the files. The elisp org libraries are light years ahead of them though
for what you describe.

> Specifically, I'm wondering about creating and deleting entries (by
> entries I mean headers with their contents), changing TODO state, moving
> entries, that sort of thing.
>
> Also, I was wondering if there's a way to hook into org-store-link. For
> a particular major mode, I would like to be able to define what kind of
> link is created when the user calls `org-store-link`. I looked at the
> source of `org-store-link` and it looks like the answer is no, but I
> thought I'd ask anyway. I could of course create the link myself and add
> it to `org-stored-links` but that feels rather hackish and I suspect
> will blow up in my face at some point in the future.

You want to add a function to org-store-link-functions. The function
should check if it is responsible for creating this link (for example by
looking at the major mode). If not, it must exit and return nil. If yes,
it should return a non-nil value after a calling `org-store-link-props'
with a list of properties and values.

>
> TIA


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



[O] Trouble with capture template and prompt

2016-09-12 Thread Bart Bunting

Hi,

Tried to send this to the list a few days back but don't think it made
it.

Sorry if it is duplicated.

-

Hi,

I have the following capture template defined in the customize
interface.

It used to work ok but now gives a cryptic (well at least to me) error:

I think I've narrowed down the part that is breaking to the title prompt
definition.

Can anyone point out what I'm doing wrong.

I'm running org-mode from master compiled this morning.

This is not a new problem it's been around for a while I just haven't
tried to chase it down.

Here is the custom definition:

INS DEL Choice: Value Menu Template entry:
Keys   : t
Description: todo
Capture Type   : Value Menu Org entry
Target location: Value Menu File:
Filename   : Value Menu Literal: ~/.org/refile.org
Template   : Value Menu String: * TODO %^{Todo} 
%u
%a
%?
Plist:
[ ] Key: :prepend t
[ ] Key: :immediate-finish t
[ ] Key: :jump-to-captured t
[ ] Key: :empty-lines 1
[ ] Key: :empty-lines-before 1
[ ] Key: :empty-lines-after 1
[X] Key: :clock-in t
[ ] Key: :clock-keep t
[X] Key: :clock-resume t
[ ] Key: :unnarrowed t
[ ] Key: :table-line-pos t
[ ] Key: :kill-buffer t
INS

The error that is shown in the messages buffer is:

Template key: 
Capture abort: (error Key sequence C-c ! starts with non-prefix key C-c) 

Any help would be appreciated.

Kind regards
Bart
Kind regards
Bart
-- 

Bart Bunting



[O] Programmatically handling org files

2016-09-12 Thread Joost Kremers
Hi all,

I was wondering if there is some sort of (semi)official API for handling
org files programmatically. That's to say, is there a documented way for
non-org Emacs packages to manipulate (the contents of) org files?

Specifically, I'm wondering about creating and deleting entries (by
entries I mean headers with their contents), changing TODO state, moving
entries, that sort of thing.

Also, I was wondering if there's a way to hook into org-store-link. For
a particular major mode, I would like to be able to define what kind of
link is created when the user calls `org-store-link`. I looked at the
source of `org-store-link` and it looks like the answer is no, but I
thought I'd ask anyway. I could of course create the link myself and add
it to `org-stored-links` but that feels rather hackish and I suspect
will blow up in my face at some point in the future.

TIA


--
Joost Kremers
Life has its moments



Re: [O] org-review is on melpa

2016-09-12 Thread Alan Schmitt
On 2016-09-10 22:12, Karl Voit  writes:

> * Alan Schmitt  wrote:
>> --=-=-=
>> Content-Type: text/plain; charset=utf-8
>> Content-Transfer-Encoding: quoted-printable
>
> Btw, is there a reason that those two lines are not part of the
> header?

I have no idea, I have no modified what message-mode and gnus do in that
regard.

> You might want to add this simple explanation at the top of your
> README.org since it seems to summarize the main feature of your cool
> tool for Org-mode savvy people.

Done. Thanks for the suggestion.

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2015-08: 398.93, 2016-08: 402.25


signature.asc
Description: PGP signature