* [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat.
@ 2015-06-24 11:43 Dmitri Makarov
0 siblings, 0 replies; 9+ messages in thread
From: Dmitri Makarov @ 2015-06-24 11:43 UTC (permalink / raw)
To: emacs-orgmode
https://github.com/dmakarov/org-mode/commit/b9feb9b3ebd618d0fc8e82dc266d62e8252775ed
git@github.com:dmakarov/org-mode.git
* contrib/lisp/org-mac-link.el: Add new link type "acrobat" to grab
links to documents open in Adobe Acrobat application.
Regards,
Dmitri
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat.
@ 2015-09-09 10:42 Dmitri Makarov
2015-09-09 14:11 ` Alan Schmitt
0 siblings, 1 reply; 9+ messages in thread
From: Dmitri Makarov @ 2015-09-09 10:42 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 114 bytes --]
This is my second attempt to submit a patch that enables grabbing
links from Adobe Acrobat Pro.
Regards,
Dmitri
[-- Attachment #2: patch.diff --]
[-- Type: text/plain, Size: 4034 bytes --]
From b9feb9b3ebd618d0fc8e82dc266d62e8252775ed Mon Sep 17 00:00:00 2001
From: Dmitri Makarov <dmakarov@alumni.stanford.edu>
Date: Wed, 24 Jun 2015 12:22:44 +0200
Subject: [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat.
* contrib/lisp/org-mac-link.el: Add new link type "acrobat" to grab
links to documents open in Adobe Acrobat application.
---
contrib/lisp/org-mac-link.el | 72 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 71 insertions(+), 1 deletion(-)
diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index c991dfa..119de8f 100644
--- a/contrib/lisp/org-mac-link.el
+++ b/contrib/lisp/org-mac-link.el
@@ -165,6 +165,12 @@
:group 'org-mac-link
:type 'boolean)
+(defcustom org-mac-grab-Acrobat-app-p t
+ "Add menu option [A]crobat to grab page links from Acrobat.app."
+ :tag "Grab Acrobat.app page links"
+ :group 'org-mac-link
+ :type 'boolean)
+
(defgroup org-mac-flagged-mail nil
"Options foring linking to flagged Mail.app messages."
:tag "Org Mail.app"
@@ -207,7 +213,8 @@ When done, go grab the link, and insert it at point."
("v" "imperator" org-mac-vimperator-insert-frontmost-url ,org-mac-grab-Firefox+Vimperator-p)
("c" "hrome" org-mac-chrome-insert-frontmost-url ,org-mac-grab-Chrome-app-p)
("t" "ogether" org-mac-together-insert-selected ,org-mac-grab-Together-app-p)
- ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)))
+ ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)
+ ("A" "crobat" org-mac-acrobat-insert-page ,org-mac-grab-Acrobat-app-p)))
(menu-string (make-string 0 ?x))
input)
@@ -571,6 +578,69 @@ The links are of the form <link>::split::<name>."
(interactive)
(insert (org-mac-skim-get-page)))
+;; Handle links from Adobe Acrobat Pro.app
+;;
+;; Original code & idea by Christopher Suckling (org-mac-protocol)
+;;
+;; The URI format is path_to_pdf_file::page_number
+
+(org-add-link-type "acrobat" 'org-mac-acrobat-open)
+
+(defun org-mac-acrobat-open (uri)
+ "Visit page of pdf in Acrobat"
+ (let* ((page (when (string-match "::\\(.+\\)\\'" uri)
+ (match-string 1 uri)))
+ (document (substring uri 0 (match-beginning 0))))
+ (do-applescript
+ (concat
+ "tell application \"Adobe Acrobat Pro\"\n"
+ " activate\n"
+ " set theDoc to \"" document "\"\n"
+ " set thePage to " page "\n"
+ " open theDoc\n"
+ " tell PDF Window 1\n"
+ " goto page thePage\n"
+ " end tell\n"
+ "end tell"))))
+
+;; The applescript returns link in the format
+;; path_to_pdf_file::document_title::page_number::page_label
+
+(defun as-get-acrobat-page-link ()
+ (do-applescript
+ (concat
+ "tell application \"Adobe Acrobat Pro\"\n"
+ " set theDoc to active doc\n"
+ " set theWindow to (PDF Window 1 of theDoc)\n"
+ " set thePath to (file alias of theDoc)\n"
+ " set theTitle to (name of theWindow)\n"
+ " set thePage to (page number of theWindow)\n"
+ " set theLabel to (label text of (page thePage of theWindow))\n"
+ "end tell\n"
+ "set theResult to thePath & \"::\" & theTitle & \"::\" & thePage & \"::\" & theLabel\n"
+ "return theResult as string\n")))
+
+(defun org-mac-acrobat-get-page ()
+ (interactive)
+ (message "Applescript: Getting Acrobat page link...")
+ (let* ((descriptor (as-get-acrobat-page-link))
+ (components (split-string descriptor "::"))
+ (path (car components))
+ (title (nth 1 components))
+ (page (nth 2 components))
+ (label (nth 3 components))
+ (link (concat "acrobat:" path "::" page))
+ (description (concat title ", p." label))
+ (org-link))
+ (when (not (string= link ""))
+ (setq org-link (org-make-link-string link description)))
+ (kill-new org-link)
+ org-link))
+
+(defun org-mac-acrobat-insert-page ()
+ (interactive)
+ (insert (org-mac-acrobat-get-page)))
+
\f
;; Handle links from Microsoft Outlook.app
--
2.5.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat.
2015-09-09 10:42 [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat Dmitri Makarov
@ 2015-09-09 14:11 ` Alan Schmitt
2015-09-09 15:59 ` Dmitri Makarov
0 siblings, 1 reply; 9+ messages in thread
From: Alan Schmitt @ 2015-09-09 14:11 UTC (permalink / raw)
To: Dmitri Makarov; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1248 bytes --]
Hello,
On 2015-09-09 12:42, Dmitri Makarov <dmakarov@alumni.stanford.edu> writes:
> This is my second attempt to submit a patch that enables grabbing
> links from Adobe Acrobat Pro.
I do not have Acrobat to test, but I have a small comment.
> +(defun org-mac-acrobat-get-page ()
> + (interactive)
> + (message "Applescript: Getting Acrobat page link...")
> + (let* ((descriptor (as-get-acrobat-page-link))
> + (components (split-string descriptor "::"))
> + (path (car components))
> + (title (nth 1 components))
> + (page (nth 2 components))
> + (label (nth 3 components))
> + (link (concat "acrobat:" path "::" page))
> + (description (concat title ", p." label))
> + (org-link))
> + (when (not (string= link ""))
> + (setq org-link (org-make-link-string link description)))
> + (kill-new org-link)
> + org-link))
Could you reuse `org-mac-paste-applescript-links' for this? For that,
you need to add the "acrobat:" and the ", p." bits in the AppleScript
(as is done for Skim).
Best,
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] 9+ messages in thread
* Re: [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat.
2015-09-09 14:11 ` Alan Schmitt
@ 2015-09-09 15:59 ` Dmitri Makarov
2015-09-10 9:28 ` Alan Schmitt
0 siblings, 1 reply; 9+ messages in thread
From: Dmitri Makarov @ 2015-09-09 15:59 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1478 bytes --]
This is refactored patch that uses org-mac-paste-applescript-links
Regards,
Dmitri
On Wed, Sep 9, 2015 at 4:11 PM, Alan Schmitt
<alan.schmitt@polytechnique.org> wrote:
> Hello,
>
> On 2015-09-09 12:42, Dmitri Makarov <dmakarov@alumni.stanford.edu> writes:
>
>> This is my second attempt to submit a patch that enables grabbing
>> links from Adobe Acrobat Pro.
>
> I do not have Acrobat to test, but I have a small comment.
>
>> +(defun org-mac-acrobat-get-page ()
>> + (interactive)
>> + (message "Applescript: Getting Acrobat page link...")
>> + (let* ((descriptor (as-get-acrobat-page-link))
>> + (components (split-string descriptor "::"))
>> + (path (car components))
>> + (title (nth 1 components))
>> + (page (nth 2 components))
>> + (label (nth 3 components))
>> + (link (concat "acrobat:" path "::" page))
>> + (description (concat title ", p." label))
>> + (org-link))
>> + (when (not (string= link ""))
>> + (setq org-link (org-make-link-string link description)))
>> + (kill-new org-link)
>> + org-link))
>
> Could you reuse `org-mac-paste-applescript-links' for this? For that,
> you need to add the "acrobat:" and the ", p." bits in the AppleScript
> (as is done for Skim).
>
> Best,
>
> Alan
>
> --
> OpenPGP Key ID : 040D0A3B4ED2E5C7
> Last week athmospheric CO₂ average (Updated September 6, 2015, Mauna Loa Obs.):
> 377.86 ppm
[-- Attachment #2: patch.diff --]
[-- Type: text/plain, Size: 3608 bytes --]
From 6d4fbeeda9bbc7a31c6cbd48a45238f8a3efe54f Mon Sep 17 00:00:00 2001
From: Dmitri Makarov <dmakarov@alumni.stanford.edu>
Date: Wed, 9 Sep 2015 17:24:42 +0200
Subject: [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat.
* contrib/lisp/org-mac-link.el: Add new link type "acrobat" to grab
links to documents open in Adobe Acrobat application.
---
contrib/lisp/org-mac-link.el | 60 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index 5e0f891..c2fb60e 100644
--- a/contrib/lisp/org-mac-link.el
+++ b/contrib/lisp/org-mac-link.el
@@ -169,6 +169,12 @@
:group 'org-mac-link
:type 'boolean)
+(defcustom org-mac-grab-Acrobat-app-p t
+ "Add menu option [A]crobat to grab page links from Acrobat.app."
+ :tag "Grab Acrobat.app page links"
+ :group 'org-mac-link
+ :type 'boolean)
+
(defgroup org-mac-flagged-mail nil
"Options foring linking to flagged Mail.app messages."
:tag "Org Mail.app"
@@ -211,7 +217,8 @@ When done, go grab the link, and insert it at point."
("v" "imperator" org-mac-vimperator-insert-frontmost-url ,org-mac-grab-Firefox+Vimperator-p)
("c" "hrome" org-mac-chrome-insert-frontmost-url ,org-mac-grab-Chrome-app-p)
("t" "ogether" org-mac-together-insert-selected ,org-mac-grab-Together-app-p)
- ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)))
+ ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)
+ ("A" "crobat" org-mac-acrobat-insert-page ,org-mac-grab-Acrobat-app-p)))
(menu-string (make-string 0 ?x))
input)
@@ -543,6 +550,57 @@ The links are of the form <link>::split::<name>."
(interactive)
(insert (org-mac-skim-get-page)))
+;; Handle links from Adobe Acrobat Pro.app
+;;
+;; Original code & idea by Christopher Suckling (org-mac-protocol)
+;;
+;; The URI format is path_to_pdf_file::page_number
+
+(org-add-link-type "acrobat" 'org-mac-acrobat-open)
+
+(defun org-mac-acrobat-open (uri)
+ "Visit page of pdf in Acrobat"
+ (let* ((page (when (string-match "::\\(.+\\)\\'" uri)
+ (match-string 1 uri)))
+ (document (substring uri 0 (match-beginning 0))))
+ (do-applescript
+ (concat
+ "tell application \"Adobe Acrobat Pro\"\n"
+ " activate\n"
+ " set theDoc to \"" document "\"\n"
+ " set thePage to " page "\n"
+ " open theDoc\n"
+ " tell PDF Window 1\n"
+ " goto page thePage\n"
+ " end tell\n"
+ "end tell"))))
+
+;; The applescript returns link in the format
+;; path_to_pdf_file::document_title::page_number::page_label
+
+(defun as-get-acrobat-page-link ()
+ (do-applescript
+ (concat
+ "tell application \"Adobe Acrobat Pro\"\n"
+ " set theDoc to active doc\n"
+ " set theWindow to (PDF Window 1 of theDoc)\n"
+ " set thePath to (file alias of theDoc)\n"
+ " set theTitle to (name of theWindow)\n"
+ " set thePage to (page number of theWindow)\n"
+ " set theLabel to (label text of (page thePage of theWindow))\n"
+ "end tell\n"
+ "set theResult to \"acrobat:\" & thePath & \"::\" & thePage & \"::split::\" & theTitle & \", p.\" & theLabel\n"
+ "return theResult as string\n")))
+
+(defun org-mac-acrobat-get-page ()
+ (interactive)
+ (message "Applescript: Getting Acrobat page link...")
+ (org-mac-paste-applescript-links (as-get-acrobat-page-link)))
+
+(defun org-mac-acrobat-insert-page ()
+ (interactive)
+ (insert (org-mac-acrobat-get-page)))
+
\f
;; Handle links from Microsoft Outlook.app
--
2.5.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat.
2015-09-09 15:59 ` Dmitri Makarov
@ 2015-09-10 9:28 ` Alan Schmitt
2015-09-10 9:37 ` Dmitri Makarov
0 siblings, 1 reply; 9+ messages in thread
From: Alan Schmitt @ 2015-09-10 9:28 UTC (permalink / raw)
To: Dmitri Makarov; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 440 bytes --]
On 2015-09-09 17:59, Dmitri Makarov <dmakarov@alumni.stanford.edu> writes:
> This is refactored patch that uses org-mac-paste-applescript-links
LGTM (with a tiny caveat that I can fix: the first line of the commit
message should not end with a dot). Nicolas, can I push this?
Thanks,
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] 9+ messages in thread
* Re: [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat.
2015-09-10 9:28 ` Alan Schmitt
@ 2015-09-10 9:37 ` Dmitri Makarov
2015-09-10 9:57 ` Nicolas Goaziou
0 siblings, 1 reply; 9+ messages in thread
From: Dmitri Makarov @ 2015-09-10 9:37 UTC (permalink / raw)
To: Alan Schmitt; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 756 bytes --]
Hello Alan,
If you haven't pushed the patch yet, here is attached an updated
patch, with a correction in the commit message, and a minor correction
in one of the comments.
Regards,
Dmitri
On Thu, Sep 10, 2015 at 11:28 AM, Alan Schmitt
<alan.schmitt@polytechnique.org> wrote:
> On 2015-09-09 17:59, Dmitri Makarov <dmakarov@alumni.stanford.edu> writes:
>
>> This is refactored patch that uses org-mac-paste-applescript-links
>
> LGTM (with a tiny caveat that I can fix: the first line of the commit
> message should not end with a dot). Nicolas, can I push this?
>
> Thanks,
>
> Alan
>
> --
> OpenPGP Key ID : 040D0A3B4ED2E5C7
> Last week athmospheric CO₂ average (Updated September 6, 2015, Mauna Loa Obs.):
> 377.86 ppm
[-- Attachment #2: patch.diff --]
[-- Type: text/plain, Size: 3624 bytes --]
From c5c378360e1a0a84f465b7cf9da685ea511d5e34 Mon Sep 17 00:00:00 2001
From: Dmitri Makarov <dmakarov@alumni.stanford.edu>
Date: Wed, 9 Sep 2015 17:24:42 +0200
Subject: [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat
* contrib/lisp/org-mac-link.el: Add new link type "acrobat" to grab
links to documents open in Adobe Acrobat application.
---
contrib/lisp/org-mac-link.el | 60 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index 5e0f891..4e1150e 100644
--- a/contrib/lisp/org-mac-link.el
+++ b/contrib/lisp/org-mac-link.el
@@ -169,6 +169,12 @@
:group 'org-mac-link
:type 'boolean)
+(defcustom org-mac-grab-Acrobat-app-p t
+ "Add menu option [A]crobat to grab page links from Acrobat.app."
+ :tag "Grab Acrobat.app page links"
+ :group 'org-mac-link
+ :type 'boolean)
+
(defgroup org-mac-flagged-mail nil
"Options foring linking to flagged Mail.app messages."
:tag "Org Mail.app"
@@ -211,7 +217,8 @@ When done, go grab the link, and insert it at point."
("v" "imperator" org-mac-vimperator-insert-frontmost-url ,org-mac-grab-Firefox+Vimperator-p)
("c" "hrome" org-mac-chrome-insert-frontmost-url ,org-mac-grab-Chrome-app-p)
("t" "ogether" org-mac-together-insert-selected ,org-mac-grab-Together-app-p)
- ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)))
+ ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)
+ ("A" "crobat" org-mac-acrobat-insert-page ,org-mac-grab-Acrobat-app-p)))
(menu-string (make-string 0 ?x))
input)
@@ -543,6 +550,57 @@ The links are of the form <link>::split::<name>."
(interactive)
(insert (org-mac-skim-get-page)))
+;; Handle links from Adobe Acrobat Pro.app
+;;
+;; Original code & idea by Christopher Suckling (org-mac-protocol)
+;;
+;; The URI format is path_to_pdf_file::page_number
+
+(org-add-link-type "acrobat" 'org-mac-acrobat-open)
+
+(defun org-mac-acrobat-open (uri)
+ "Visit page of pdf in Acrobat"
+ (let* ((page (when (string-match "::\\(.+\\)\\'" uri)
+ (match-string 1 uri)))
+ (document (substring uri 0 (match-beginning 0))))
+ (do-applescript
+ (concat
+ "tell application \"Adobe Acrobat Pro\"\n"
+ " activate\n"
+ " set theDoc to \"" document "\"\n"
+ " set thePage to " page "\n"
+ " open theDoc\n"
+ " tell PDF Window 1\n"
+ " goto page thePage\n"
+ " end tell\n"
+ "end tell"))))
+
+;; The applescript returns link in the format
+;; "adobe:path_to_pdf_file::page_number::split::document_title, p.page_label"
+
+(defun as-get-acrobat-page-link ()
+ (do-applescript
+ (concat
+ "tell application \"Adobe Acrobat Pro\"\n"
+ " set theDoc to active doc\n"
+ " set theWindow to (PDF Window 1 of theDoc)\n"
+ " set thePath to (file alias of theDoc)\n"
+ " set theTitle to (name of theWindow)\n"
+ " set thePage to (page number of theWindow)\n"
+ " set theLabel to (label text of (page thePage of theWindow))\n"
+ "end tell\n"
+ "set theResult to \"acrobat:\" & thePath & \"::\" & thePage & \"::split::\" & theTitle & \", p.\" & theLabel\n"
+ "return theResult as string\n")))
+
+(defun org-mac-acrobat-get-page ()
+ (interactive)
+ (message "Applescript: Getting Acrobat page link...")
+ (org-mac-paste-applescript-links (as-get-acrobat-page-link)))
+
+(defun org-mac-acrobat-insert-page ()
+ (interactive)
+ (insert (org-mac-acrobat-get-page)))
+
\f
;; Handle links from Microsoft Outlook.app
--
2.5.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat.
2015-09-10 9:37 ` Dmitri Makarov
@ 2015-09-10 9:57 ` Nicolas Goaziou
2015-09-10 10:26 ` Dmitri Makarov
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2015-09-10 9:57 UTC (permalink / raw)
To: Dmitri Makarov; +Cc: Alan Schmitt, emacs-orgmode
Hello,
Dmitri Makarov <dmakarov@alumni.stanford.edu> writes:
> If you haven't pushed the patch yet, here is attached an updated
> patch, with a correction in the commit message, and a minor correction
> in one of the comments.
Thank you. Some comments follow.
> > On Thu, Sep 10, 2015 at 11:28 AM, Alan Schmitt <alan.schmitt@polytechnique.org> wrote:
>> LGTM (with a tiny caveat that I can fix: the first line of the commit
>> message should not end with a dot). Nicolas, can I push this?
Sure. However, it would be nice to fix the two minor issues below.
> From: Dmitri Makarov <dmakarov@alumni.stanford.edu>
> Date: Wed, 9 Sep 2015 17:24:42 +0200
> Subject: [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat
>
> * contrib/lisp/org-mac-link.el: Add new link type "acrobat" to grab
> links to documents open in Adobe Acrobat application.
You need to mention new functions and variables in the commit message.
> +(defun as-get-acrobat-page-link ()
Wrong namespace. It should be prefixed with "org-mac-".
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat.
2015-09-10 9:57 ` Nicolas Goaziou
@ 2015-09-10 10:26 ` Dmitri Makarov
2015-09-10 11:16 ` Alan Schmitt
0 siblings, 1 reply; 9+ messages in thread
From: Dmitri Makarov @ 2015-09-10 10:26 UTC (permalink / raw)
To: Dmitri Makarov, Alan Schmitt, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1312 bytes --]
Attached is the patch with requested corrections. I hope now this
small patch is sufficiently well commented.
Regards,
Dmitri
On Thu, Sep 10, 2015 at 11:57 AM, Nicolas Goaziou
<mail@nicolasgoaziou.fr> wrote:
> Hello,
>
> Dmitri Makarov <dmakarov@alumni.stanford.edu> writes:
>
>> If you haven't pushed the patch yet, here is attached an updated
>> patch, with a correction in the commit message, and a minor correction
>> in one of the comments.
>
> Thank you. Some comments follow.
>
>> > On Thu, Sep 10, 2015 at 11:28 AM, Alan Schmitt <alan.schmitt@polytechnique.org> wrote:
>
>>> LGTM (with a tiny caveat that I can fix: the first line of the commit
>>> message should not end with a dot). Nicolas, can I push this?
>
> Sure. However, it would be nice to fix the two minor issues below.
>
>> From: Dmitri Makarov <dmakarov@alumni.stanford.edu>
>> Date: Wed, 9 Sep 2015 17:24:42 +0200
>> Subject: [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat
>>
>> * contrib/lisp/org-mac-link.el: Add new link type "acrobat" to grab
>> links to documents open in Adobe Acrobat application.
>
> You need to mention new functions and variables in the commit message.
>
>> +(defun as-get-acrobat-page-link ()
>
> Wrong namespace. It should be prefixed with "org-mac-".
>
>
> Regards,
>
> --
> Nicolas Goaziou
[-- Attachment #2: patch.diff --]
[-- Type: text/plain, Size: 4181 bytes --]
From ada3e9afbcadb6020b8e4949b49afc1243f8278d Mon Sep 17 00:00:00 2001
From: Dmitri Makarov <dmakarov@alumni.stanford.edu>
Date: Wed, 9 Sep 2015 17:24:42 +0200
Subject: [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat
Add new link type "acrobat" to grab links to documents open in Adobe
Acrobat application.
* contrib/lisp/org-mac-link.el (org-mac-acrobat-open): Open Adobe
Acrobat document pointed to by a link.
* contrib/lisp/org-mac-link.el (org-mac-as-get-acrobat-page-link):
Invoke applescript to generate a link to an open and active Adobe
Acrobat document.
* contrib/lisp/org-mac-link.el (org-mac-acrobat-get-page,
org-mac-acrobat-insert-page): methods used when an Adobe Acrobat link
grab request is issued or a link is clicked in an org document.
* contrib/lisp/org-mac-link.el (org-mac-grab-Acrobat-app-p): predicate
that enables grabbing Adobe Acrobat links.
---
contrib/lisp/org-mac-link.el | 60 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index 5e0f891..01556f7 100644
--- a/contrib/lisp/org-mac-link.el
+++ b/contrib/lisp/org-mac-link.el
@@ -169,6 +169,12 @@
:group 'org-mac-link
:type 'boolean)
+(defcustom org-mac-grab-Acrobat-app-p t
+ "Add menu option [A]crobat to grab page links from Acrobat.app."
+ :tag "Grab Acrobat.app page links"
+ :group 'org-mac-link
+ :type 'boolean)
+
(defgroup org-mac-flagged-mail nil
"Options foring linking to flagged Mail.app messages."
:tag "Org Mail.app"
@@ -211,7 +217,8 @@ When done, go grab the link, and insert it at point."
("v" "imperator" org-mac-vimperator-insert-frontmost-url ,org-mac-grab-Firefox+Vimperator-p)
("c" "hrome" org-mac-chrome-insert-frontmost-url ,org-mac-grab-Chrome-app-p)
("t" "ogether" org-mac-together-insert-selected ,org-mac-grab-Together-app-p)
- ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)))
+ ("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)
+ ("A" "crobat" org-mac-acrobat-insert-page ,org-mac-grab-Acrobat-app-p)))
(menu-string (make-string 0 ?x))
input)
@@ -543,6 +550,57 @@ The links are of the form <link>::split::<name>."
(interactive)
(insert (org-mac-skim-get-page)))
+;; Handle links from Adobe Acrobat Pro.app
+;;
+;; Original code & idea by Christopher Suckling (org-mac-protocol)
+;;
+;; The URI format is path_to_pdf_file::page_number
+
+(org-add-link-type "acrobat" 'org-mac-acrobat-open)
+
+(defun org-mac-acrobat-open (uri)
+ "Visit page of pdf in Acrobat"
+ (let* ((page (when (string-match "::\\(.+\\)\\'" uri)
+ (match-string 1 uri)))
+ (document (substring uri 0 (match-beginning 0))))
+ (do-applescript
+ (concat
+ "tell application \"Adobe Acrobat Pro\"\n"
+ " activate\n"
+ " set theDoc to \"" document "\"\n"
+ " set thePage to " page "\n"
+ " open theDoc\n"
+ " tell PDF Window 1\n"
+ " goto page thePage\n"
+ " end tell\n"
+ "end tell"))))
+
+;; The applescript returns link in the format
+;; "adobe:path_to_pdf_file::page_number::split::document_title, p.page_label"
+
+(defun org-mac-as-get-acrobat-page-link ()
+ (do-applescript
+ (concat
+ "tell application \"Adobe Acrobat Pro\"\n"
+ " set theDoc to active doc\n"
+ " set theWindow to (PDF Window 1 of theDoc)\n"
+ " set thePath to (file alias of theDoc)\n"
+ " set theTitle to (name of theWindow)\n"
+ " set thePage to (page number of theWindow)\n"
+ " set theLabel to (label text of (page thePage of theWindow))\n"
+ "end tell\n"
+ "set theResult to \"acrobat:\" & thePath & \"::\" & thePage & \"::split::\" & theTitle & \", p.\" & theLabel\n"
+ "return theResult as string\n")))
+
+(defun org-mac-acrobat-get-page ()
+ (interactive)
+ (message "Applescript: Getting Acrobat page link...")
+ (org-mac-paste-applescript-links (org-mac-as-get-acrobat-page-link)))
+
+(defun org-mac-acrobat-insert-page ()
+ (interactive)
+ (insert (org-mac-acrobat-get-page)))
+
\f
;; Handle links from Microsoft Outlook.app
--
2.5.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat.
2015-09-10 10:26 ` Dmitri Makarov
@ 2015-09-10 11:16 ` Alan Schmitt
0 siblings, 0 replies; 9+ messages in thread
From: Alan Schmitt @ 2015-09-10 11:16 UTC (permalink / raw)
To: Dmitri Makarov; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 370 bytes --]
On 2015-09-10 12:26, Dmitri Makarov <dmakarov@alumni.stanford.edu> writes:
> Attached is the patch with requested corrections. I hope now this
> small patch is sufficiently well commented.
Applied and pushed. Thanks!
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] 9+ messages in thread
end of thread, other threads:[~2015-09-10 11:16 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-09 10:42 [PATCH] org-mac-link.el: Handle links to/from Adobe Acrobat Dmitri Makarov
2015-09-09 14:11 ` Alan Schmitt
2015-09-09 15:59 ` Dmitri Makarov
2015-09-10 9:28 ` Alan Schmitt
2015-09-10 9:37 ` Dmitri Makarov
2015-09-10 9:57 ` Nicolas Goaziou
2015-09-10 10:26 ` Dmitri Makarov
2015-09-10 11:16 ` Alan Schmitt
-- strict thread matches above, loose matches on Subject: below --
2015-06-24 11:43 Dmitri Makarov
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).