From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id GOF1NncLi2C/hAAAgWs5BA (envelope-from ) for ; Thu, 29 Apr 2021 21:39:35 +0200 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 cKVdMncLi2DcKQAA1q6Kng (envelope-from ) for ; Thu, 29 Apr 2021 19:39:35 +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 584539E79 for ; Thu, 29 Apr 2021 21:39:35 +0200 (CEST) Received: from localhost ([::1]:37884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcCVa-0002Hl-G5 for larch@yhetil.org; Thu, 29 Apr 2021 15:39:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcCV6-0002Fq-JV for emacs-orgmode@gnu.org; Thu, 29 Apr 2021 15:39:04 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:45011) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lcCV4-0006Uv-K2 for emacs-orgmode@gnu.org; Thu, 29 Apr 2021 15:39:04 -0400 Received: by mail-pj1-x102e.google.com with SMTP id m6-20020a17090a8586b02901507e1acf0fso460636pjn.3 for ; Thu, 29 Apr 2021 12:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:subject:date:in-reply-to:message-id :mime-version:content-transfer-encoding; bh=LBYhVHJbyNA2C2o+nCPEjSBBsl5X4OjF8Ur+UaoRDdg=; b=arB6ioHErbD1xesO5i10jckYncmzvyzs6uACF6M0F4c5sPDhcSxY9RjVH2sJkVsBX4 eK7ffqlIUkxInoPE9GsfLEsPwptPGOs0V7Dnf+f3Z4Nd8YiajWmPJjXflhpXmuA2xTLh /1tIGV+u4iH9oPOkJkx6SuyLyesEla12KpWfBZSX+YhVqy+gr+sEaMtLo1IPEIe+k+Dw 4El1eWlIyHKzn/hLMSVKBX9KCIaZ2A6JY77C0CbTW9V0P+J2jnnTjpWNIuFesK2ag4PZ lN/6WYVBPTKLWIWBKmorGV2LUE4y1yhW4+R3G6oGq6wPxzlm7QKF+B2VhBJSLbgLSomy cnfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:subject:date :in-reply-to:message-id:mime-version:content-transfer-encoding; bh=LBYhVHJbyNA2C2o+nCPEjSBBsl5X4OjF8Ur+UaoRDdg=; b=idL/mRxcl9qJshwVCsGvaM4707cRbILssnvW7EEgnGYH+gF3lSLJJbb39LnvUWJJcm 23AKjmh7f9Owt+q5ixtXuH7O+vnjmYh5kf9ExTai0tkRJeykj9SyfbNSUv7ATTk4gRaE 3dZ9HS49QlfKfu/XOCl1aa5mN78U5UVFXYLkwejWPWfajmQ378t6HvRSYloAqEQp24hk CkhLYJWNTE1MqAlLDCQAteqdjj/8ghmeevybZR8f8KA7SuCLKIxW3TPOoQlflSDjxhuw 4uUlAhiIdIa01ZR1VugLvuaWU5fcTdlusznGlbGgpKmr6B8lbnHv0KvWOXZE5ZlJhAJy 3TEA== X-Gm-Message-State: AOAM53306Xs70b0bWs4wLtGpkge3RDW1G2E3WVF7Q30StKjZ/giTK5oF 8Ob3Pk6Abp1nXjG+eov+uXLqGcozpCw= X-Google-Smtp-Source: ABdhPJznuZrjHvAbgr7F/+gDnBQo9vcYaUZuiLslmJ7/IEuqoaA93wYfUp7SyJIsRBz5teO6SXuA+w== X-Received: by 2002:a17:90a:9e9:: with SMTP id 96mr1519652pjo.130.1619725140760; Thu, 29 Apr 2021 12:39:00 -0700 (PDT) Received: from tim-desktop (203-206-8-119.dyn.iinet.net.au. [203.206.8.119]) by smtp.gmail.com with ESMTPSA id y29sm3430320pfq.29.2021.04.29.12.38.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Apr 2021 12:39:00 -0700 (PDT) References: <2acd022ab06f7f7e2fbe74a6b42d816a@condition-alpha.com> User-agent: mu4e 1.5.12; emacs 28.0.50 From: Tim Cross To: emacs-orgmode@gnu.org Subject: Re: How to use `open` to handle `message:*` links on macOS Date: Fri, 30 Apr 2021 05:37:19 +1000 In-reply-to: Message-ID: <87pmycj2y6.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=theophilusx@gmail.com; helo=mail-pj1-x102e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1619725175; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=LBYhVHJbyNA2C2o+nCPEjSBBsl5X4OjF8Ur+UaoRDdg=; b=UBeYVTAW44GbZznSjUa09FTIXtsStZt20YF8QvxygMnF+ONUgeAV0c8ETFcNdRTMBGUaS9 OgdjY+cWRPL+qBRwzG47px+UupgHoXvFwE2fk+M1QGLeKgaedmDXBWNrrjJlrvJbHIcTiu yOABV+pgSl1EX2MgxGLagnI0KZVF3gnQlkJZPVDaUgxzJa7ybgOqUDvO9jY0csKlYqXQrz I2IpTAP7e5EMgz3ByoVLGC27iWfiw8oCqvbS8UakCrbcDk+Om7oi5R40c/yVhInEAFkxCh DDtwvm1yhGAxG1je0ayh79koN+gQRMaD54qH0Vt6LNa+P01zB6mtEs3YcaEUMA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619725175; a=rsa-sha256; cv=none; b=SFbC07uclgu0OYi8tOoAPoQzH1kIheBr4rHT4srqVsCHqLKhbCWX8Uy9bVkhMf6gEeLeQv mTB/13E9HYzlwS+ln5fYeNRVBkGPouV4HQE7BP7Yfs2Nk6LlJpKGv+8ECeCBmD939ZS4WA Nc7Q4diMFzk1tJUKjkYDRT5cY0FgLGM7np87xdPF7iJhJm4FWUMqZNdbl0GYQlDzUXrNzN 5rnuHcjcifSMDKqBT1m1S8voD0zcuq1NJEGdaQQNBKdQzMqDRxF61tlX8E8EJrTvd6qu1j +6R+PV4E5G4Penbb0QoKuZrWyXieo4UWqgOy2Jmxajs1jFxihcY/wGj7lKTO+Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=arB6ioHE; 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-Spam-Score: -3.16 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=arB6ioHE; dmarc=pass (policy=none) header.from=gmail.com; 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: 584539E79 X-Spam-Score: -3.16 X-Migadu-Scanner: scn0.migadu.com X-TUID: m2thQ0Mv+gJa Tim Visher writes: > Hi Diego and Alexander, > > Thanks for the tips here. I finally got around to trying them out. Here's= what I ended up with and it's working perfectly. > > (defun timvisher-org-link-mac-mail-open-link > (mid _) > (start-process "open-link" nil "open" (format "message://%%3C%s%%3E" > mid))) > > (defun timvisher-org-link-mac-mail-add-message-links > () > (org-link-set-parameters > "message" :follow #'timvisher-org-link-mac-mail-open-link)) > > (eval-after-load 'org > '(timvisher-org-link-mac-mail-add-message-links)) > > Pairing that with my org-capture TODO Current Mail Template is a dream co= me true. :) > > (defun timvisher-org-current-mail-get-selected-message-subject > () > (with-temp-buffer > (call-process > "osascript" nil t nil > "-e" "tell application \"Mail\" to get subject of item 1 of (selecti= on as list)") > (buffer-substring-no-properties (point-min) (- (point-max) 1)))) > > (defun timvisher-org-current-mail-get-selected-message-id > () > (with-temp-buffer > (call-process > "osascript" nil t nil > "-e" "tell application \"Mail\" to get message id of item 1 of (sele= ction as list)") > (browse-url-url-encode-chars > (buffer-substring-no-properties (point-min) (- (point-max) 1)) > "[/]"))) > > (defun timvisher-org-current-mail-get-link-string > () > (let ((subject (timvisher-org-current-mail-get-selected-message-subject= )) > (message-id (timvisher-org-current-mail-get-selected-message-id))) > (org-link-make-string (format "message:%s" message-id) > subject))) > > (defun timvisher-org-current-mail-get-body-quote-template-element > () > (let ((body (setq body (with-temp-buffer > (call-process > "osascript" nil t nil > "-e" "tell application \"Mail\" to get content of item = 1 of (selection as list)") > (buffer-substring-no-properties (point-min) (- (point-ma= x) 1)))))) > (format " > > #+begin_quote > %s > #+end_quote" > (string-join > (seq-reduce > (lambda (acc next) > (if (string=3D next (or (car (last acc)) "")) > acc > (append acc (list next)))) > (mapcar (lambda (string) > (let ((string (string-trim string))) > (if (string=3D "" string) > string > (format " %s" string)))) > (split-string body "\n")) > '()) > "\n")))) > > (setq org-capture-templates > '(=E2=80=A6 > ("twcm" "TODO Work Current Mail" entry > (file+headline "~/Dropbox/todo/work.org" "Inbox") > "* TODO %(timvisher-org-current-mail-get-link-string) > > %U%(timvisher-org-current-mail-get-body-quote-template-element)" :prepe= nd t :immediate-finish t) > =E2=80=A6)) > > Thanks so much! :) I think this would be great content to add to the worg site. Would you be willing to add this, plus a short outline of the issue you needed to resolve so that others might benefit from your experience? --=20 Tim Cross