emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Emmanuel Charpentier <emm.charpentier@free.fr>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: [PATCH] c-csl : accept relative CSL filenames
Date: Tue, 19 Oct 2021 20:24:22 +0200	[thread overview]
Message-ID: <923e51a09367741650c05692009e00ae913a28d3.camel@free.fr> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 644 bytes --]

This (minuscule) patch allows to pass a relative (to the buffer's
default directory) file name to denote the CSL style file.

Rationale : this allows the use of "one-of" styles for "one-of"
projects without overloading a defailt CSL style directory (which may
or may not exist on a given system : think JabRef users...). Also
useful for hacked CSL files specific to a given project.

For the same reasons, when the named filename exists both in the
central CSL file and the buffer's default directory, the latter is
retained.

HTH,

PS : Note that I have already transferred my rights to GNU for emacs-
related works.

--
Emmanuel Charpentier


[-- Attachment #1.2: Type: text/html, Size: 862 bytes --]

[-- Attachment #2: 0001-oc-csl-accept-relative-CSL-filenames.patch --]
[-- Type: text/x-patch, Size: 1442 bytes --]

From 80e4121f8a74aec1e5638713ce7af8e041404e44 Mon Sep 17 00:00:00 2001
From: Emmanuel Charpentier <emm.charpentier@free.fr>
Date: Tue, 19 Oct 2021 19:57:17 +0200
Subject: [PATCH] oc-csl : accept relative CSL filenames

---
 lisp/oc-csl.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 94de97e33..ab75db85b 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -364,15 +364,19 @@ corresponding to one of the output formats supported by Citeproc: `html',
 
 INFO is the export state, as a property list.
 
-When file name is relative, expand it according to `org-cite-csl-styles-dir',
+When file name is relative, expand it according to the buffer's default
+directory, failing that according to `org-cite-csl-styles-dir',
 or raise an error if the variable is unset."
   (pcase (org-cite-bibliography-style info)
     ('nil org-cite-csl--fallback-style-file)
     ((and (pred file-name-absolute-p) file) file)
+    ((and (pred (lambda (x)
+		  (let ((fn (expand-file-name x default-directory)))
+		    (if (file-exists-p fn) fn nil)))) file) file)
     ((and (guard org-cite-csl-styles-dir) file)
      (expand-file-name file org-cite-csl-styles-dir))
     (other
-     (user-error "Cannot handle relative style file name: %S" other))))
+     (user-error "CSL style file not found: %S" other))))
 
 (defun org-cite-csl--locale-getter ()
   "Return a locale getter.
-- 
2.33.0


             reply	other threads:[~2021-10-19 18:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19 18:24 Emmanuel Charpentier [this message]
2021-11-03 16:19 ` Nicolas Goaziou
2021-11-04 16:25   ` Emmanuel Charpentier
2021-11-04 22:16     ` Nicolas Goaziou
2021-11-04 22:36       ` Bruce D'Arcus
2021-11-05 12:18         ` Eric S Fraga
2021-11-05  9:38       ` M. ‘quintus’ Gülker
2021-11-05 17:56 Emmanuel Charpentier
2021-11-19 12:54 ` Nicolas Goaziou
2021-11-19 18:10   ` M. ‘quintus’ Gülker

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=923e51a09367741650c05692009e00ae913a28d3.camel@free.fr \
    --to=emm.charpentier@free.fr \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: [PATCH] c-csl : accept relative CSL filenames' \
    /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

Code repositories for project(s) associated with this 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).