[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] org-attach-attach: fix symlinks
From: |
Ihor Radchenko |
Subject: |
Re: [PATCH] org-attach-attach: fix symlinks |
Date: |
Sat, 30 Apr 2022 11:32:58 +0800 |
Matt Price <moptop99@gmail.com> writes:
> I'm having trouble with org-attach-attach if my current buffer is visiting
> a filepath starting with "~/". This trivial patch fixes the problem for me
> by running (expand-file-name) on the file before attaching. I always use
> the 'lns method, so I don't know whether it might be better to
> expand-file-name before running any of the methods.
>
> Alternatively, it might actually be better to use a *relative* file path
> where possible (e.g. to ensure that project directories are fully
> portable), but I'm not sure how best to do that.
I do not like explicit expansion of the FILE path. It may break relative
vs. absolute path handling.
Attaching an alternative patch. It makes use of make-symbolic-link
arguments.
Best,
Ihor
>From ff9ccae51ce1b02fc5d95cbc60de7a44c42f28a1 Mon Sep 17 00:00:00 2001
Message-Id:
<ff9ccae51ce1b02fc5d95cbc60de7a44c42f28a1.1651289455.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sat, 30 Apr 2022 11:27:30 +0800
Subject: [PATCH] org-attach-attach: Avoid linking to path starting with ~
* lisp/org-attach.el (org-attach-attach): Auto-expand ~ in the file
patch when using symlink (`lns') attach method.
Fixes
https://orgmode.org/list/CAN_Dec_LyTKgSN_kiftee9GULM7FPER5frQFant3n_2C3cwM-g@mail.gmail.com
---
lisp/org-attach.el | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lisp/org-attach.el b/lisp/org-attach.el
index 5ee2b84b2..760592507 100644
--- a/lisp/org-attach.el
+++ b/lisp/org-attach.el
@@ -524,7 +524,8 @@ (defun org-attach-attach (file &optional visit-dir method)
((eq method 'mv) (rename-file file attach-file))
((eq method 'cp) (copy-file file attach-file))
((eq method 'ln) (add-name-to-file file attach-file))
- ((eq method 'lns) (make-symbolic-link file attach-file))
+ ;; We pass integer third argument to auto-expand "~" in FILE.
+ ((eq method 'lns) (make-symbolic-link file attach-file 1))
((eq method 'url) (url-copy-file file attach-file)))
(run-hook-with-args 'org-attach-after-change-hook attach-dir)
(org-attach-tag)
--
2.35.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH] org-attach-attach: fix symlinks,
Ihor Radchenko <=