Here's a script that lets you send the body of the selected node to email.
The body needs to contain the text "email: <address>", where "<address>" is
the email address to send the node to. If there is a text selection, it
will be searched for the address. If not, the entire body will be
searched. The script works for both Windows and Linux. It ought to work on
MacOS but I can't try that. The message is handled by the system default
email handler.
I have added this script to my "Local" custom menu defined in
myLeoSettings.leo. Here it is:
@language python
"""Extract email address and launch email program on it.
The address is expected to be prefaced like this:
[optional text first] email: [email protected] [optional text after]
If there is a selection, the selected text is searched for an email
address. Otherwise, the entire body is searched. The system's
default email program is opened.
"""
import re
from sys import platform
import os
from subprocess import call
EMAILre = r'.*email:[ ]*([^@]+@[^@ \t\n]+)' # inline
def open_file(filename):
try:
os.startfile(filename) # Windows only
except Exception as e:
print(e)
opener = "open" if platform == "darwin" else "xdg-open"
call([opener, filename])
# List of line(s) containing cursor or selection
cursor_lines = c.getBodyLines()[1]
line = cursor_lines[0] if cursor_lines else ''
matched = re.match(EMAILre, line)
target = matched[1] if matched else None
if target:
target = 'mailto:' + target.strip()
open_file(target)
else:
g.es('no address found')
--
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 view this discussion visit
https://groups.google.com/d/msgid/leo-editor/24cbb781-b514-4cea-af48-9d06fb266881n%40googlegroups.com.