emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [org-ref] how to tweak display of links and entries


From: John Kitchin
Subject: Re: [O] [org-ref] how to tweak display of links and entries
Date: Thu, 12 Jan 2017 11:04:12 -0500
User-agent: mu4e 0.9.19; emacs 25.1.1

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]