[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Function to find symlink target
From: |
Emanuel Berg |
Subject: |
Re: Function to find symlink target |
Date: |
Sun, 29 May 2022 04:01:51 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
>> (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
- Re: Function to find symlink target, (continued)
- 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/25
- Re: Function to find symlink target, Emanuel Berg, 2022/05/25
- Re: Function to find symlink target,
Emanuel Berg <=
Re: Function to find symlink target, Nick Dokos, 2022/05/19