[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 00:49:29 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Jean Louis <bugs@gnu.support> writes:
> Is there maybe some Dired function to jump exactly to specific file
> name?
I have written one so I don't think so. Maybe it is useful:
#+begin_src emacs-lisp
(defun my-dired-jump-close (file &optional not-this-window)
"Visit file under point in its dir buffer, resolving symlinks.
Display the buffer in a popup window in this frame when prefix arg
given and in the selected window else."
(interactive (let ((file-name-at-point (dired-get-filename)))
(list (pcase nil
((guard (file-name-directory (dired-get-filename
'verbatim)))
file-name-at-point)
((and (let link (file-symlink-p (if (file-directory-p
file-name-at-point)
(directory-file-name file-name-at-point)
file-name-at-point)))
(guard link))
(expand-file-name link (file-name-directory
file-name-at-point)))
(_ file-name-at-point))
current-prefix-arg)))
(select-window
(let ((split-height-threshold 15))
(display-buffer (dired-noselect (file-name-directory file))
(if not-this-window
'((display-buffer-reuse-window
display-buffer-pop-up-window)
(inhibit-same-window . t)
(reusable-frames . nil))
'((display-buffer-same-window))))))
(dired-goto-file
(if (file-exists-p file) file
(minibuffer-with-setup-hook (lambda () (goto-char (point-max)))
(read-file-name "Dired Goto File: " nil nil nil file)))))
#+end_src
I use this key binding:
#+begin_src emacs-lisp
(define-key dired-mode-map [(control return)] #'my-dired-jump-close)
#+end_src
Michael.
- Re: Function to find symlink target, (continued)
- Re: Function to find symlink target, Jean Louis, 2022/05/31
- Re: Function to find symlink target, Emanuel Berg, 2022/05/31
- 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, 2022/05/28
Re: Function to find symlink target, Nick Dokos, 2022/05/19