From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniil Frumin Subject: Re: Skim.app support for org-mac-link-grabber.el Date: Tue, 14 May 2013 00:35:46 +0400 Message-ID: <5D9D77F4-F343-45D1-8B06-70550EE83E2B@gmail.com> References: <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=_0FCB9D8F-4EAD-4A36-A17F-F36CB67F3DDD" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:43927) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UbzTO-0002nr-4K for emacs-orgmode@gnu.org; Mon, 13 May 2013 16:35:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UbzTL-0002WC-2X for emacs-orgmode@gnu.org; Mon, 13 May 2013 16:35:54 -0400 Received: from mail-la0-x22b.google.com ([2a00:1450:4010:c03::22b]:41624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UbzTK-0002W1-K3 for emacs-orgmode@gnu.org; Mon, 13 May 2013 16:35:50 -0400 Received: by mail-la0-f43.google.com with SMTP id ea20so6625670lab.30 for ; Mon, 13 May 2013 13:35:48 -0700 (PDT) In-Reply-To: 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: Carsten Dominik Cc: "emacs-orgmode@gnu.org Mode" , anthony.lander@gmail.com --Apple-Mail=_0FCB9D8F-4EAD-4A36-A17F-F36CB67F3DDD Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii So I've been researching this problem and it seems that there is no sane = way to re-select a text.=20 The problem is that `(do-applescript ..)' only interacts with = AppleScript well if the return type of the string is either a number or = a string. If I try to convert the selection object (which is not really = an object but a list of specifiers) it just returns the selected text.=20= There is also `selection bounds' but it only covers rectangle = selections. It's possible to save the selected text and try to `find' it later, but = that won't work well (e.g.: there are several repetitions of the same = text on one page).=20 I've also tried to implement an auto-scrolling to the selected text, but = to no avail. The option that seems to me the most reasonable is to add a highlight = note to the selected text (which is actually possible). What do you = think?=20 For now, the patch to the problem mentioned by Ivan. I have actually fixed a small bug in the code for getting links from = Firefox: Prior to the fix the firefox link grabber won't work correctly if a = cursor has been already positioned in the URL field. The fix works by = adding an additional keystore for selecting all the text in that field. The problem is that I've committed it before committing the stuff that = Ivan told us about, so I am not sure what to do in this case. Thanks -- Daniil --Apple-Mail=_0FCB9D8F-4EAD-4A36-A17F-F36CB67F3DDD Content-Disposition: attachment; filename=0002-Fixing-a-bug-in-as-mac-firefox-get-frontmost-url.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0002-Fixing-a-bug-in-as-mac-firefox-get-frontmost-url.patch" Content-Transfer-Encoding: quoted-printable =46rom=2005982f42efbc27df5db10a6b244ab5dccdd31987=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Daniil=20Frumin=20=0ADate:=20= Mon,=2013=20May=202013=2022:36:50=20+0400=0ASubject:=20[PATCH=202/3]=20= Fixing=20a=20bug=20in=20as-mac-firefox-get-frontmost-url=0A=0APrior=20to=20= the=20fix=20the=20firefox=20link=20grabber=20won't=20work=20correctly=20= if=20a=20cursor=20has=20been=20already=20positioned=20in=20the=20URL=20= field.=20The=20fix=20works=20by=20adding=20an=20additional=20keystore=20= for=20selecting=20all=20the=20text=20in=20that=20field.=0A---=0A=20= contrib/lisp/org-mac-link-grabber.el=20|=205=20+++--=0A=201=20file=20= changed,=203=20insertions(+),=202=20deletions(-)=0A=0Adiff=20--git=20= a/contrib/lisp/org-mac-link-grabber.el=20= b/contrib/lisp/org-mac-link-grabber.el=0Aindex=20e71fc15..f816c76=20= 100644=0A---=20a/contrib/lisp/org-mac-link-grabber.el=0A+++=20= b/contrib/lisp/org-mac-link-grabber.el=0A@@=20-216,8=20+216,9=20@@=20= applications=20and=20inserting=20them=20in=20org=20documents"=0A=20=09=09= =09=09=09=20"=09activate\n"=0A=20=09=09=09=09=09=20"=09delay=200.15\n"=0A= =20=09=09=09=09=09=20"=09tell=20application=20\"System=20Events\"\n"=0A-=09= =09=09=09=09=20"=09=09keystroke=20\"l\"=20using=20command=20down\n"=0A-=09= =09=09=09=09=20"=09=09keystroke=20\"c\"=20using=20command=20down\n"=0A+=09= =09=09=09=09=20"=09=09keystroke=20\"l\"=20using=20{command=20down}\n"=0A= +=09=09=09=09=09=20"=09=09keystroke=20\"a\"=20using=20{command=20= down}\n"=0A+=09=09=09=09=09=20"=09=09keystroke=20\"c\"=20using=20= {command=20down}\n"=0A=20=09=09=09=09=09=20"=09end=20tell\n"=0A=20=09=09=09= =09=09=20"=09delay=200.15\n"=0A=20=09=09=09=09=09=20"=09set=20theUrl=20= to=20the=20clipboard\n"=0A--=20=0A1.7.12.4=20(Apple=20Git-37)=0A=0A= --Apple-Mail=_0FCB9D8F-4EAD-4A36-A17F-F36CB67F3DDD Content-Disposition: attachment; filename=0003-Automatic-detection-of-the-presence-of-Skim.app.patch Content-Type: application/octet-stream; name="0003-Automatic-detection-of-the-presence-of-Skim.app.patch" Content-Transfer-Encoding: quoted-printable =46rom=2032c21fea9dd417a4405f0c6741d86c3c71f06a2b=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Daniil=20Frumin=20=0ADate:=20= Tue,=2014=20May=202013=2000:11:14=20+0400=0ASubject:=20[PATCH=203/3]=20= Automatic=20detection=20of=20the=20presence=20of=20Skim.app=0A=0A= Automatically=20detect=20whether=20the=20option=20for=20Skim.app=20= should=20be=20enabled=0Aby=20default=20or=20not.=20Thanks=20to=20Ivan=20= Andurs.=0A---=0A=20contrib/lisp/org-mac-link-grabber.el=20|=2020=20= +++++++++++---------=0A=201=20file=20changed,=2011=20insertions(+),=209=20= deletions(-)=0A=0Adiff=20--git=20a/contrib/lisp/org-mac-link-grabber.el=20= b/contrib/lisp/org-mac-link-grabber.el=0Aindex=20f816c76..cb92b44=20= 100644=0A---=20a/contrib/lisp/org-mac-link-grabber.el=0A+++=20= b/contrib/lisp/org-mac-link-grabber.el=0A@@=20-128,7=20+128,9=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+(defcustom=20= org-mac-grab-Skim-app-p=0A+=20=20(<=200=20(length=20= (shell-command-to-string=0A+=09=09"mdfind=20kMDItemCFBundleIdentifier=20= =3D=3D=20'net.sourceforge.skim-app.skim'")))=0A=20=20=20"Enable=20menu=20= option=20[S]kim=20to=20grab=20page=20links=20from=20Skim.app"=0A=20=20=20= :tag=20"Grab=20Skim.app=20page=20links"=0A=20=20=20:group=20= 'org-mac-link-grabber=0A@@=20-472,7=20+474,7=20@@=20applications=20and=20= inserting=20them=20in=20org=20documents"=0A=20;;=0A=20;;=20Handle=20= links=20from=20Skim.app=0A=20;;=0A-;;=20A=20rewriting=20of=20some=20code=20= originally=20by=20Christopher=20Suckling=20from=20org-mac-protocol=0A+;;=20= Original=20code=20&=20idea=20by=20Christopher=20Suckling=20= (org-mac-protocol)=0A=20=0A=20(org-add-link-type=20"skim"=20= 'org-mac-skim-open)=0A=20=0A@@=20-486,7=20+488,7=20@@=20applications=20= and=20inserting=20them=20in=20org=20documents"=0A=20=20=20=20=20=20=20= "tell=20application=20\"Skim\"\n"=0A=20=20=20=20=20=20=20=20=20=20= "activate\n"=0A=20=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"set=20= thePage=20to=20"=20page=20"\n"=0A=20=09=20"open=20theDoc\n"=0A=20=09=20= "go=20document=201=20to=20page=20thePage=20of=20document=201\n"=0A=20=20=20= =20=20=20=20"end=20tell"))))=0A@@=20-503,7=20+505,7=20@@=20applications=20= and=20inserting=20them=20in=20org=20documents"=0A=20=20=20=20=20=20=20=20= "set=20theSelection=20to=20selection=20of=20theDoc\n"=0A=20=20=20=20=20=20= =20=20"set=20theContent=20to=20contents=20of=20(get=20text=20for=20= theSelection)\n"=0A=20=20=20=20=20=20=20=20"if=20theContent=20is=20= missing=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"=20=20=20=20set=20theContent=20to=20theTitle=20&=20\",=20= p.=20\"=20&=20thePage\n"=0A=20=20=20=20=20=20=20=20"end=20if\n"=0A=20=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=20"\"::split::\"=20= &=20theContent\n"=0A@@=20-513,13=20+515,13=20@@=20applications=20and=20= inserting=20them=20in=20org=20documents"=0A=20(defun=20= org-mac-skim-get-page=20()=0A=20=20=20(interactive)=0A=20=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(let*=20= ((link-and-descr=20(as-get-skim-page-link))=0A+=20=20=20=20=20=20=20=20=20= (split-link=20(split-string=20link-and-descr=20"::split::"))=0A+=20=20=20= =20=20=20=20=20=20(link=20(car=20split-link))=0A=20=20=20=20=20=20=20=20=20= =20(description=20(cadr=20split-link))=0A=20=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(when=20(not=20(string=3D=20link=20""))=0A= +=20=20=20=20=20=20(setq=20org-link=20(org-make-link-string=20link=20= description)))=0A=20=20=20=20=20(kill-new=20org-link)=0A=20=20=20=20=20= org-link))=0A=20=0A--=20=0A1.7.12.4=20(Apple=20Git-37)=0A=0A= --Apple-Mail=_0FCB9D8F-4EAD-4A36-A17F-F36CB67F3DDD Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On May 13, 2013, at 10:34 AM, Carsten Dominik = wrote: > Hi Daniil, >=20 > I like this a lot and would like to take the patch after you have = taken Ivans feedback, and maybe more feedback if you get any. >=20 > I would like it even more if following the link would rehighlight the = selected text. Is there any way to achieve this? >=20 > I have another question, this would maybe be for the original author, = Anthony Lander? I see that there are functions with prefixes that are = not "org-". This is dangerous because there might be packages around = that use that name space. I also think it violates coding rules in = Emacs. I think this should be changed - unless you know of a convention = that all functions dealing with applescripts are supposed to have an = "as-" prefix. >=20 > I can fix this - but I wanted your feedback first. >=20 > Thanks. >=20 > - Carsten >=20 > On 12 mei 2013, at 20:29, Daniil Frumin wrote: >=20 >> Hi, all! >>=20 >> 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 >>=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. >>=20 >> What it does: >>=20 >> * Grabs not just the link to file, but a page >>=20 >> * Inserts the selected text as a description, if present. Otherwise >> inserts ", p. " >>=20 >> * The shortcut is set to [S] >>=20 >> * Defines a new "skim" link type >>=20 >> It would be interesting to also add some support for importing notes = from Skim to org. >>=20 >> 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'. >>=20 >> 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. >>=20 >> Cheers. >>=20 >> -- Daniil Frumin >> <0001-Adding-Skim.app-support-to-org-mac-link-grabber.el.patch> >=20 --Apple-Mail=_0FCB9D8F-4EAD-4A36-A17F-F36CB67F3DDD--