I have bound mailto: links to the following AppleScript, which simply lets you copy the To: address to the clipboard:

on open location mailtostr
        set rtnstr to display dialog "Approve or change text to be copied:" buttons {"Copy", "Cancel"} ¬
            default answer text 8 thru end of mailtostr default button "Copy" cancel button "Cancel" with title "Mailto.app"
        tell application "Finder" to set the clipboard to text returned of rtnstr
    end try
end open location

How can I change this script to:

  1. Copy the mailto: address to the clipboard without showing the dialog
  2. Activate Terminal (already running)
  3. Activate tab running Emacs (already running)
  4. Run an Emacs function which starts a new email with the To: field filled in. (I suppose this has to happen by AppleScript sending a key sequence which is bound to the mailto function.)

    (defun mailto ()
  5. If Terminal / Emacs is unavailable, show a fallback macOS notification:

    display notification "someone@example.com" with title "E-mail address copied to clipboard"
  • Here is a link to a related thread about activating the Terminal.app: emacs.stackexchange.com/questions/22653/… FYI: emacsclient can receive a lisp argument from the command line, but would require a setup using things like (server-start) in the .emacs/init.el and some people like running a daemon. The applescript above is copyrighted, so it would be a good idea to give credit to the author and a link to the original source. – lawlist Apr 5 '18 at 16:33

You must log in to answer this question.

Browse other questions tagged .