emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Christian Wittern <cwittern@gmail.com>
To: John Kitchin <jkitchin@andrew.cmu.edu>
Cc: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: [org-ref] how to tweak display of links and entries
Date: Fri, 13 Jan 2017 08:57:29 +0900	[thread overview]
Message-ID: <e475d52a-6801-2924-02c7-5b8a8bccb4f2@gmail.com> (raw)
In-Reply-To: <m21sw8jmdf.fsf@andrew.cmu.edu>

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

      reply	other threads:[~2017-01-12 23:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e475d52a-6801-2924-02c7-5b8a8bccb4f2@gmail.com \
    --to=cwittern@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=jkitchin@andrew.cmu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).