[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Function to find symlink target
From: |
Jean Louis |
Subject: |
Re: Function to find symlink target |
Date: |
Fri, 27 May 2022 11:00:19 +0300 |
User-agent: |
Mutt/+ () (2022-05-21) |
* Michael Heerdegen <michael_heerdegen@web.de> [2022-05-27 06:32]:
> Jean Louis <bugs@gnu.support> writes:
>
> > How do you mean to see truename, is it by message?
>
> Not sure I understand your question.
>
> I meant this case:
>
> symlink1 -> symlink2 -> file
>
> what would you want to get? Both seeing FILE or SYMLINK2 could be
> useful.
Yes, there are complex conditions.
In my case I need `file', the target. I found also `file-chase-links'
function. But that one returns always something, even if file does not
exist, and is not as good as `file-truename' as it would not resolve
parent directories that are symlinks.
(defun rcd-dired-show-symlink-target (&optional file)
"Show target of a link."
(interactive)
(let ((file (or file (car (dired-get-marked-files)))))
(if (and file (file-symlink-p file))
(let* ((target (file-chase-links file))
(target-exists (file-exists-p target))
(directory (file-name-directory target)))
(if target-exists
(progn
(find-file directory)
(dired-jump nil target))
(rcd-warning-message "Target does not exist: %s" target)))
(rcd-warning-message "Not a symlink: %s" file))))
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
- Re: Function to find symlink target, (continued)
- Re: Function to find symlink target, Emanuel Berg, 2022/05/23
- Re: Function to find symlink target, Emanuel Berg, 2022/05/23
- Re: Function to find symlink target, Michael Heerdegen, 2022/05/23
- Re: Function to find symlink target, Emanuel Berg, 2022/05/23
- Re: Function to find symlink target, Michael Heerdegen, 2022/05/23
- Re: Function to find symlink target, Emanuel Berg, 2022/05/24
- Re: Function to find symlink target, Michael Heerdegen, 2022/05/24
- Re: Function to find symlink target, Michael Heerdegen, 2022/05/25
- Re: Function to find symlink target, Jean Louis, 2022/05/26
- Re: Function to find symlink target, Michael Heerdegen, 2022/05/26
- Re: Function to find symlink target,
Jean Louis <=
- Re: Function to find symlink target, Emanuel Berg, 2022/05/27
- Re: Function to find symlink target, Jean Louis, 2022/05/28
- Re: Function to find symlink target, Emanuel Berg, 2022/05/28
- Re: Function to find symlink target, Emanuel Berg, 2022/05/28
- Re: Function to find symlink target, Eli Zaretskii, 2022/05/28
- Re: Function to find symlink target, Emanuel Berg, 2022/05/28
- Re: Function to find symlink target, Eli Zaretskii, 2022/05/28
- Re: Function to find symlink target, Emanuel Berg, 2022/05/28
- Re: Function to find symlink target, Jean Louis, 2022/05/31
- Re: Function to find symlink target, Emanuel Berg, 2022/05/31