From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Danan Subject: [PATCH] org-bibtex.el: Make headline format costomizable Date: Thu, 24 Nov 2016 22:22:17 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cA1Tl-0000Si-Jq for emacs-orgmode@gnu.org; Thu, 24 Nov 2016 16:22:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cA1Ti-0005uu-Cx for emacs-orgmode@gnu.org; Thu, 24 Nov 2016 16:22:49 -0500 Received: from mail-wj0-x243.google.com ([2a00:1450:400c:c01::243]:35077) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cA1TI-0005mj-7S for emacs-orgmode@gnu.org; Thu, 24 Nov 2016 16:22:46 -0500 Received: by mail-wj0-x243.google.com with SMTP id o2so156251wje.2 for ; Thu, 24 Nov 2016 13:22:19 -0800 (PST) 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: emacs-orgmode@gnu.org Hello, When adding an org-bibtex entry with `org-bibtex-write' (or any command relying on it), the headline is the title. The patch below simply makes the headline customizable through a new variable. I tried to follow the contribution guidelines at http://orgmode.org/worg/org-contribute.html#patches but I am not familiar with the process of sending patches, please let me know if I did not do it correctly. If you find it worth to incorporate this into org-bibtex I should probably add a dosctring for the new variable `org-bibtex-headline-format' and I would also have a few questions: 1. Should I name this variable differently? 2. Should I use `defcustom' instead of `defvar'? 3. Should I move the `defvar' / `defcustom' at the beginning of the file? 4. In the default value of the variable should I make use of the `val' function that is let-bound inside `org-bibtex-write'? Thank you for your attention, Eric * lisp/org-bibtex.el (org-bibtex-write): Make this function reads the headline format from the newly created variable `org-bibtex-headline-format' instead of systematically using the entry title. (org-bibtex-headline-format): Create this variable to hold a function of one argument, the entry alist, and return the string to be inserted as headline. The default value replicates the current behavior of returning the entry title. TINYCHANGE --- lisp/org-bibtex.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/org-bibtex.el b/lisp/org-bibtex.el index db5d97b3..b4b8b3c6 100644 --- a/lisp/org-bibtex.el +++ b/lisp/org-bibtex.el @@ -668,6 +668,10 @@ (defun org-bibtex-read-file (file) (interactive "fFile: ") (org-bibtex-read-buffer (find-file-noselect file 'nowarn 'rawfile))) +(defvar org-bibtex-headline-format + (lambda (entry) + (cdr (assoc :title entry)))) + (defun org-bibtex-write () "Insert a heading built from the first element of `org-bibtex-entries'." (interactive) @@ -678,7 +682,7 @@ (defun org-bibtex-write () (val (lambda (field) (cdr (assoc field entry)))) (togtag (lambda (tag) (org-toggle-tag tag 'on)))) (org-insert-heading) - (insert (funcall val :title)) + (insert (funcall org-bibtex-headline-format entry)) (org-bibtex-put "TITLE" (funcall val :title)) (org-bibtex-put org-bibtex-type-property-name (downcase (funcall val :type))) -- 2.8.3