From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Schmitt Subject: [PATCH] Consistently use `org-mac-paste-applescript-links' in org-mac-links Date: Tue, 08 Sep 2015 10:16:26 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZE4w-0002NV-02 for emacs-orgmode@gnu.org; Tue, 08 Sep 2015 04:16:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZE4s-00014T-OV for emacs-orgmode@gnu.org; Tue, 08 Sep 2015 04:16:33 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:37031) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZE4s-000141-1U for emacs-orgmode@gnu.org; Tue, 08 Sep 2015 04:16:30 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Hello, The attached patch simplifies the code in org-mac-links to always use `org-mac-paste-applescript-links' when parsing the results returned from AppleScript. As a side effect, it gets rid of the bug where the link or description would have an extra quote at the end. I do not know how to write the changelog when the same change happens over many different functions. Please tell me if I need to change the commit message. Alan --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-org-mac-link.el-Consistently-use-org-mac-paste-apple.patch Content-Transfer-Encoding: quoted-printable From=2064385400360dea961cf8497db75738d583c177a8 Mon Sep 17 00:00:00 2001 From: Alan Schmitt Date: Tue, 8 Sep 2015 10:03:56 +0200 Subject: [PATCH] org-mac-link.el: Consistently use `org-mac-paste-applescript-links' * contrib/lisp/org-mac-link.el (org-mac-firefox-get-frontmost-url): Replace the handling of AppleScript results code with `org-mac-paste-applescript-links'. (org-mac-vimperator-get-frontmost-url): Replace the handling of AppleScript results code with `org-mac-paste-applescript-links'. (org-mac-chrome-get-frontmost-url): Replace the handling of AppleScript results code with `org-mac-paste-applescript-links'. (org-mac-skim-get-page): Replace the handling of AppleScript results code with `org-mac-paste-applescript-links'. (org-mac-outlook-message-get-links): Replace the handling of AppleScript results code with `org-mac-paste-applescript-links'. (org-mac-devonthink-get-links): Replace the handling of AppleScript results code with `org-mac-paste-applescript-links'. This fixes some bugs where links would have a dangling quote at the end. =2D-- contrib/lisp/org-mac-link.el | 93 ++++++++--------------------------------= ---- 1 file changed, 16 insertions(+), 77 deletions(-) diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el index c991dfa..5e0f891 100644 =2D-- a/contrib/lisp/org-mac-link.el +++ b/contrib/lisp/org-mac-link.el @@ -1,6 +1,6 @@ ;;; org-mac-link.el --- Insert org-mode links to items selected in various= Mac apps ;; =2D;; Copyright (c) 2010-2014 Free Software Foundation, Inc. +;; Copyright (c) 2010-2015 Free Software Foundation, Inc. ;; ;; Author: Anthony Lander ;; John Wiegley @@ -18,6 +18,10 @@ ;; Author: Mike McLean ;; Add support for Microsoft Outlook for Mac as Org mode links ;; +;; Version: 1.3 +;; Author: Alan Schmitt +;; Consistently use `org-mac-paste-applescript-links' +;;=20 ;; This file is not part of GNU Emacs. ;; ;; This program is free software; you can redistribute it and/or modify @@ -299,15 +303,7 @@ The links are of the form ::split::." (defun org-mac-firefox-get-frontmost-url () (interactive) (message "Applescript: Getting Firefox url...") =2D (let* ((url-and-title (org-as-mac-firefox-get-frontmost-url)) =2D (split-link (split-string url-and-title "::split::")) =2D (URL (car split-link)) =2D (description (cadr split-link)) =2D (org-link)) =2D (when (not (string=3D URL "")) =2D (setq org-link (org-make-link-string URL description))) =2D (kill-new org-link) =2D org-link)) + (org-mac-paste-applescript-links (org-as-mac-firefox-get-frontmost-url))) =20 (defun org-mac-firefox-insert-frontmost-url () (interactive) @@ -345,15 +341,7 @@ The links are of the form ::split::." (defun org-mac-vimperator-get-frontmost-url () (interactive) (message "Applescript: Getting Vimperator url...") =2D (let* ((url-and-title (org-as-mac-vimperator-get-frontmost-url)) =2D (split-link (split-string url-and-title "::split::")) =2D (URL (car split-link)) =2D (description (cadr split-link)) =2D (org-link)) =2D (when (not (string=3D URL "")) =2D (setq org-link (org-make-link-string URL description))) =2D (kill-new org-link) =2D org-link)) + (org-mac-paste-applescript-links (org-as-mac-vimperator-get-frontmost-ur= l))) =20 (defun org-mac-vimperator-insert-frontmost-url () (interactive) @@ -383,15 +371,7 @@ The links are of the form ::split::." (defun org-mac-chrome-get-frontmost-url () (interactive) (message "Applescript: Getting Chrome url...") =2D (let* ((url-and-title (org-as-mac-chrome-get-frontmost-url)) =2D (split-link (split-string url-and-title "::split::")) =2D (URL (car split-link)) =2D (description (cadr split-link)) =2D (org-link)) =2D (when (not (string=3D URL "")) =2D (setq org-link (org-make-link-string URL description))) =2D (kill-new org-link) =2D org-link)) + (org-mac-paste-applescript-links (org-as-mac-chrome-get-frontmost-url))) =20 (defun org-mac-chrome-insert-frontmost-url () (interactive) @@ -557,15 +537,7 @@ The links are of the form ::split::." (defun org-mac-skim-get-page () (interactive) (message "Applescript: Getting Skim page link...") =2D (let* ((link-and-descr (as-get-skim-page-link)) =2D (split-link (split-string link-and-descr "::split::")) =2D (link (car split-link)) =2D (description (cadr split-link)) =2D (org-link)) =2D (when (not (string=3D link "")) =2D (setq org-link (org-make-link-string link description))) =2D (kill-new org-link) =2D org-link)) + (org-mac-paste-applescript-links (as-get-skim-page-link))) =20 (defun org-mac-skim-insert-page () (interactive) @@ -640,27 +612,12 @@ The Org-syntax text will be pushed to the kill ring, = and also returned." (interactive "sLink to (s)elected or (f)lagged messages: ") (setq select-or-flag (or select-or-flag "s")) (message "Org Mac Outlook: searching mailboxes...") =2D (let* ((as-link-list =2D (if (string=3D select-or-flag "s") =2D (org-as-get-selected-outlook-mail) =2D (if (string=3D select-or-flag "f") =2D (org-sh-get-flagged-outlook-mail) =2D (error "Please select \"s\" or \"f\"")))) =2D (link-list =2D (mapcar =2D (lambda (x) (if (string-match "\\`\"\\(.*\\)\"\\'" x) (setq x= (match-string 1 x))) x) =2D (split-string as-link-list "[\r\n]+"))) =2D split-link URL description orglink orglink-insert rtn orglink-l= ist) =2D (while link-list =2D (setq split-link (split-string (pop link-list) "::split::")) =2D (setq URL (car split-link)) =2D (setq description (cadr split-link)) =2D (when (not (string=3D URL "")) =2D (setq orglink (org-make-link-string URL description)) =2D (push orglink orglink-list))) =2D (setq rtn (mapconcat 'identity orglink-list "\n")) =2D (kill-new rtn) =2D rtn)) + (org-mac-paste-applescript-links + (if (string=3D select-or-flag "s") + (org-as-get-selected-outlook-mail) + (if (string=3D select-or-flag "f") + (org-sh-get-flagged-outlook-mail) + (error "Please select \"s\" or \"f\""))))) =20 (defun org-mac-outlook-message-insert-selected () "Insert a link to the messages currently selected in Microsoft Outlook.a= pp. @@ -734,25 +691,7 @@ selected items in DEVONthink Pro Office.app and make l= inks out of it/them. This function will push the Org-syntax text to the kill ring, and also return it." (message "Org Mac DEVONthink: looking for selected items...") =2D (let* ((as-link-list (org-as-get-selected-devonthink-item)) =2D (link-list (if as-link-list =2D (mapcar =2D (lambda (x) (if (string-match "\\`\"\\(.*\\)\"\= \'" x) =2D (setq x (match-string 1 x))) =2D x) =2D (split-string as-link-list "[\r\n]+")) =2D nil)) =2D orglink-list) =2D (while link-list =2D (let* ((current-item (pop link-list))) =2D (message "current item: %s" current-item) =2D (when (and current-item (not (string=3D current-item ""))) =2D (let* ((split-link (split-string current-item "::split::")) =2D (orglink (org-make-link-string =2D (url-encode-url (car split-link)) =2D (cadr split-link)))) =2D (push orglink orglink-list))))) =2D (kill-new (mapconcat 'identity orglink-list "\n")))) + (org-mac-paste-applescript-links (org-as-get-selected-devonthink-item))) =20 (defun org-mac-devonthink-item-insert-selected () "Insert a link to the item(s) currently selected in DEVONthink Pro Offic= e. =2D-=20 2.5.1 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =2D-=20 OpenPGP Key ID : 040D0A3B4ED2E5C7 Last week athmospheric CO=E2=82=82 average (Updated September 6, 2015, Maun= a Loa Obs.): 377.86 ppm --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEbBAEBCgAGBQJV7plaAAoJEAQNCjtO0uXHxS4H+PmZyy4fC93dn1YqkQc4L4aG BBRSv/PUwba9oX+Dzyj7O8d3GF9TqJ5bq3zgKz0J2EUrZeMeY6x2Hylx+/jI/yYi 9IgvXK1caNmI29uW6iddPzxxE7mMj9GJDyZ7sMm3fh304rtqbSAiMBIF42w3yt8J u7vKi+LHl/UZHySBsA7HAQEfiNG/L3fzZmCE8qNFgAhu2VCEEypVjQbHTGxKEjkI EqrbE6lnAo/r0XlumMIdZlSJ4rRin6mxPVAI1My9LOKGz7p9hz69OhC9z12ecbAr U1axbVwc/3e5Avj9mnCAAP4ryZuEa1vXGXlkNWCmEKWoKQM67MWVftcJ93eIVg== =hArw -----END PGP SIGNATURE----- --==-=-=--