aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Rankin <william@bydasein.com>2020-09-27 18:50:03 +1000
committerWilliam Rankin <william@bydasein.com>2020-09-27 18:50:03 +1000
commitbad3a40e1cca1f14792346d3731adaaf1b52b5b4 (patch)
tree1267d47a8ec6fcdf22b24c52ff146eec1b4eba00
parent577bf2640408e432fb79b96ff6b853d15444f4a9 (diff)
downloadbinder-bad3a40e1cca1f14792346d3731adaaf1b52b5b4.zip
Fix binder-file-relative-to-root called from file
When calling e.g. binder-toggle-notes from a file (instead of from sidebar) this would leave a "/" prefix and so fail to match the item fileid.
-rw-r--r--binder.el5
1 files changed, 3 insertions, 2 deletions
diff --git a/binder.el b/binder.el
index 0109663..9ea8ac2 100644
--- a/binder.el
+++ b/binder.el
@@ -510,8 +510,9 @@ With optional argument FILTER, call `binder-filter' on data."
(defun binder-file-relative-to-root (filepath)
"Return FILEPATH relative to binder root directory."
- (string-remove-prefix (expand-file-name (or binder-project-directory ""))
- (expand-file-name filepath)))
+ (let ((dir (expand-file-name (or binder-project-directory ""))))
+ (unless (string-suffix-p "/" dir) (setq dir (concat dir "/")))
+ (string-remove-prefix dir (expand-file-name filepath))))
(defun binder-get-item (fileid)
"Return project item association list for FILEID."