emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] org-element-at-point fails in programming-modes


From: Thorsten Jolitz
Subject: Re: [O] org-element-at-point fails in programming-modes
Date: Wed, 20 Aug 2014 15:52:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Nicolas Richard <address@hidden> writes:

>> Although Org functions are of course made only for working in org-mode
>> and its a bit hard to see at first sight how this could be useful, I
>> wonder if the regexps could be made a bit more general to make
>> `org-element-at-point' work in programming modes too (most likely this
>> behaviour is caused by references to character-classes that differ in
>> text-modes and programming-modes)?
>
> The reason is that a newline has the "endcomment" syntax in programming
> modes, but has "whitespace" syntax in text modes. So the regexp
> "\\+BEGIN_\\(\\S-+\\)" (which can be found in org-element.el) matches
> e.g. "+BEGIN_QUOTE\nhallo" instead of just "+BEGIN_QUOTE".
> ("\\S-" means "anything that doesn't have whitespace syntax")

Yes, thats more or less what I expected to be the root cause of the problem.

> You could wrap your code in a (with-syntax-table org-mode-syntax-table
> ...) and cross fingers, or simply do the (org-element-at-point)
> computations in a temporary (org-mode) buffer.

Ok, thanks, that sounds promising. OTOH, is the use of "\\S-" really
mandatory, couldn't a more robust construct be used, either something
like this (untested) regexp:

,----
| "[^[:space:]\\n]+"
`----

or a custom character-class that consists of whitespace plus newline?

-- 
cheers,
Thorsten




reply via email to

[Prev in Thread] Current Thread [Next in Thread]