From: Emanuel Berg <incal@dataswamp.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Function to find symlink target
Date: Sun, 29 May 2022 04:01:51 +0200 [thread overview]
Message-ID: <87sfotf65s.fsf@dataswamp.org> (raw)
In-Reply-To: 87v8ttb5te.fsf@dataswamp.org
>> (defun rcd-dired-show-symlink-target ()
>> "Show target of a symlink." [...]
>
> Yes, that works. You can add an optional FILE argument and
> only when that's not provided look for the first marked file
> or even the file at point which is perhaps more intuitive
> since it's only one file ...
;;; -*- lexical-binding: t -*-
;;
;; this file:
;; https://dataswamp.org/~incal/emacs-init/dired-jump-target.el
(require 'dired)
(defun dired-jump-target (&optional file)
"Jump to FILE or to the target if a symlink."
(interactive
(let ((fls (dired-get-marked-files)))
(list (if (= 1 (length fls))
(car fls)
(thing-at-point 'filename) ))))
(let*((tgt (file-truename file))
(dir (file-name-directory tgt)) )
(when (file-exists-p tgt)
(find-file dir)
(dired-jump nil tgt) )))
;; (dired-jump-target "~/mia.txt") ; from Lisp, regular file
;; ^ and try interactively with point here
;;
;; (dired-jump-target "~/l") ; symlink
;; ^
;; (dired-jump-target "~/xxx") ; nil and NOOP on no file
;; ^
;; last, try from dired with one (1) file marked for cases
;; regular/symlink
--
underground experts united
https://dataswamp.org/~incal
next prev parent reply other threads:[~2022-05-29 2:01 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sfotf65s.fsf@dataswamp.org \
--to=incal@dataswamp.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.