From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: [org-ref] how to tweak display of links and entries Date: Thu, 12 Jan 2017 11:04:12 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRhrP-0003Lv-EW for emacs-orgmode@gnu.org; Thu, 12 Jan 2017 11:04:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cRhrL-00072G-GY for emacs-orgmode@gnu.org; Thu, 12 Jan 2017 11:04:19 -0500 Received: from mail-qt0-x22b.google.com ([2607:f8b0:400d:c0d::22b]:34109) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cRhrL-000727-CV for emacs-orgmode@gnu.org; Thu, 12 Jan 2017 11:04:15 -0500 Received: by mail-qt0-x22b.google.com with SMTP id l7so22047275qtd.1 for ; Thu, 12 Jan 2017 08:04:15 -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: 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