On 19/06/2024, Ihor Radchenko wrote:

> Al Haji-Ali <abdo.haji....@gmail.com> writes:
>
>> On 18/06/2024, Ihor Radchenko wrote:
>>> Hmm. Thanks, but the patch does not apply on my side.
>>> May you instead create a patch as a separate file, add the commit
>>> message, and attach that patch file in the email reply?
>>
>> See attached.
>
> Thanks. Although this is a different kind of patch. And it is doing too
> much - we do not want to expand all the names via `file-truename'
> because you may have a situation like
>
> /path/to/file1.org
> /path/to/symlinks/name-is-completely-different.org
>
> Then, using `file-truename' may be confusing for people who expect the
> symlink name to be displayed.

I am not sure what would be the correct approach. Perhaps the true-name 
expansion should be conditioned on the value of `find-file-visit-truename`.

> I am thus attaching an alternative patch.
> May you please test if it fixes the problem on your side?
I think it's missing calling `file-truename` call on `filename`, see attached 
patch.

Best regards,
-- Al
>From 9b44f737a44945723a9cf35dfa92e19d27a1135b Mon Sep 17 00:00:00 2001
From: Al Haji-Ali <a.haji...@hw.ac.uk>
Date: Tue, 18 Jun 2024 19:27:56 +0100
Subject: [PATCH] org-refile-get-location: Fix outline path to a symlink of
 current buffer

* lisp/org-refile.el (org-refile-get-location): When current buffer
file is a symlink to refile location, do not append the file name to
the outline path, just as we do when current buffer is the same as
refile location file.
---
 lisp/org-refile.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-refile.el b/lisp/org-refile.el
index 20b5fbd02..c8e64903c 100644
--- a/lisp/org-refile.el
+++ b/lisp/org-refile.el
@@ -666,12 +666,12 @@ this function appends the default value from
 		  #'completing-read))
 	 (extra (if org-refile-use-outline-path "/" ""))
 	 (cbnex (concat (buffer-name) extra))
-	 (filename (and cfn (expand-file-name cfn)))
+	 (filename (and cfn (file-truename cfn)))
 	 (tbl (mapcar
 	       (lambda (x)
 		 (if (and (not (member org-refile-use-outline-path
 				       '(file full-file-path title)))
-			  (not (equal filename (nth 1 x))))
+			  (not (equal filename (file-truename (nth 1 x)))))
 		     (cons (concat (car x) extra " ("
 				   (file-name-nondirectory (nth 1 x)) ")")
 			   (cdr x))

Reply via email to