emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [org-ref] how to tweak display of links and entries
@ 2017-01-11  4:42 Christian Wittern
  2017-01-11 13:33 ` John Kitchin
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Wittern @ 2017-01-11  4:42 UTC (permalink / raw)
  To: Org Mode Mailing List

Hi Org, especially Org-ref users,

I have seen a number of org-ref related questions here recently, so I guess 
it is OK to ask here.

I am trying to move to a more sophisticated bibliography format involving 
some new field types recently added to biblatex. An author field for example 
can look like

author = {family=Fang, given=Ailong, cjk=方愛龍},

where cjk is defined using biblatex's tools for this as a name addon. 
Obviously, neither parsebib, helm-bibtex or org-ref understand this format 
(yet). However, I do not understand where I have to intervene to display 
this in a reasonable way, that is family name, given name and cjk name.  Is 
there a custom I have to redefine, or a hook I should add somewhere?

Another unrelated question is how to stop org-ref from displaying both the 
key and the description of the link.  I seem to remember having seen some 
discussion here about this, but can't find it now.

Any help appreciated,

Christian



-- 
Christian Wittern, Kyoto

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [org-ref] how to tweak display of links and entries
  2017-01-11  4:42 [org-ref] how to tweak display of links and entries Christian Wittern
@ 2017-01-11 13:33 ` John Kitchin
  2017-01-11 23:03   ` Christian Wittern
  0 siblings, 1 reply; 5+ messages in thread
From: John Kitchin @ 2017-01-11 13:33 UTC (permalink / raw)
  To: Christian Wittern; +Cc: Org Mode Mailing List


Christian Wittern writes:

> Hi Org, especially Org-ref users,
>
> I have seen a number of org-ref related questions here recently, so I guess 
> it is OK to ask here.
>
> I am trying to move to a more sophisticated bibliography format involving 
> some new field types recently added to biblatex. An author field for example 
> can look like
>
> author = {family=Fang, given=Ailong, cjk=方愛龍},
>
> where cjk is defined using biblatex's tools for this as a name addon. 
> Obviously, neither parsebib, helm-bibtex or org-ref understand this format 
> (yet). However, I do not understand where I have to intervene to display 
> this in a reasonable way, that is family name, given name and cjk name.  Is 
> there a custom I have to redefine, or a hook I should add somewhere?

There is not a way to hook or define a format for this that I know of.
For helm-bibtex, you might be able to redefine or advise
bibtex-completion-apa-format-authors to handle that.

>
> Another unrelated question is how to stop org-ref from displaying both the 
> key and the description of the link.  I seem to remember having seen some 
> discussion here about this, but can't find it now.

this is also not currently customizable. The description in cite links
is used for pre/post text in the citations, and they are shown in full
display so you can see the key and pre/post text. If you use the
description for anything else, the latex export will probably not be
what you expect.

You can turn off the full display like this:

#+BEGIN_SRC emacs-lisp
(loop for cite in org-ref-cite-types
  do
  (org-link-set-parameters cite :display nil))
#+END_SRC

>
> Any help appreciated,
>
> Christian


-- 
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [org-ref] how to tweak display of links and entries
  2017-01-11 13:33 ` John Kitchin
@ 2017-01-11 23:03   ` Christian Wittern
  2017-01-12 16:04     ` John Kitchin
  0 siblings, 1 reply; 5+ messages in thread
From: Christian Wittern @ 2017-01-11 23:03 UTC (permalink / raw)
  To: John Kitchin; +Cc: Org Mode Mailing List

Dear John,

Thanks for your answer.

On 01/11/2017 10:33 PM, John Kitchin wrote:
>
> There is not a way to hook or define a format for this that I know of.
> For helm-bibtex, you might be able to redefine or advise
> bibtex-completion-apa-format-authors to handle that.

Well, thanks, I'll investigate that. Is that what is also used for the 
display as popup and in the echo area that org-ref is providing?

>
> You can turn off the full display like this:
>
> #+BEGIN_SRC emacs-lisp
> (loop for cite in org-ref-cite-types
>   do
>   (org-link-set-parameters cite :display nil))
> #+END_SRC
>

OK, that is what I wanted to know, all I want to do is hide the citekey in 
this case.

All the best, and thanks for given us the present of org-ref,

Christian

-- 
Christian Wittern, Kyoto

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [org-ref] how to tweak display of links and entries
  2017-01-11 23:03   ` Christian Wittern
@ 2017-01-12 16:04     ` John Kitchin
  2017-01-12 23:57       ` Christian Wittern
  0 siblings, 1 reply; 5+ messages in thread
From: John Kitchin @ 2017-01-12 16:04 UTC (permalink / raw)
  To: Christian Wittern; +Cc: Org Mode Mailing List


Christian Wittern writes:

> Dear John,
>
> Thanks for your answer.
>
> On 01/11/2017 10:33 PM, John Kitchin wrote:
>>
>> There is not a way to hook or define a format for this that I know of.
>> For helm-bibtex, you might be able to redefine or advise
>> bibtex-completion-apa-format-authors to handle that.

Here is a lightly tested way to modify the authors. It basically works
by bypassing bibtex-completion-apa-format-authors to do what you want. I
adapted it from the bibtex-completion-apa-format-authors code. 

#+BEGIN_SRC emacs-lisp
(defun format--cjk-authors (orig-fun &rest args)
  "Format authors my way."
  (cl-loop for a in (s-split " and " value t)
	   collect
	   (let ((fields (mapcar (lambda (x)
				   (let* ((f (split-string x "="))
					  (prop (s-trim (nth 0 f)))
					  (val (s-trim (nth 1 f))))
				     (cons prop val)))
				 (s-split "," a t))))
	     (s-format "${given} ${family} (${cjk})" 'aget fields)) 
	   into authors
	   finally return
	   (let ((l (length authors)))
	     (cond
	      ((= l 1) (car authors))
	      ((= l 2) (s-join " & " authors))
	      ((< l 8) (concat (s-join ", " (-butlast authors))
			       ", & " (-last-item authors)))
	      (t (concat (s-join ", " authors) ", ..."))))))

(advice-add 'bibtex-completion-apa-format-authors :around
#'format--cjk-authors)

; remove advice like this.
;(advice-remove 'bibtex-completion-apa-format-authors  #'format--cjk-authors)

#+END_SRC

That generates Ailong Fang (方愛龍) & Another Fang (方愛龍), Super
interesting report, J. Interesting Reports, 1(),  (2007).  for the
tooltips and messages.

for this entry

@article{fang-2007-super,
  title =	 {Super interesting report},
  author =	 {family=Fang, given=Ailong, cjk=方愛龍 and family=Fang, given=Another, cjk=方愛龍},
  journal =	 {J. Interesting Reports},
  keywords =	 {test, word},
  volume =	 1,
  year =	 2007,
}

It is not very robust, e.g. it assumes there will be family, given and
cjk for all authors, that authors are split by and, and prop=val is
split by commas, etc...

>
> Well, thanks, I'll investigate that. Is that what is also used for the 
> display as popup and in the echo area that org-ref is providing?

yes, I think so.

>
>>
>> You can turn off the full display like this:
>>
>> #+BEGIN_SRC emacs-lisp
>> (loop for cite in org-ref-cite-types
>>   do
>>   (org-link-set-parameters cite :display nil))
>> #+END_SRC
>>
>
> OK, that is what I wanted to know, all I want to do is hide the citekey in 
> this case.
>
> All the best, and thanks for given us the present of org-ref,
>
> Christian


-- 
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [org-ref] how to tweak display of links and entries
  2017-01-12 16:04     ` John Kitchin
@ 2017-01-12 23:57       ` Christian Wittern
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Wittern @ 2017-01-12 23:57 UTC (permalink / raw)
  To: John Kitchin; +Cc: Org Mode Mailing List

Dear John,

This is great.  I will tweak this as needed.

Thanks a lot,

Christian

On 01/13/2017 01:04 AM, John Kitchin wrote:
> #+BEGIN_SRC emacs-lisp
> (defun format--cjk-authors (orig-fun &rest args)
>   "Format authors my way."
>   (cl-loop for a in (s-split " and " value t)
> 	   collect
> 	   (let ((fields (mapcar (lambda (x)
> 				   (let* ((f (split-string x "="))
> 					  (prop (s-trim (nth 0 f)))
> 					  (val (s-trim (nth 1 f))))
> 				     (cons prop val)))
> 				 (s-split "," a t))))
> 	     (s-format "${given} ${family} (${cjk})" 'aget fields))
> 	   into authors
> 	   finally return
> 	   (let ((l (length authors)))
> 	     (cond
> 	      ((= l 1) (car authors))
> 	      ((= l 2) (s-join " & " authors))
> 	      ((< l 8) (concat (s-join ", " (-butlast authors))
> 			       ", & " (-last-item authors)))
> 	      (t (concat (s-join ", " authors) ", ..."))))))
>
> (advice-add 'bibtex-completion-apa-format-authors :around
> #'format--cjk-authors)
>
> ; remove advice like this.
> ;(advice-remove 'bibtex-completion-apa-format-authors  #'format--cjk-authors)
>
> #+END_SRC
>
> That generates Ailong Fang (方愛龍) & Another Fang (方愛龍), Super
> interesting report, J. Interesting Reports, 1(),  (2007).  for the
> tooltips and messages.
>
> for this entry
>
> @article{fang-2007-super,
>   title =	 {Super interesting report},
>   author =	 {family=Fang, given=Ailong, cjk=方愛龍 and family=Fang, given=Another, cjk=方愛龍},
>   journal =	 {J. Interesting Reports},
>   keywords =	 {test, word},
>   volume =	 1,
>   year =	 2007,
> }
>
> It is not very robust, e.g. it assumes there will be family, given and
> cjk for all authors, that authors are split by and, and prop=val is
> split by commas, etc...

Yes, but its a great start.  This proves that this is a viable road for this 
kind of material.  There is still no established and robust way to do this 
kind of thing in any format, so I am great to see this is possible.

All the best,

Christian


-- 
Christian Wittern, Kyoto

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-01-12 23:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-11  4:42 [org-ref] how to tweak display of links and entries Christian Wittern
2017-01-11 13:33 ` John Kitchin
2017-01-11 23:03   ` Christian Wittern
2017-01-12 16:04     ` John Kitchin
2017-01-12 23:57       ` Christian Wittern

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).