From: Eric Danan <eric.danan@u-cergy.fr>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org-bibtex.el: Make headline format costomizable
Date: Thu, 24 Nov 2016 22:22:17 +0100 [thread overview]
Message-ID: <CAMBH+RZJ1UwTP0qVFbpAdawKEBwK3qnfarme4wS2uqCUNcbr4g@mail.gmail.com> (raw)
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
next reply other threads:[~2016-11-24 21:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-24 21:22 Eric Danan [this message]
2016-12-03 7:59 ` [PATCH] org-bibtex.el: Make headline format costomizable Nicolas Goaziou
2016-12-07 21:20 ` Eric Danan
2016-12-09 20:48 ` Nicolas Goaziou
2016-12-09 22:11 ` Eric Danan
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=CAMBH+RZJ1UwTP0qVFbpAdawKEBwK3qnfarme4wS2uqCUNcbr4g@mail.gmail.com \
--to=eric.danan@u-cergy.fr \
--cc=emacs-orgmode@gnu.org \
/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).