From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Richard Subject: Re: org-element-at-point fails in programming-modes Date: Wed, 20 Aug 2014 14:40:27 +0200 Message-ID: <878umj8hc4.fsf@geodiff-mac3.ulb.ac.be> References: <87zjez9xqc.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XK59i-0002Ki-9l for emacs-orgmode@gnu.org; Wed, 20 Aug 2014 08:38:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XK59a-00034a-0K for emacs-orgmode@gnu.org; Wed, 20 Aug 2014 08:38:22 -0400 Received: from mxin.ulb.ac.be ([164.15.128.112]:3716) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XK59Z-00033Z-Rm for emacs-orgmode@gnu.org; Wed, 20 Aug 2014 08:38:13 -0400 In-Reply-To: <87zjez9xqc.fsf@gmail.com> (Thorsten Jolitz's message of "Wed, 20 Aug 2014 14:00:59 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Thorsten Jolitz Cc: emacs-orgmode@gnu.org > 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") 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. HTH, -- Nico.