I do not see the "point at line 16" behavior you see: every time I open a directory after killing the buffer, the cursor is on the first file (third line in the buffer, with the default -al
switches). Are you sure you are killing the buffer?
For the reverse sorting, as @Drew points out, calling dired
with a prefix argument (C-u M-x dired
) allows you to specify the SWITCHES
argument: you can add an r
to the default -al
and get a reversed listing. If you want to have reverse listings always, add this line to your init file:
(setq dired-listing-switches "-alr")
or customize the dired-listing-switches
variable.
If you insist on getting to dired
through find-file
, things get a bit harder: I would let-bind the above variable in your function:
(global-set-key (kbd "C-6") (lambda()
(interactive)
(let ((dired-listing-switches "-alr"))
(find-file (format "C:/Users/%s/notes" user-login-name)))))
If you want to go to the beginning of the buffer every time you press C-6
(whether the buffer exists already or not), you can add a (goto-char (point-min))
to your function:
(global-set-key (kbd "C-6") (lambda()
(interactive)
(let ((dired-listing-switches "-alr"))
(find-file (format "C:/Users/%s/notes" user-login-name))
(goto-char (point-min)))))
EDIT: re.the revised sorting spec - I don't think that's possible with ls
switches. You can try adding --group-directories-first
to the dired-listing-switchtes
, but the -r
will reverse the order of the directories as well, so all the directories will appear first in reverse order (so .
and ..
will be at the end of the list of directories) and then all the files will appear in reverse order. I'm not even sure that --group-directories-first
is available on Windows.
SWITCHES
arg todired
, specifying switch-r
.M-x man
ls
is your friend.