unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Function to find symlink target
@ 2022-05-18 20:55 Jean Louis
  2022-05-18 23:00 ` Emanuel Berg
  2022-05-19 23:14 ` Nick Dokos
  0 siblings, 2 replies; 41+ messages in thread
From: Jean Louis @ 2022-05-18 20:55 UTC (permalink / raw)
  To: Help GNU Emacs

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/




^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2022-06-05  5:40 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-18 20:55 Function to find symlink target Jean Louis
2022-05-18 23:00 ` Emanuel Berg
2022-05-22 13:52   ` Jean Louis
2022-05-22 18:02     ` Emanuel Berg
2022-05-23  9:05       ` Jean Louis
2022-05-23 20:46         ` Emanuel Berg
2022-05-24  0:59           ` Emanuel Berg
2022-05-24  1:09             ` Michael Heerdegen
2022-05-24  2:14               ` Emanuel Berg
2022-05-24  2:27                 ` Michael Heerdegen
2022-05-24  8:04                   ` Emanuel Berg
2022-05-24  8:52                     ` Michael Heerdegen
2022-05-25  5:54                       ` Michael Heerdegen
2022-05-27  2:25                         ` Jean Louis
2022-05-27  3:31                           ` Michael Heerdegen
2022-05-27  8:00                             ` Jean Louis
2022-05-27 14:47                           ` Emanuel Berg
2022-05-28  6:43                             ` Jean Louis
2022-05-28 15:29                               ` Emanuel Berg
2022-05-28 15:43                                 ` Emanuel Berg
2022-05-28 16:08                                   ` Eli Zaretskii
2022-05-28 16:46                                     ` Emanuel Berg
2022-05-28 16:55                                       ` Eli Zaretskii
2022-05-28 17:05                                         ` Emanuel Berg
2022-05-31  6:27                                 ` Jean Louis
2022-05-31 12:24                                   ` Emanuel Berg
2022-05-31  6:31                                 ` Jean Louis
2022-05-31 12:16                                   ` Emanuel Berg
2022-06-01  7:43                                     ` Jean Louis
2022-06-02  0:40                                       ` Emanuel Berg
2022-06-02  5:15                                         ` Jean Louis
2022-06-05  5:40                                           ` Emanuel Berg
2022-05-25  5:05                 ` Jean Louis
2022-05-25 22:33                   ` Emanuel Berg
2022-05-29  2:01                     ` Emanuel Berg
2022-05-19 23:14 ` Nick Dokos
2022-05-20  0:42   ` Emanuel Berg
2022-05-23  8:17   ` Jean Louis
2022-05-23 22:49     ` Michael Heerdegen
2022-05-23 22:57       ` Emanuel Berg
2022-05-24  0:59         ` Michael Heerdegen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).