diff options
author | Alan Schmitt <alan.schmitt@polytechnique.org> | 2014-10-15 10:17:34 +0200 |
---|---|---|
committer | Alan Schmitt <alan.schmitt@polytechnique.org> | 2014-10-15 10:22:08 +0200 |
commit | 5963b0345513398fd553c4fd5d11832243b6e49a (patch) | |
tree | 77c0bbfcf56e8dd44c4c5df1d46fee41e02f3be6 | |
parent | ad0d51ff1c34dcbdd8dc408c6cea59863b0e3a28 (diff) | |
download | org-mode-5963b0345513398fd553c4fd5d11832243b6e49a.tar.gz |
org-mac-link.el: Fix malformed Safari links
* contrib/lisp/org-mac-link.el (org-as-mac-safari-get-frontmost-url):
Run only the AppleScript.
(org-mac-safari-get-frontmost-url): reuse
`org-mac-paste-applescript-links' to properly deal with quotes.
-rw-r--r-- | contrib/lisp/org-mac-link.el | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el index e1ab56d..e0636a5 100644 --- a/contrib/lisp/org-mac-link.el +++ b/contrib/lisp/org-mac-link.el @@ -402,28 +402,19 @@ The links are of the form <link>::split::<name>." ;; Grab the frontmost url from Safari. (defun org-as-mac-safari-get-frontmost-url () - (let ((result - (do-applescript - (concat - "tell application \"Safari\"\n" - " set theUrl to URL of document 1\n" - " set theName to the name of the document 1\n" - " return theUrl & \"::split::\" & theName & \"\n\"\n" - "end tell\n")))) - (car (split-string result "[\r\n]+" t)))) + (do-applescript + (concat + "tell application \"Safari\"\n" + " set theUrl to URL of document 1\n" + " set theName to the name of the document 1\n" + " return theUrl & \"::split::\" & theName & \"\n\"\n" + "end tell\n"))) (defun org-mac-safari-get-frontmost-url () (interactive) (message "Applescript: Getting Safari url...") - (let* ((url-and-title (org-as-mac-safari-get-frontmost-url)) - (split-link (split-string url-and-title "::split::")) - (URL (car split-link)) - (description (cadr split-link)) - (org-link)) - (when (not (string= URL "")) - (setq org-link (org-make-link-string URL description))) - (kill-new org-link) - org-link)) + (org-mac-paste-applescript-links + (org-as-mac-safari-get-frontmost-url))) (defun org-mac-safari-insert-frontmost-url () (interactive) |