Re: [O] [org-ref] how to tweak display of links and entries
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 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
Re: [O] [org-ref] how to tweak display of links and entries
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 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
Re: [O] [org-ref] how to tweak display of links and entries
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
Re: [O] [org-ref] how to tweak display of links and entries
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