* [PATCH] Consistently use `org-mac-paste-applescript-links' in org-mac-links
@ 2015-09-08 8:16 Alan Schmitt
2015-09-08 15:50 ` Nicolas Goaziou
0 siblings, 1 reply; 5+ messages in thread
From: Alan Schmitt @ 2015-09-08 8:16 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 437 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-org-mac-link.el-Consistently-use-org-mac-paste-apple.patch --]
[-- Type: text/x-patch, Size: 7872 bytes --]
From 64385400360dea961cf8497db75738d583c177a8 Mon Sep 17 00:00:00 2001
From: Alan Schmitt <alan.schmitt@polytechnique.org>
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.
---
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
--- 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
;;
-;; Copyright (c) 2010-2014 Free Software Foundation, Inc.
+;; Copyright (c) 2010-2015 Free Software Foundation, Inc.
;;
;; Author: Anthony Lander <anthony.lander@gmail.com>
;; John Wiegley <johnw@gnu.org>
@@ -18,6 +18,10 @@
;; Author: Mike McLean <mike.mclean@pobox.com>
;; Add support for Microsoft Outlook for Mac as Org mode links
;;
+;; Version: 1.3
+;; Author: Alan Schmitt <alan.schmitt@polytechnique.org>
+;; Consistently use `org-mac-paste-applescript-links'
+;;
;; 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 <link>::split::<name>."
(defun org-mac-firefox-get-frontmost-url ()
(interactive)
(message "Applescript: Getting Firefox url...")
- (let* ((url-and-title (org-as-mac-firefox-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-firefox-get-frontmost-url)))
(defun org-mac-firefox-insert-frontmost-url ()
(interactive)
@@ -345,15 +341,7 @@ The links are of the form <link>::split::<name>."
(defun org-mac-vimperator-get-frontmost-url ()
(interactive)
(message "Applescript: Getting Vimperator url...")
- (let* ((url-and-title (org-as-mac-vimperator-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-vimperator-get-frontmost-url)))
(defun org-mac-vimperator-insert-frontmost-url ()
(interactive)
@@ -383,15 +371,7 @@ The links are of the form <link>::split::<name>."
(defun org-mac-chrome-get-frontmost-url ()
(interactive)
(message "Applescript: Getting Chrome url...")
- (let* ((url-and-title (org-as-mac-chrome-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-chrome-get-frontmost-url)))
(defun org-mac-chrome-insert-frontmost-url ()
(interactive)
@@ -557,15 +537,7 @@ The links are of the form <link>::split::<name>."
(defun org-mac-skim-get-page ()
(interactive)
(message "Applescript: Getting Skim page link...")
- (let* ((link-and-descr (as-get-skim-page-link))
- (split-link (split-string link-and-descr "::split::"))
- (link (car split-link))
- (description (cadr split-link))
- (org-link))
- (when (not (string= link ""))
- (setq org-link (org-make-link-string link description)))
- (kill-new org-link)
- org-link))
+ (org-mac-paste-applescript-links (as-get-skim-page-link)))
(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...")
- (let* ((as-link-list
- (if (string= select-or-flag "s")
- (org-as-get-selected-outlook-mail)
- (if (string= select-or-flag "f")
- (org-sh-get-flagged-outlook-mail)
- (error "Please select \"s\" or \"f\""))))
- (link-list
- (mapcar
- (lambda (x) (if (string-match "\\`\"\\(.*\\)\"\\'" x) (setq x (match-string 1 x))) x)
- (split-string as-link-list "[\r\n]+")))
- split-link URL description orglink orglink-insert rtn orglink-list)
- (while link-list
- (setq split-link (split-string (pop link-list) "::split::"))
- (setq URL (car split-link))
- (setq description (cadr split-link))
- (when (not (string= URL ""))
- (setq orglink (org-make-link-string URL description))
- (push orglink orglink-list)))
- (setq rtn (mapconcat 'identity orglink-list "\n"))
- (kill-new rtn)
- rtn))
+ (org-mac-paste-applescript-links
+ (if (string= select-or-flag "s")
+ (org-as-get-selected-outlook-mail)
+ (if (string= select-or-flag "f")
+ (org-sh-get-flagged-outlook-mail)
+ (error "Please select \"s\" or \"f\"")))))
(defun org-mac-outlook-message-insert-selected ()
"Insert a link to the messages currently selected in Microsoft Outlook.app.
@@ -734,25 +691,7 @@ selected items in DEVONthink Pro Office.app and make links 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...")
- (let* ((as-link-list (org-as-get-selected-devonthink-item))
- (link-list (if as-link-list
- (mapcar
- (lambda (x) (if (string-match "\\`\"\\(.*\\)\"\\'" x)
- (setq x (match-string 1 x)))
- x)
- (split-string as-link-list "[\r\n]+"))
- nil))
- orglink-list)
- (while link-list
- (let* ((current-item (pop link-list)))
- (message "current item: %s" current-item)
- (when (and current-item (not (string= current-item "")))
- (let* ((split-link (split-string current-item "::split::"))
- (orglink (org-make-link-string
- (url-encode-url (car split-link))
- (cadr split-link))))
- (push orglink orglink-list)))))
- (kill-new (mapconcat 'identity orglink-list "\n"))))
+ (org-mac-paste-applescript-links (org-as-get-selected-devonthink-item)))
(defun org-mac-devonthink-item-insert-selected ()
"Insert a link to the item(s) currently selected in DEVONthink Pro Office.
--
2.5.1
[-- Attachment #1.3: Type: text/plain, Size: 137 bytes --]
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
Last week athmospheric CO₂ average (Updated September 6, 2015, Mauna Loa Obs.):
377.86 ppm
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Consistently use `org-mac-paste-applescript-links' in org-mac-links
2015-09-08 8:16 [PATCH] Consistently use `org-mac-paste-applescript-links' in org-mac-links Alan Schmitt
@ 2015-09-08 15:50 ` Nicolas Goaziou
2015-09-09 8:33 ` Alan Schmitt
0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2015-09-08 15:50 UTC (permalink / raw)
To: Alan Schmitt; +Cc: emacs-orgmode
Hello,
Alan Schmitt <alan.schmitt@polytechnique.org> writes:
> 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.
[...]
>
> * 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'.
IMO, it should be
* contrib/lisp/org-mac-link.el (org-mac-firefox-get-frontmost-url)
(org-mac-vimperator-get-frontmost-url)
(org-mac-chrome-get-frontmost-url)
...
(org-mac-devonthink-get-links): Replace the handling of AppleScript
results code with `org-mac-paste-applescript-links'.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Consistently use `org-mac-paste-applescript-links' in org-mac-links
2015-09-08 15:50 ` Nicolas Goaziou
@ 2015-09-09 8:33 ` Alan Schmitt
2015-09-09 11:38 ` Nicolas Goaziou
0 siblings, 1 reply; 5+ messages in thread
From: Alan Schmitt @ 2015-09-09 8:33 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 1518 bytes --]
On 2015-09-08 17:50, Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> Hello,
>
> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> 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.
>
> [...]
>
>>
>> * 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'.
>
> IMO, it should be
>
> * contrib/lisp/org-mac-link.el (org-mac-firefox-get-frontmost-url)
> (org-mac-vimperator-get-frontmost-url)
> (org-mac-chrome-get-frontmost-url)
> ...
> (org-mac-devonthink-get-links): Replace the handling of AppleScript
> results code with `org-mac-paste-applescript-links'.
Here is a patch with fixed message. I can push it myself if you want.
Best,
Alan
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-org-mac-link.el-Factorize-code.patch --]
[-- Type: text/x-patch, Size: 7378 bytes --]
From 83201ef720c0cc67acf01cc15c2929beaaa5c7f0 Mon Sep 17 00:00:00 2001
From: Alan Schmitt <alan.schmitt@polytechnique.org>
Date: Tue, 8 Sep 2015 10:03:56 +0200
Subject: [PATCH] org-mac-link.el: Factorize code
* contrib/lisp/org-mac-link.el (org-mac-firefox-get-frontmost-url)
(org-mac-vimperator-get-frontmost-url)
(org-mac-chrome-get-frontmost-url)
(org-mac-skim-get-page)
(org-mac-outlook-message-get-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.
---
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
--- 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
;;
-;; Copyright (c) 2010-2014 Free Software Foundation, Inc.
+;; Copyright (c) 2010-2015 Free Software Foundation, Inc.
;;
;; Author: Anthony Lander <anthony.lander@gmail.com>
;; John Wiegley <johnw@gnu.org>
@@ -18,6 +18,10 @@
;; Author: Mike McLean <mike.mclean@pobox.com>
;; Add support for Microsoft Outlook for Mac as Org mode links
;;
+;; Version: 1.3
+;; Author: Alan Schmitt <alan.schmitt@polytechnique.org>
+;; Consistently use `org-mac-paste-applescript-links'
+;;
;; 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 <link>::split::<name>."
(defun org-mac-firefox-get-frontmost-url ()
(interactive)
(message "Applescript: Getting Firefox url...")
- (let* ((url-and-title (org-as-mac-firefox-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-firefox-get-frontmost-url)))
(defun org-mac-firefox-insert-frontmost-url ()
(interactive)
@@ -345,15 +341,7 @@ The links are of the form <link>::split::<name>."
(defun org-mac-vimperator-get-frontmost-url ()
(interactive)
(message "Applescript: Getting Vimperator url...")
- (let* ((url-and-title (org-as-mac-vimperator-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-vimperator-get-frontmost-url)))
(defun org-mac-vimperator-insert-frontmost-url ()
(interactive)
@@ -383,15 +371,7 @@ The links are of the form <link>::split::<name>."
(defun org-mac-chrome-get-frontmost-url ()
(interactive)
(message "Applescript: Getting Chrome url...")
- (let* ((url-and-title (org-as-mac-chrome-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-chrome-get-frontmost-url)))
(defun org-mac-chrome-insert-frontmost-url ()
(interactive)
@@ -557,15 +537,7 @@ The links are of the form <link>::split::<name>."
(defun org-mac-skim-get-page ()
(interactive)
(message "Applescript: Getting Skim page link...")
- (let* ((link-and-descr (as-get-skim-page-link))
- (split-link (split-string link-and-descr "::split::"))
- (link (car split-link))
- (description (cadr split-link))
- (org-link))
- (when (not (string= link ""))
- (setq org-link (org-make-link-string link description)))
- (kill-new org-link)
- org-link))
+ (org-mac-paste-applescript-links (as-get-skim-page-link)))
(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...")
- (let* ((as-link-list
- (if (string= select-or-flag "s")
- (org-as-get-selected-outlook-mail)
- (if (string= select-or-flag "f")
- (org-sh-get-flagged-outlook-mail)
- (error "Please select \"s\" or \"f\""))))
- (link-list
- (mapcar
- (lambda (x) (if (string-match "\\`\"\\(.*\\)\"\\'" x) (setq x (match-string 1 x))) x)
- (split-string as-link-list "[\r\n]+")))
- split-link URL description orglink orglink-insert rtn orglink-list)
- (while link-list
- (setq split-link (split-string (pop link-list) "::split::"))
- (setq URL (car split-link))
- (setq description (cadr split-link))
- (when (not (string= URL ""))
- (setq orglink (org-make-link-string URL description))
- (push orglink orglink-list)))
- (setq rtn (mapconcat 'identity orglink-list "\n"))
- (kill-new rtn)
- rtn))
+ (org-mac-paste-applescript-links
+ (if (string= select-or-flag "s")
+ (org-as-get-selected-outlook-mail)
+ (if (string= select-or-flag "f")
+ (org-sh-get-flagged-outlook-mail)
+ (error "Please select \"s\" or \"f\"")))))
(defun org-mac-outlook-message-insert-selected ()
"Insert a link to the messages currently selected in Microsoft Outlook.app.
@@ -734,25 +691,7 @@ selected items in DEVONthink Pro Office.app and make links 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...")
- (let* ((as-link-list (org-as-get-selected-devonthink-item))
- (link-list (if as-link-list
- (mapcar
- (lambda (x) (if (string-match "\\`\"\\(.*\\)\"\\'" x)
- (setq x (match-string 1 x)))
- x)
- (split-string as-link-list "[\r\n]+"))
- nil))
- orglink-list)
- (while link-list
- (let* ((current-item (pop link-list)))
- (message "current item: %s" current-item)
- (when (and current-item (not (string= current-item "")))
- (let* ((split-link (split-string current-item "::split::"))
- (orglink (org-make-link-string
- (url-encode-url (car split-link))
- (cadr split-link))))
- (push orglink orglink-list)))))
- (kill-new (mapconcat 'identity orglink-list "\n"))))
+ (org-mac-paste-applescript-links (org-as-get-selected-devonthink-item)))
(defun org-mac-devonthink-item-insert-selected ()
"Insert a link to the item(s) currently selected in DEVONthink Pro Office.
--
2.5.1
[-- Attachment #1.3: Type: text/plain, Size: 139 bytes --]
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
Last week athmospheric CO₂ average (Updated September 6, 2015, Mauna Loa Obs.):
377.86 ppm
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Consistently use `org-mac-paste-applescript-links' in org-mac-links
2015-09-09 8:33 ` Alan Schmitt
@ 2015-09-09 11:38 ` Nicolas Goaziou
2015-09-09 11:53 ` Alan Schmitt
0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Goaziou @ 2015-09-09 11:38 UTC (permalink / raw)
To: Alan Schmitt; +Cc: emacs-orgmode
Alan Schmitt <alan.schmitt@polytechnique.org> writes:
> Here is a patch with fixed message. I can push it myself if you want.
Please be my guest. Thank you.
Regards,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Consistently use `org-mac-paste-applescript-links' in org-mac-links
2015-09-09 11:38 ` Nicolas Goaziou
@ 2015-09-09 11:53 ` Alan Schmitt
0 siblings, 0 replies; 5+ messages in thread
From: Alan Schmitt @ 2015-09-09 11:53 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 400 bytes --]
On 2015-09-09 13:38, Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> Here is a patch with fixed message. I can push it myself if you want.
>
> Please be my guest. Thank you.
Pushed.
Alan
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
Last week athmospheric CO₂ average (Updated September 6, 2015, Mauna Loa Obs.):
377.86 ppm
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-09-09 11:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-08 8:16 [PATCH] Consistently use `org-mac-paste-applescript-links' in org-mac-links Alan Schmitt
2015-09-08 15:50 ` Nicolas Goaziou
2015-09-09 8:33 ` Alan Schmitt
2015-09-09 11:38 ` Nicolas Goaziou
2015-09-09 11:53 ` Alan Schmitt
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).