On Jun 7, 2011, at 8:33 PM, Niels Giesen wrote: > Hi Michael, > > 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). > > 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. > > 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 > > (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 > > Returns a reasonable answer each time I run it. > > (info "(Elisp)Match Data") > > May be of interest to you. > > On Tue, Jun 7, 2011 at 6:23 PM, Michael Brand > <michael.ch.br...@gmail.com> wrote: >> Hi all >> >> 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. >> >> 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? >> >> Michael >> >> > > > > -- > http://pft.github.com > - Carsten