emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Ian Garmaise <ian.g@phorixsol.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: difficulty extracting email address from property field containing gmail link
Date: Sun, 29 Nov 2020 22:39:04 -0500	[thread overview]
Message-ID: <87czzvqzs7.fsf@kyleam.com> (raw)
In-Reply-To: <CALWEx6UFJpfE13iNVESXfYz1pOeqe7pQwh+KupkHz2JCjkhWcQ@mail.gmail.com>

Ian Garmaise writes:

> This is working well, except for the property used for the email address.
> Unfortunately, I stored this as a gmail link.  This makes it difficult to
> extract the actual email address using org-collector as follows:
>
> #+BEGIN: propview :cols ((car (s-split " " ITEM))  EMAIL_ADDRESS)  :id
> "candidates" :match "testthis" :wrap example
>
> the result produced looks like this:
> 
> | (car (s-split " " ITEM)) | EMAIL_ADDRESS                                                                   |
> |--------------------------+---------------------------------------------------------------------------------|
> | "Ciara"                  | [[https://mail.google.com/mail/?view=cm&fs=1&to=ciaraxyz@gmail\.com]]             |
> | "Duncan"                 | [[https://mail.google.com/mail/?view=cm&fs=1&to=duncanxyz@indeedemail\.com]] |
>
> I have looked at several methods that I found on the web to extract the
> email address from the link in the property, but haven't yet found a
> solution that I could get to work.  Still building up my elisp skillset,
> would appreciate suggestions.

I've never used org-collector, but quickly trying to wire up a function
to extract the email part of the text you show, I suspect some of the
trouble you're having is that the value comes in as a vector because
org-propview-collect processes it with org-babel-read.  So perhaps
something like this would get you on the right track:

  (require 'subr-x)
  
  (defun my/extract-email-from-link (value)
    (setq value (format "%S" value))
    (when-let ((link (and (string-match org-link-bracket-re value)
                          (org-link-unescape
                           (match-string-no-properties 1 value)))))
      (thread-last
          link
        (replace-regexp-in-string
         (rx string-start (one-or-more not-newline) "to="
             (group (one-or-more not-newline)) string-end)
         "\\1")
        (replace-regexp-in-string (rx "\\.") "."))))


--8<---------------cut here---------------start------------->8---
#+BEGIN: propview :cols ((car (s-split " " ITEM)) (my/extract-email-from-link EMAIL_ADDRESS)) :id global
| (car (s-split " " ITEM)) | (my/extract-email-from-link EMAIL_ADDRESS) |
|--------------------------+--------------------------------------------|
| "Ciara"                  | "ciaraxyz@gmail.com"                       |
| "Duncan"                 | "duncanxyz@indeedemail.com"                |
|--------------------------+--------------------------------------------|
|                          |                                            |
#+END:

* Ciara
:PROPERTIES:
:EMAIL_ADDRESS: [[https://mail.google.com/mail/?view=cm&fs=1&to=ciaraxyz@gmail\.com]]
:END:

* Duncan
:PROPERTIES:
:EMAIL_ADDRESS: [[https://mail.google.com/mail/?view=cm&fs=1&to=duncanxyz@indeedemail\.com]]
:END:
--8<---------------cut here---------------end--------------->8---


  reply	other threads:[~2020-11-30  3:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30  2:18 difficulty extracting email address from property field containing gmail link Ian Garmaise
2020-11-30  3:39 ` Kyle Meyer [this message]
2020-11-30 12:41   ` Ian Garmaise
2020-11-30 13:42     ` John Kitchin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87czzvqzs7.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=ian.g@phorixsol.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).