emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: [PATCH] c-csl : accept relative CSL filenames
@ 2021-11-05 17:56 Emmanuel Charpentier
  2021-11-19 12:54 ` Nicolas Goaziou
  2021-12-10  9:20 ` Nicolas Goaziou
  0 siblings, 2 replies; 14+ messages in thread
From: Emmanuel Charpentier @ 2021-11-05 17:56 UTC (permalink / raw)
  To: post+orgmodeml, emacs-orgmode

Quintus' example illustrates why I think my proposed patch is useful
(or, rather, will be when corrected :-)), and why the order of research
should be from most-specific to less-specific.

If a finename is not absolute, search :
	1. relatively to the buffer's default directory
	2. if 1. unsuccessfull, relatively to`org-cite-csl-styles-dir'
	3. if 2. unsuccessfull, relatively to emacs' default directory
	   (BTW : what is this ? How to retrieve it ?)
	4. if 3. unsuccessfull, fail.

BTW : my current code does *not* work, and I do not understand why my
test used to succeed... A better patch will follow ( but not
tonight...).

HTH,

--
Emmanuel Charpentier



^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH] c-csl : accept relative CSL filenames
@ 2021-10-19 18:24 Emmanuel Charpentier
  2021-11-03 16:19 ` Nicolas Goaziou
  0 siblings, 1 reply; 14+ messages in thread
From: Emmanuel Charpentier @ 2021-10-19 18:24 UTC (permalink / raw)
  To: emacs-orgmode


[-- 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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-02-18 19:25 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-05 17:56 [PATCH] c-csl : accept relative CSL filenames Emmanuel Charpentier
2021-11-19 12:54 ` Nicolas Goaziou
2021-11-19 18:10   ` M. ‘quintus’ Gülker
2021-12-10  9:20 ` Nicolas Goaziou
2022-02-18 14:51   ` Kaushal Modi
2022-02-18 18:16     ` Nicolas Goaziou
2022-02-18 19:17       ` Kaushal Modi
  -- strict thread matches above, loose matches on Subject: below --
2021-10-19 18:24 Emmanuel Charpentier
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

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).