[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Function to find symlink target
From: |
Jean Louis |
Subject: |
Function to find symlink target |
Date: |
Wed, 18 May 2022 23:55:26 +0300 |
Hello,
I have made this function to find the target of a symlink in dired, it opens
new Dired window and tries to locate the file. I have tried finding
such function in Dired and did not succeed, maybe it exists in Emacs
programs somewhere.
(defun rcd-dired-find-symlink ()
"Find target of a symlink"
(interactive)
(when (dired-get-marked-files)
(let ((file (car (dired-get-marked-files))))
(if (file-symlink-p file)
(let* ((file (file-truename file))
(directory (file-name-directory file))
(file (file-name-nondirectory file))
(back (length file)))
(find-file directory)
(search-forward file)
(backward-char back))
(message "Not a symlink: %s" file)))))
Let me know if I should improve this by any means.
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
- Function to find symlink target,
Jean Louis <=
- Re: Function to find symlink target, Emanuel Berg, 2022/05/18
- Re: Function to find symlink target, Jean Louis, 2022/05/22
- Re: Function to find symlink target, Emanuel Berg, 2022/05/22
- Re: Function to find symlink target, Jean Louis, 2022/05/23
- 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