I upgraded from 4.6.1 to 4.8 and saw this new feature. However, it
behaves quite differently than it used to: It is no more possible, to
comment an url in the body pane, by none of the two variants:

1. If the headline contains "@url http://www.google.at"; and the body
contains "This is my favorite search engine", then Leo tries to use
the body text as an url - and fails.

All my nodes look this way since Leo is able to @url. As a
consequence, all my nodes fail if I do not change them all.

2. If the headline contains "@url Google" and the body contains
"http://www.google.at\n\nThis is my favorite search engine", then Leo
tries to use the body text as an url, instad of just the first line -
and fails. It works, however, if "--" is preceded. But that opens a
new Firefox window, which shouldn't happen with me.

I therefore came up with the following changes in
leoTree::OnIconDoubleClick (I have tagged the changes by leading and
trailing '#fge' tags):

    def OnIconDoubleClick (self,p):

        # Note: "icondclick" hooks handled by vnode callback routine.

        c = self.c
        s = p.h.strip()
        if g.match_word(s,0,"@url"):
#fge            if p.b:
            if p.b and not ("http:" in s or "https:" in s or "ftp:" in
s or "file:" in s): #fge
                #fge# Headline urls have precedence. If the headline
doesn't contain a valid url, the body is taken.
                url = p.b.strip()
            else:
                url = s[4:].strip()
            # g.trace(url,g.callers())
#fge            if url.lstrip().startswith('--'):
            if any( map( lambda x, url=url.lstrip():
url.startswith( x), ("--", "http:", "https:", "ftp:", "file:"))): #fge
                #fge# We alwas take the first line and only the first
line, if the url seems valid.
                # Get the url from the first body line.
                lines = p.b.split('\n')
                url = lines and lines[0] or ''
            else:
                #...@+<< stop the url after any whitespace >>
                #...@+node:ekr.20031218072017.2313: *5* << stop the url
after any whitespace  >>
                # For safety, the URL string should end at the first
whitespace, unless quoted.
                # This logic is also found in the UNL plugin so we
don't have to change the 'unl1' hook.

                url = url.replace('\t',' ')

                # Strip quotes.
                i = -1
                if url and url[0] in ('"',"'"):
                    i = url.find(url[0],1)
                    if i > -1:
                        url = url[1:i]

                if i == -1:
                    # Not quoted or no matching quote.
                    i = url.find(' ')
                    if i > -1:
                        if 0: # No need for a warning.  Assume
everything else is a comment.
                            z_url = url[i:]
                            g.es("ignoring characters after space in
url:",z_url)
                            g.es("use %20 instead of spaces")
                        url = url[:i]
                #...@-<< stop the url after any whitespace >>
            if not g.doHook("@url1",c=c,p=p,v=p,url=url):
                g.handleUrlInUrlNode(url)
            g.doHook("@url2",c=c,p=p,v=p)

        return 'break' # 11/19/06

I've tested the code until I saw that it works for me. What do you
think about it?

Kind regards
F. GEIGER



-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to