help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function to find symlink target


From: Michael Heerdegen
Subject: Re: Function to find symlink target
Date: Tue, 24 May 2022 04:27:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Emanuel Berg <incal@dataswamp.org> writes:

> >> (defun dired-find-link-target (link)
> >>   (let*((target (file-truename link))
> >>         (name   (file-name-nondirectory target)) )
> >>     (find-file (file-name-directory target))
> >>     (goto-char (point-min))
> >>     (cl-loop
> >>      while (re-search-forward name (point-max) t)
> >>      do (when (get-text-property (point) 'dired-filename)
> >>           (cl-return) ))
> >>     (goto-char (match-beginning 0)) ))
> >
> > Not wrong - but reinventing wheels: see `dired-jump' and
> > `dired-goto-file'.
>
> None of these work ...
>
> (dired-goto-file "~/test/dired/target-link.txt")
> (dired-jump "~/test/dired/target-link.txt")

I didn't say your function will shrink to one line.  It will shrink a
lot, however.  Any necessary information in the docstrings of those.

Michael.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]