On Sat, 16 Sep 2017 01:50:41 -0700 (PDT)
vitalije <[email protected]> wrote:

> Done at 41ebaba <http://41ebaba5cc720beefa752649007a9c409c33a5b1>.
> 
> Added support for `@data extract-patterns`.

This is great.  So now I'm wondering how we can extend extract to
handle defs like this:

  // set viewer time to time of selected node
  goTo = () => {
      this.drifterViz.gotoTime(new Date(this.drifterViz.currentNode().gpstime))
  }

i.e. the name I want to use for the node, `goTo`, is on the *second*
line.  Just glanced and the code and see only the first line of the
selection is passed to the pattern matching.... 

Looks like (?ms) in a regex will put re into multi-line dot matches all
mode, I guess just (?m) would be sufficient, so I *think* passing the
whole selection to extractDef() and letting people set (?m) in their
patterns would be sufficient and more importantly backwards compatible?

Thoughts?

Cheers -Terry

> This setting should contain in body regex pattern definitions, one
> per line, which should capture prefered headline in group(1) from the
> first line of extracted text. For example:
> 
> line containing '\s*(?:def|class)\s+(\w+)' (without appostrophe),
> will match python definitions of functions/methods and classes.
> 
> User defined regex patterns are prepended to default list, so even if
> this setting is empty, Leo will extract definitions in: python,
> javascript, clojure, coffeescript.
> 
> Note: if you need groups in pattern, make them with (?: ....) syntax
> so that the headline is captured in group(1). In the example above
> first group that matches 'def' or 'class' keyword is surrounded with
> '(?:' and ')'  in order to skip this group from the output groups and
> let the second group to be captured at index 1. 'extract` command
> relies on this convention that headline should be captured in group
> at index 1. It is also possible to write several regex patterns and
> avoid all other groups except the one that captures headline. For
> example regex from above can be written in two lines like so:
> \s*def\s+(\w+)
> \s*class\s+(\w+)
> 
> Vitalije
> 

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to