0

window 10, Emacs 26.1, Dired+

Suppose I open in Dired+ mode some folder:

d:/TEMP/test_folder/folder2/

enter image description here

I need next:

  1. When press button "End" then go to the last file in the folder. Like this:

enter image description here

  1. When press button "Home" then go to the first file in the folder. Like this: enter image description here

  2. When press button "Backspace" then go to the up folder. Like this:

enter image description here

1

1.

(defun my/dired-last-file ()
  (interactive)
  (end-of-buffer)
  (dired-next-line -1))

2.

(defun my/dired-first-file ()
  (interactive)
  (beginning-of-buffer)
  (while (and (not (eobp))
              (or (bolp)
                  (member (dired-get-filename 'no-dir t)
                          '("." ".."))))
    (dired-next-line 1)))
  1. Bind <backspace> to dired-up-directory.
| improve this answer | |
1

Since you mention Dired+, Menu-bar menu Dir, submenu Navigation has these items, with associated keyboard keys:

  • Next Dirline (>)
  • Prev Dirline (<)
  • Next Subdir (C-M-n)
  • Prev Subdir (C-M-p)
  • Up Directory (^)
  • Tree Up (C-M-u)
  • Tree Down (C-M-d)
  • Move To This Subdir (i)

C-M-u and C-M-d are the same in vanilla Dired. Vanilla Dired also offers (less useful) versions of ^, i and C-M-p.

  • For your #1, just use M-> p. Or, if by "the folder" you mean the current subdir, use C-M-n p p.
  • For your #2, you can use M-< n, repeating n as needed. Or, if by "the folder" you mean the current subdir, use C-M-p n, repeating n as needed.
  • For your #3, use C-M-p, possibly repeated.
| improve this answer | |
  • "M -> p" - is not too comfortable combination. I need only press "End" button to go for first file in folder – a_subscriber Jan 24 at 17:26
  • 1
    1. M-> p takes you to the last, not the first, file. (M-< n takes you to the first.) 2. You can bind what it does to any key you like, of course. 3. I think it's not very often that someone wants to go to the last file in a folder (and M-> is well known as moving to the buffer end). – Drew Jan 24 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.