From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Org-mode and/or org-ref citation formats Date: Thu, 5 Jan 2017 12:41:15 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=94eb2c19400288f62e05455c68a5 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPC2R-0005oo-KS for emacs-orgmode@gnu.org; Thu, 05 Jan 2017 12:41:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPC2Q-0003pX-5Q for emacs-orgmode@gnu.org; Thu, 05 Jan 2017 12:41:19 -0500 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:37573) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cPC2P-0003pM-SY for emacs-orgmode@gnu.org; Thu, 05 Jan 2017 12:41:18 -0500 Received: by mail-wm0-x232.google.com with SMTP id t79so493429970wmt.0 for ; Thu, 05 Jan 2017 09:41:17 -0800 (PST) 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" To: Gerald Wildgruber Cc: org mode mailing list --94eb2c19400288f62e05455c68a5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I don't know if it is possible to get helm-bibtex to insert links with pre/post text in a way that doesn't get in the (i.e. my) way. I never use pre/post text, so I want to select entries, and press enter to insert them. There would have to be some prompt for pre and post text I think, and I wouldn't want to press enter two more times to get empty ones. You could write your own function for that like this: #+BEGIN_SRC emacs-lisp (defun my-insert (candidate) (insert (format "[[cite:%s]%s]" candidate (let ((pre (read-input "pre-text: ")) (post (read-input "post text: "))) (cond ;; both pre and post ((and (not (string=3D pre "")) (not (string=3D post ""))) (format "[%s::%s]" pre post)) ;; only pre ((and (not (string=3D pre "")) (string=3D post "")) (format "[%s]" pre)) ((and (not (string=3D post "")) (string=3D pre "")) (format "[::%s]" post))))))) (helm-add-action-to-source "pre/post insert cite" 'my-insert helm-source-bibtex) #+END_SRC we already use C-u to insert a ref link, and C-u C-u to insert a label link on C-c ] (which inserts a citation). John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Thu, Jan 5, 2017 at 12:20 PM, Gerald Wildgruber < Gerald.Wildgruber@unibas.ch> wrote: > > On Mi, Jan 04 2017, John Kitchin wrote: > > > >> A simple link would be of the form "cite:MYREF" or "citep:MYREF"; but = if > >> I want to add a page number to this reference, the syntax of the link > >> seems to be very different, like so: "[[citep:MYREF][PAGENUM]]" or > >> [[citep:MYREF][::PAGENUM]]. > > > > That is correct. Basically it is [[cite:key][pre text::post text]] > > > > You can type C-c C-l, select the link type, then the bibtex key, then > > type in the description. There is no way to do it through helm-bibtex > though. > > Thanks! Is there a reason why refs with pre- and post-text use the > general Org-mode link syntax and insert mechanisms and not org-ref's own > more powerful format and interface (helm-bibtex); why are they handled > differently? > > Gerald. > > > -- > Dr.Gerald Wildgruber > eikones NFS Bildkritik > NCCR Iconic Criticism > Universit=C3=A4t Basel > Rheinsprung 11 > CH-4051 Basel > www.eikones.ch > T. +41 (0)61 267 18 02 > F. +41 (0)61 267 18 11 > --------------------- > Sent with mu4e > --94eb2c19400288f62e05455c68a5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I don't know if it is possible to get helm-bibtex to i= nsert links with pre/post text in a way that doesn't get in the (i.e. m= y) way. I never use pre/post text, so I want to select entries, and press e= nter to insert them. There would have to be some prompt for pre and post te= xt I think, and I wouldn't want to press enter two more times to get em= pty ones.

You could write your own function for that lik= e this:

#+BEGIN_SRC emacs-lisp
(def= un my-insert (candidate)
=C2=A0 (insert (format "[[cite:%s]%= s]"
=C2=A0candidate
=C2=A0(let ((pre (read-input "= ;pre-text: "))
(post (read-input "post text: ")))
=C2=A0 =C2=A0(cond
=C2=A0 =C2=A0 ;; both pre and post
= =C2=A0 =C2=A0 ((and (not (string=3D pre ""))
=C2=A0 (no= t (string=3D post "")))
=C2=A0 =C2=A0 =C2=A0(format "= ;[%s::%s]" pre post))
=C2=A0 =C2=A0 ;; only pre
=C2=A0= =C2=A0 ((and (not (string=3D pre ""))
=C2=A0 (string=3D= post ""))
=C2=A0 =C2=A0 =C2=A0(format "[%s]"= pre))
=C2=A0 =C2=A0 ((and (not (string=3D post ""))
=C2=A0 (string=3D pre ""))
=C2=A0 =C2=A0 =C2=A0(form= at "[::%s]" post)))))))

(helm-add-action= -to-source "pre/post insert cite" 'my-insert
=C2=A0 = helm-source-bibtex)
#+END_SRC

we already= use C-u to insert a ref link, and C-u C-u to insert a label link on C-c ] = (which inserts a citation).
John

-------------= ----------------------
Professor John Kitchin=C2=A0
Doherty Hall A207= F
Department of Chemical Engineering
Carnegie Mellon University
Pi= ttsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchi= ngroup.cheme.cmu.edu


On Thu, Jan 5, 2017 at 12:20 PM, Gerald Wild= gruber <Gerald.Wildgruber@unibas.ch> wrote:

On Mi, Jan 04 2017, John Kitchin <jkitchin@andrew.cmu.edu> wrote:


>> A simple link would be of the form "cite:MYREF" or "= ;citep:MYREF"; but if
>> I want to add a page number to this reference, the syntax of the l= ink
>> seems to be very different, like so: "[[citep:MYREF][PAGENUM]= ]" or
>> [[citep:MYREF][::PAGENUM]].
>
> That is correct. Basically it is [[cite:key][pre text::post text]]
>
> You can type C-c C-l, select the link type, th= en the bibtex key, then
> type in the description. There is no way to do it through helm-bibtex = though.

Thanks! Is there a reason why refs with pre- and post-text use the general Org-mode link syntax and insert mechanisms and not org-ref's ow= n
more powerful format and interface (helm-bibtex); why are they handled
differently?

Gerald.


--
Dr.Gerald Wildgruber
eikones NFS Bildkritik
NCCR Iconic Criticism
Universit=C3=A4t Basel
Rheinsprung 11
CH-4051 Basel
www.= eikones.ch
T. +41 (0)61 267 18 02
F. +41 (0)61 267 18 11
---------------------
Sent with mu4e

--94eb2c19400288f62e05455c68a5--