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 10:18:41 +0400 Message-ID: <529C465A-6A0D-492A-BE0D-F179091E61C6@gmail.com> References: <171D50FA-314D-4233-9F7E-AD07D8B1B902@gmail.com> <5D9D77F4-F343-45D1-8B06-70550EE83E2B@gmail.com> <541E4CA0-F2FD-4870-9CE6-52C18567C1B4@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_DC8A681A-9187-4455-82D9-5C84AB6F90B9" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:49358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uc8ZU-0007sk-9N for emacs-orgmode@gnu.org; Tue, 14 May 2013 02:18:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uc8ZQ-00049Z-GL for emacs-orgmode@gnu.org; Tue, 14 May 2013 02:18:48 -0400 Received: from mail-la0-x232.google.com ([2a00:1450:4010:c03::232]:36134) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uc8ZQ-00049L-3r for emacs-orgmode@gnu.org; Tue, 14 May 2013 02:18:44 -0400 Received: by mail-la0-f50.google.com with SMTP id ed20so135399lab.23 for ; Mon, 13 May 2013 23:18:43 -0700 (PDT) In-Reply-To: <541E4CA0-F2FD-4870-9CE6-52C18567C1B4@gmail.com> 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 , "emacs-orgmode@gnu.org Mode" --Apple-Mail=_DC8A681A-9187-4455-82D9-5C84AB6F90B9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii OK, here's a patch which adds the ability to highlight the selected = text. It makes new highlight notes only if = `org-mac-Skim-highlight-selection-p' is set to t. - Dan --Apple-Mail=_DC8A681A-9187-4455-82D9-5C84AB6F90B9 Content-Disposition: attachment; filename=0004-Add-the-ability-to-highlight-the-selected-text-in-Sk.patch Content-Type: application/octet-stream; name="0004-Add-the-ability-to-highlight-the-selected-text-in-Sk.patch" Content-Transfer-Encoding: quoted-printable =46rom=20cb943216ae4d4a5ff2ab0295d0d026b6cbdfb4ea=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Daniil=20Frumin=20=0ADate:=20= Tue,=2014=20May=202013=2010:13:50=20+0400=0ASubject:=20[PATCH=204/4]=20= Add=20the=20ability=20to=20highlight=20the=20selected=20text=20in=0A=20= Skim.app=0A=0AMake=20a=20'highlight=20note'=20upon=20grabbing=20a=20link=20= from=20Skim.app=20if=20the=0Aoption=20= 'org-mac-Skim-highlight-selection-p'=20is=20t.=0A---=0A=20= contrib/lisp/org-mac-link-grabber.el=20|=2013=20+++++++++++++=0A=201=20= file=20changed,=2013=20insertions(+)=0A=0Adiff=20--git=20= a/contrib/lisp/org-mac-link-grabber.el=20= b/contrib/lisp/org-mac-link-grabber.el=0Aindex=20cb92b44..59f4820=20= 100644=0A---=20a/contrib/lisp/org-mac-link-grabber.el=0A+++=20= b/contrib/lisp/org-mac-link-grabber.el=0A@@=20-136,6=20+136,12=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-Skim-highlight-selection-p=20nil=0A+=20=20= "Highlight=20(using=20notes)=20the=20selection=20(if=20present)=20when=20= grabbing=20the=20a=20link=20from=20Skim.app"=0A+=20=20:tag=20"Highlight=20= selection=20in=20Skim.app"=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=20application=20to=20grab=20a=20= link=20from,=20then=20go=20grab=20the=20link,=20and=20insert=20it=20at=20= point"=0A@@=20-506,6=20+512,13=20@@=20applications=20and=20inserting=20= them=20in=20org=20documents"=0A=20=20=20=20=20=20=20=20"set=20theContent=20= to=20contents=20of=20(get=20text=20for=20theSelection)\n"=0A=20=20=20=20=20= =20=20=20"if=20theContent=20is=20missing=20value=20then\n"=0A=20=20=20=20= =20=20=20=20"=20=20=20=20set=20theContent=20to=20theTitle=20&=20\",=20p.=20= \"=20&=20thePage\n"=0A+=20=20=20=20=20=20=20(when=20= org-mac-Skim-highlight-selection-p=0A+=09=20(concat=0A+=09=20=20"else\n"=0A= +=20=20=20=20=20=20=20=20=20=20"=20=20=20=20tell=20theDoc\n"=0A+=20=20=20= =20=20=20=20=20=20=20"=20=20=20=20=20=20=20=20set=20theNote=20to=20make=20= note=20with=20properties=20{type:highlight=20note,=20= selection:theSelection}\n"=0A+=20=20=20=20=20=20=20=20=20=20"=20=20=20=20= =20=20=20=20=20set=20text=20of=20theNote=20to=20(get=20text=20for=20= theSelection)\n"=0A+=20=20=20=20=20=20=20=20=20=20"=20=20=20=20end=20= tell\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&=20= thePage=20&=20"=0A=20=20=20=20=20=20=20=20"\"::split::\"=20&=20= theContent\n"=0A--=20=0A1.7.12.4=20(Apple=20Git-37)=0A=0A= --Apple-Mail=_DC8A681A-9187-4455-82D9-5C84AB6F90B9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On May 14, 2013, at 8:33 AM, Carsten Dominik = wrote: >=20 > On 13.5.2013, at 22:35, Daniil Frumin wrote: >=20 >> So I've been researching this problem and it seems that there is no = sane way to re-select a text.=20 >=20 > OK, thanks for looking into it. >=20 >>=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= >>=20 >> There is also `selection bounds' but it only covers rectangle = selections. >>=20 >> 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 >>=20 >> I've also tried to implement an auto-scrolling to the selected text, = but to no avail. >>=20 >> 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 >=20 > Interesting idea! I think this should be implemented, but with a user = option to turn it off. >=20 >>=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. >>=20 >> 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. >=20 > So you mean the patch you would like to send to me is several commits? = That is no problem, just specify with git which range of commits should = be part of the patch, for example >=20 > git diff HEAD^^ >=20 > will include the changes from two commits. You could also amend the = previous commit if it has not yet been push to another repository - = there are many ways to deal with this. >=20 > - Carsten >=20 >>=20 >> Thanks >>=20 >> -- Daniil >>=20 >> = <0002-Fixing-a-bug-in-as-mac-firefox-get-frontmost-url.patch><0003-Automat= ic-detection-of-the-presence-of-Skim.app.patch> >>=20 >>=20 >> On May 13, 2013, at 10:34 AM, Carsten Dominik = wrote: >>=20 >>> 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 >>=20 >=20 --Apple-Mail=_DC8A681A-9187-4455-82D9-5C84AB6F90B9--