From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id EMCDGtr5xF/7QwAA0tVLHw (envelope-from ) for ; Mon, 30 Nov 2020 13:55:38 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id GD9WFtr5xF9dEAAA1q6Kng (envelope-from ) for ; Mon, 30 Nov 2020 13:55:38 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 635829404CC for ; Mon, 30 Nov 2020 13:55:37 +0000 (UTC) Received: from localhost ([::1]:55316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kjjeQ-0003nO-Ng for larch@yhetil.org; Mon, 30 Nov 2020 08:55:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kjjSC-00010V-QH for emacs-orgmode@gnu.org; Mon, 30 Nov 2020 08:42:56 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:36486) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kjjSA-0001GE-1z for emacs-orgmode@gnu.org; Mon, 30 Nov 2020 08:42:56 -0500 Received: by mail-pg1-x544.google.com with SMTP id q3so2369267pgr.3 for ; Mon, 30 Nov 2020 05:42:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=andrew-cmu-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZWK/DaW5omzj0O9/dHy3qAuaX5+Q7Sa+sZZ+ZW5yvtM=; b=uv0Y16Qq47NAz5FiJ12iIcN1A33l8v4WI/Z3x9EIEBlVPjlM4VZ6T1NCczrrw3DxtJ aXdKzlmqi2r0v1Z92sEKvcoW6ayrAjRiU8p3okV0p6lBk3LpiBH2i1J8ImsoI+YflWei wNfpVlCRrh8PZwcFcLjmNAfHNtycYz5BtTFQ2D5BHtjT0XZq4nzSh6y65qsEfvPrON/g Itj1IXgHG2YmtmtJ1v40CdtdvUAzDVsJYMfJdOXPLuSZJVNWK5Cc6egDveg9zkHWpmRH anDYei9yNm1P8/Rnyvmkh8icCOSSWcVcI5tyKAhIrykLeh52oMtngQ8iu72TBVXsnDYj AOYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZWK/DaW5omzj0O9/dHy3qAuaX5+Q7Sa+sZZ+ZW5yvtM=; b=Qph/rzoY/BVjXPXSTEmeyCLET3Eu2Y3IFO/P2hZIWvbbifsyairj8RiHzAbXfoDzia Yo9MV+P7GyrPoiRH80GJKq8TpLbepU0uQYGeDbnrgZMQIg1DMX1bxqKHNSq39dDyT2ya xKTiodlZldJuQrla86u0tJZ01HnuOC7PeUNz1VgdrPh8ELqf+/upGalZvYfso5q/57uJ Z7y3ynJurBTNtSCRFzOYlmh4MADuU5TBPnjLVeiZ6F4ekBgCsM4OMiHMzBMtVVi8hgcd BtuNpVwDbfgVxxx39rwdmB0s5Akk/oh1IEdIEc6cfYOjLF9f6lo6pZLaKiGUsDkRCDYE KIsA== X-Gm-Message-State: AOAM533aZU1u4xHIcoUPQu9wlPankXlHgOLPocKWEpENeTpF6xDA95DZ o+LN5hHxt/2UIQZiQqUAVp164ITVILIxePXdppetksSozLukxQ== X-Google-Smtp-Source: ABdhPJxyAONTAPVoDvH56yr0di6Yh37dHMU4PHasHmgVR5DiM5BKqiwdpHb7MJzGmxVDcU+mX3imUX0RThevY5utOI0= X-Received: by 2002:a63:6c03:: with SMTP id h3mr17684282pgc.293.1606743772032; Mon, 30 Nov 2020 05:42:52 -0800 (PST) MIME-Version: 1.0 References: <87czzvqzs7.fsf@kyleam.com> In-Reply-To: From: John Kitchin Date: Mon, 30 Nov 2020 08:42:41 -0500 Message-ID: Subject: Re: difficulty extracting email address from property field containing gmail link To: Ian Garmaise Content-Type: multipart/alternative; boundary="000000000000c6f27005b5532f16" Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=johnrkitchin@gmail.com; helo=mail-pg1-x544.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.38 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=andrew-cmu-edu.20150623.gappssmtp.com header.s=20150623 header.b=uv0Y16Qq; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=andrew.cmu.edu (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 635829404CC X-Spam-Score: -2.38 X-Migadu-Scanner: ns3122888.ip-94-23-21.eu X-TUID: xyhMjdvbEGZm --000000000000c6f27005b5532f16 Content-Type: text/plain; charset="UTF-8" I think code like this would also work: #+BEGIN_SRC emacs-lisp (let* ((url " https://mail.google.com/mail?view=cm&fs=1&to=duncanxyz@indeedemail.com") (struct (url-generic-parse-url url)) (filename (url-filename struct))) (cadr (assoc "to" (url-parse-query-string filename)))) #+END_SRC John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Mon, Nov 30, 2020 at 7:51 AM Ian Garmaise wrote: > Thanks Kyle, got it to work this way: > > #+BEGIN: propview :cols ((car (s-split " " ITEM)) (s-chop-prefix "gmail:" > (my/extract-email-from-link EMAIL_ADDRESS))) :id "candidates" :match > "testthis" :wrap example > | (car (s-split " " ITEM)) | (s-chop-prefix "gmail:" > (my/extract-email-from-link EMAIL_ADDRESS)) | > > |--------------------------+---------------------------------------------------------------------| > | "Ciara" | "ciaraxxxx@gmail.com" > | > | "Duncan" | "duncanxxxx@indeedemail.com" > | > > Thanks a million! > > Ian > > > On Sun, Nov 29, 2020 at 10:39 PM Kyle Meyer wrote: > >> 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--- >> > > > -- > ===== > Ian Garmaise > Consultant > Phorix Solutions Group > ian.g@phorixsol.com > Toronto cell: 416.432.2251 > NYC: 917.512.9535 > > https://www.linkedin.com/in/igarmaise/ > > http://www.PhorixSol.com > --000000000000c6f27005b5532f16 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I think code like this would also work:

#+BEGIN_SRC emacs-lisp
(let* ((url "https://= mail.google.com/mail?view=3Dcm&fs=3D1&to=3Dduncanxyz@indeedemail.co= m")
=C2=A0 =C2=A0 =C2=A0 =C2=A0(struct (url-generic-parse-url u= rl))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(filename (url-filename struct)))
=C2=A0 (cadr (assoc "to" (url-parse-query-string filename))))#+END_SRC


John

-----------------------------------Professor John Kitchin=C2=A0
Doherty Hall A207F
Department of Chemi= cal Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
41= 2-268-7803


On Mon, Nov 30, 2020 at 7:5= 1 AM Ian Garmaise <ian.g@phorixso= l.com> wrote:
Thanks Kyle, got it to work this way:
=

#+BEGIN: propview :cols ((car (s-split "= " ITEM)) =C2=A0(s-chop-prefix "gmail:" (my/extract-email-fr= om-link EMAIL_ADDRESS))) =C2=A0:id "candidates" :match "test= this" :wrap example
| (car (s-split " " ITEM)) | (s-chop-= prefix "gmail:" (my/extract-email-from-link EMAIL_ADDRESS)) |
= |--------------------------+-----------------------------------------------= ----------------------|
| "Ciara" =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| "ciaraxxxx@gmail.com" =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
| &q= uot;Duncan" =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | = "dunca= nxxxx@indeedemail.com" =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0|

Thanks a million!

Ian


On Sun, Nov 29, 2020 at = 10:39 PM Kyle Meyer <kyle@kyleam.com> wrote:
Ian Garmaise writes:

> This is working well, except for the property used for the email addre= ss.
> Unfortunately, I stored this as a gmail link.=C2=A0 This makes it diff= icult to
> extract the actual email address using org-collector as follows:
>
> #+BEGIN: propview :cols ((car (s-split " " ITEM))=C2=A0 EMAI= L_ADDRESS)=C2=A0 :id
> "candidates" :match "testthis" :wrap example
>
> the result produced looks like this:
>
> | (car (s-split " " ITEM)) | EMAIL_ADDRESS=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|<= br> > |--------------------------+------------------------------------------= ---------------------------------------|
> | "Ciara"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 | [[h= ttps://mail.google.com/mail/?view=3Dcm&fs=3D1&to=3Dciaraxyz@gmail\.= com]]=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
> | "Duncan"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0| [[https://mail.google.com/mail/?view=3Dcm&fs=3D1&to=3Dduncanxyz= @indeedemail\.com]] |
>
> I have looked at several methods that I found on the web to extract th= e
> email address from the link in the property, but haven't yet found= a
> solution that I could get to work.=C2=A0 Still building up my elisp sk= illset,
> 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.=C2=A0 So perhaps
something like this would get you on the right track:

=C2=A0 (require 'subr-x)

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


--8<---------------cut here---------------start------------->8---
#+BEGIN: propview :cols ((car (s-split " " ITEM)) (my/extract-ema= il-from-link EMAIL_ADDRESS)) :id global
| (car (s-split " " ITEM)) | (my/extract-email-from-link EMAIL_AD= DRESS) |
|--------------------------+--------------------------------------------| | "Ciara"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 | "ciar= axyz@gmail.com"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
| "Duncan"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0| "duncanxyz@indeedemail.com"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 |
|--------------------------+--------------------------------------------| |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 |
#+END:

* Ciara
:PROPERTIES:
:EMAIL_ADDRESS: [[h= ttps://mail.google.com/mail/?view=3Dcm&fs=3D1&to=3Dciaraxyz@gmail\.= com]]
:END:

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


--
=3D=3D=3D=3D=3D
Ian Garmaise
Consultant
Phorix Solutions Groupian.g@phorixsol.c= om
Toronto cell: 416.432.2251
NYC: 917.512.9535

https://www.link= edin.com/in/igarmaise/

http://www.PhorixSol.com
--000000000000c6f27005b5532f16--