From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniil Frumin Subject: Skim.app support for org-mac-link-grabber.el Date: Sun, 12 May 2013 22:29:13 +0400 Message-ID: <171D50FA-314D-4233-9F7E-AD07D8B1B902@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_923B728F-8D5F-4F46-A8F6-3F4CA766246B" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:38166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ubb1M-0008DQ-Mw for emacs-orgmode@gnu.org; Sun, 12 May 2013 14:29:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ubb1K-0007ec-8f for emacs-orgmode@gnu.org; Sun, 12 May 2013 14:29:20 -0400 Received: from mail-la0-x22f.google.com ([2a00:1450:4010:c03::22f]:63096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ubb1J-0007e1-St for emacs-orgmode@gnu.org; Sun, 12 May 2013 14:29:18 -0400 Received: by mail-la0-f47.google.com with SMTP id fq12so134866lab.6 for ; Sun, 12 May 2013 11:29:16 -0700 (PDT) Received: from [192.168.1.17] (ppp91-77-223-139.pppoe.mtu-net.ru. [91.77.223.139]) by mx.google.com with ESMTPSA id jr19sm4413458lab.0.2013.05.12.11.29.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 12 May 2013 11:29:14 -0700 (PDT) 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@gnu.org --Apple-Mail=_923B728F-8D5F-4F46-A8F6-3F4CA766246B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi, all! I use org-mac-link-grabber.el = almost = every day. However, it lacks support for an app that I'd like to use = together with org-mode.=20 Skim.app is a light and fast PDF reader for Mac OS X with a note-taking = ability. I wrote a little patch for org-mac-link-grabber.el to support = grabbing links to documents. What it does: * Grabs not just the link to file, but a page * Inserts the selected text as a description, if present. Otherwise inserts ", p. " * The shortcut is set to [S] * Defines a new "skim" link type It would be interesting to also add some support for importing notes = from Skim to org. Since Skim.app is not present in clean OS X installs, by default support = for grabbing links from it is disabled. You can enable it by customizing = group `org-mac-link-grabber'. So, maybe it's possible to get this patch into the tree? It's my first = time hacking on org (or even any major elisp extension), so it's = probably that I've messed up somewhere with a commit format or whatnot. Cheers. -- Daniil Frumin --Apple-Mail=_923B728F-8D5F-4F46-A8F6-3F4CA766246B Content-Disposition: attachment; filename=0001-Adding-Skim.app-support-to-org-mac-link-grabber.el.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Adding-Skim.app-support-to-org-mac-link-grabber.el.patch" Content-Transfer-Encoding: quoted-printable =46rom=201326cb78bfcc2111e4fd59789a3960d09cb4a694=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Daniil=20=0ADate:=20Sun,=2012=20= May=202013=2022:11:09=20+0400=0ASubject:=20[PATCH]=20Adding=20Skim.app=20= support=20to=20org-mac-link-grabber.el=0A=0A*=20The=20shortcut=20is=20= set=20to=20[S]=0A=0A*=20Grabs=20not=20just=20the=20link=20to=20file,=20= but=20a=20page=0A=0A*=20Inserts=20the=20selected=20text=20as=20a=20= description,=20if=20present.=20Otherwise=0A=20=20inserts=20",=20= p.=20"=0A=0A*=20Defines=20a=20new=20"skim"=20link=20type=0A---=0A= =20contrib/lisp/org-mac-link-grabber.el=20|=2083=20= ++++++++++++++++++++++++++++++++----=0A=201=20file=20changed,=2075=20= insertions(+),=208=20deletions(-)=0A=0Adiff=20--git=20= a/contrib/lisp/org-mac-link-grabber.el=20= b/contrib/lisp/org-mac-link-grabber.el=0Aindex=200598617..e71fc15=20= 100644=0A---=20a/contrib/lisp/org-mac-link-grabber.el=0A+++=20= b/contrib/lisp/org-mac-link-grabber.el=0A@@=20-128,21=20+128,28=20@@=20= applications=20and=20inserting=20them=20in=20org=20documents"=0A=20=20=20= :group=20'org-mac-link-grabber=0A=20=20=20:type=20'boolean)=0A=20=0A= +(defcustom=20org-mac-grab-Skim-app-p=20t=0A+=20=20"Enable=20menu=20= option=20[S]kim=20to=20grab=20page=20links=20from=20Skim.app"=0A+=20=20= :tag=20"Grab=20Skim.app=20page=20links"=0A+=20=20:group=20= 'org-mac-link-grabber=0A+=20=20:type=20'boolean)=0A+=0A=20=0C=0A=20= (defun=20omlg-grab-link=20()=0A=20=20=20"Prompt=20the=20user=20for=20an=20= application=20to=20grab=20a=20link=20from,=20then=20go=20grab=20the=20= link,=20and=20insert=20it=20at=20point"=0A=20=20=20(interactive)=0A=20=20= =20(let*=20((descriptors=20`(("F"=20"inder"=20= org-mac-finder-insert-selected=20,org-mac-grab-Finder-app-p)=0A-=09=09=09= =09=09=09("m"=20"ail"=20org-mac-message-insert-selected=20= ,org-mac-grab-Mail-app-p)=0A-=09=09=09=09=09=09("a"=20"ddressbook"=20= org-mac-addressbook-insert-selected=20,org-mac-grab-Addressbook-app-p)=0A= -=09=09=09=09=09=09("s"=20"afari"=20org-mac-safari-insert-frontmost-url=20= ,org-mac-grab-Safari-app-p)=0A-=09=09=09=09=09=09("f"=20"irefox"=20= org-mac-firefox-insert-frontmost-url=20,org-mac-grab-Firefox-app-p)=0A-=09= =09=09=09=09=09("v"=20"imperator"=20= org-mac-vimperator-insert-frontmost-url=20= ,org-mac-grab-Firefox+Vimperator-p)=0A-=09=09=09=09=09=09("c"=20"hrome"=20= org-mac-chrome-insert-frontmost-url=20,org-mac-grab-Chrome-app-p)=0A-=09=09= =09=09=09=09("t"=20"ogether"=20org-mac-together-insert-selected=20= ,org-mac-grab-Together-app-p)))=0A+=09=09=09("m"=20"ail"=20= org-mac-message-insert-selected=20,org-mac-grab-Mail-app-p)=0A+=09=09=09= ("a"=20"ddressbook"=20org-mac-addressbook-insert-selected=20= ,org-mac-grab-Addressbook-app-p)=0A+=09=09=09("s"=20"afari"=20= org-mac-safari-insert-frontmost-url=20,org-mac-grab-Safari-app-p)=0A+=09=09= =09("f"=20"irefox"=20org-mac-firefox-insert-frontmost-url=20= ,org-mac-grab-Firefox-app-p)=0A+=09=09=09("v"=20"imperator"=20= org-mac-vimperator-insert-frontmost-url=20= ,org-mac-grab-Firefox+Vimperator-p)=0A+=09=09=09("c"=20"hrome"=20= org-mac-chrome-insert-frontmost-url=20,org-mac-grab-Chrome-app-p)=0A+=09=09= =09("t"=20"ogether"=20org-mac-together-insert-selected=20= ,org-mac-grab-Together-app-p)=0A+=09=09=09("S"=20"kim"=20= org-mac-skim-insert-page=20,org-mac-grab-Skim-app-p)))=0A=20=09=09=20= (menu-string=20(make-string=200=20?x))=0A=20=09=09=20input)=0A-=0A+=20=20= =20=20=0A=20=09;;=20Create=20the=20menu=20string=20for=20the=20keymap=0A=20= =09(mapc=20'(lambda=20(descriptor)=0A=20=09=09=09(when=20(elt=20= descriptor=203)=0A@@=20-460,6=20+467,66=20@@=20applications=20and=20= inserting=20them=20in=20org=20documents"=0A=20=20=20(interactive)=0A=20=20= =20(insert=20(org-mac-addressbook-item-get-selected)))=0A=20=0A+;;=0A+;;=0A= +;;=20Handle=20links=20from=20Skim.app=0A+;;=0A+;;=20A=20rewriting=20of=20= some=20code=20originally=20by=20Christopher=20Suckling=20from=20= org-mac-protocol=0A+=0A+(org-add-link-type=20"skim"=20= 'org-mac-skim-open)=0A+=0A+(defun=20org-mac-skim-open=20(uri)=0A+=20=20= "Visit=20page=20of=20pdf=20in=20Skim"=0A+=20=20(let*=20((page=20(when=20= (string-match=20"::\\(.+\\)\\'"=20uri)=0A+=09=09=20(match-string=201=20= uri)))=0A+=09=20(document=20(substring=20uri=200=20(match-beginning=20= 0))))=0A+=20=20=20=20(do-applescript=0A+=20=20=20=20=20(concat=0A+=20=20=20= =20=20=20"tell=20application=20\"Skim\"\n"=0A+=20=20=20=20=20=20=20=20=20= "activate\n"=0A+=09=20"set=20theDoc=20to=20\""=20document=20"\"\n"=0A+=09= =09=20=20=20=20=20"set=20thePage=20to=20"=20page=20"\n"=0A+=09=20"open=20= theDoc\n"=0A+=09=20"go=20document=201=20to=20page=20thePage=20of=20= document=201\n"=0A+=20=20=20=20=20=20"end=20tell"))))=0A+=0A+=0A+(defun=20= as-get-skim-page-link=20()=0A+=20=20(do-applescript=0A+=20=20=20(concat=0A= +=20=20=20=20"tell=20application=20\"Skim\"\n"=0A+=20=20=20=20=20=20=20= "set=20theDoc=20to=20front=20document\n"=0A+=20=20=20=20=20=20=20"set=20= theTitle=20to=20(name=20of=20theDoc)\n"=0A+=20=20=20=20=20=20=20"set=20= thePath=20to=20(path=20of=20theDoc)\n"=0A+=20=20=20=20=20=20=20"set=20= thePage=20to=20(get=20index=20for=20current=20page=20of=20theDoc)\n"=0A+=20= =20=20=20=20=20=20"set=20theSelection=20to=20selection=20of=20theDoc\n"=0A= +=20=20=20=20=20=20=20"set=20theContent=20to=20contents=20of=20(get=20= text=20for=20theSelection)\n"=0A+=20=20=20=20=20=20=20"if=20theContent=20= is=20missing=20value=20then\n"=0A+=20=20=20=20=20=20=20=20=20=20"set=20= theContent=20to=20theTitle=20&=20\",=20p.=20\"=20&=20thePage\n"=0A+=20=20= =20=20=20=20=20"end=20if\n"=0A+=20=20=20=20=20=20=20"set=20theLink=20to=20= \"skim://\"=20&=20thePath=20&=20\"::\"=20&=20thePage=20&=20"=0A+=20=20=20= =20=20=20=20"\"::split::\"=20&=20theContent\n"=0A+=20=20=20=20"end=20= tell\n"=0A+=20=20=20=20"return=20theLink=20as=20string\n")))=0A+=0A= +(defun=20org-mac-skim-get-page=20()=0A+=20=20(interactive)=0A+=20=20= (message=20"Applescript:=20Getting=20Skim=20page=20link...")=0A+=20=20= (let*=20((url-and-title=20(as-get-skim-page-link))=0A+=20=20=20=20=20=20=20= =20=20(split-link=20(split-string=20url-and-title=20"::split::"))=0A+=20=20= =20=20=20=20=20=20=20(URL=20(car=20split-link))=0A+=20=20=20=20=20=20=20=20= =20(description=20(cadr=20split-link))=0A+=20=20=20=20=20=20=20=20=20= (org-link))=0A+=20=20=20=20(when=20(not=20(string=3D=20URL=20""))=0A+=20=20= =20=20=20=20(setq=20org-link=20(org-make-link-string=20URL=20= description)))=0A+=20=20=20=20(kill-new=20org-link)=0A+=20=20=20=20= org-link))=0A+=0A+(defun=20org-mac-skim-insert-page=20()=0A+=20=20= (interactive)=0A+=20=20(insert=20(org-mac-skim-get-page)))=0A+=0A+=0A=20=0C= =0A=20(provide=20'org-mac-link-grabber)=0A=20=0A--=20=0A1.7.12.4=20= (Apple=20Git-37)=0A=0A= --Apple-Mail=_923B728F-8D5F-4F46-A8F6-3F4CA766246B--