From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: understanding the function outline-level Date: Thu, 9 Jun 2011 09:51:23 +0200 Message-ID: <64F7F67C-4A1E-4DDB-B8F8-FCC6E8AB93B3@gmail.com> References: Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:55952) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QUa1b-0000xS-PE for emacs-orgmode@gnu.org; Thu, 09 Jun 2011 03:51:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QUa1Z-0002jE-DB for emacs-orgmode@gnu.org; Thu, 09 Jun 2011 03:51:31 -0400 Received: from mail-ew0-f41.google.com ([209.85.215.41]:51739) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QUa1Z-0002it-1X for emacs-orgmode@gnu.org; Thu, 09 Jun 2011 03:51:29 -0400 Received: by ewy9 with SMTP id 9so521536ewy.0 for ; Thu, 09 Jun 2011 00:51:27 -0700 (PDT) In-Reply-To: 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: Niels Giesen Cc: Michael Brand , Org Mode On Jun 7, 2011, at 8:33 PM, Niels Giesen wrote: > Hi Michael, >=20 > match data get set by searches. One can inhibit match-data being > cluttered by using the `save-match-data' macro (you should probably do > so when using searches in a lisp program). >=20 > Outline.el seems to make very frequent use of this 'global' data; > instead of passing this data on via function arguments or so, it > depends on this dynamically set data, which makes it very hard to see > who does what. >=20 > Some prodding about led me to believe the searching in > `outline-back-to-heading' is your suspect (but I have not investigated > this further). At least >=20 > (progn > (outline-back-to-heading) > (outline-level)) Or, alternatively, if you are already at the beginning of the headline (and (looking-at outline-regexp) (funcall 'outline-level)) So outline-level needs to just have matched when calling that function. IMPORTANT: Using (funcall 'outline-level) is more general as major modes are = allowed to set their own function for level calculation. In fact, calling = (outline-level) in Org-mode will give the wrong result, because the regexp also matches the space character after the stars, so the level is one less = than the length of the match string. - Carsten >=20 > Returns a reasonable answer each time I run it. >=20 > (info "(Elisp)Match Data") >=20 > May be of interest to you. >=20 > On Tue, Jun 7, 2011 at 6:23 PM, Michael Brand > wrote: >> Hi all >>=20 >> I am on the way of tracking down an (Org?) buglet and now >> outline-level tries to strike me with my lack of experience with >> "Match Data" of Emacs search and I would like to ask for some help to >> understand. >>=20 >> M-: (outline-level) returns a value that I don't understand yet. The >> number does not correspond to the amount of stars and is independent >> of at the beginning of which line the point was before. And when I >> look at the implementation of outline-level I am missing a function >> that initializes the "Match Data". Where is that last search or match >> operation? >>=20 >> Michael >>=20 >>=20 >=20 >=20 >=20 > --=20 > http://pft.github.com >=20 - Carsten