From 5963b0345513398fd553c4fd5d11832243b6e49a Mon Sep 17 00:00:00 2001 From: Alan Schmitt Date: Wed, 15 Oct 2014 10:17:34 +0200 Subject: [PATCH] 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. --- contrib/lisp/org-mac-link.el | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el index e1ab56dea..e0636a523 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 ::split::." ;; 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) -- 2.11.4.GIT