first post :)
I wondered if anyone knew a way to quickly change the dired path of of the additional dired (in a split window) to the current dired path? like the traditional OFM synchronize panes?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityNot sure what you want to do with that. You can duplicate the buffer as suggested by @lawlist but then you have both windows displaying the same buffer.
If what you want is two separate dired buffers visiting the same directory (so that you can for example insert subdirs in one but not in the other) you can try this (this is quickly hacked code so it may have pitfalls but it seems to work).
(defun my/get-other-dired-directory ()
"find name and directory of another dired buffer"
(let ((bs (buffer-list))
(here (current-buffer))
this)
(mapc (lambda (b) (unless (equal b here)
(with-current-buffer b
(if dired-directory
(setq this (cons (buffer-name) dired-directory)))))) bs)
this))
(defun my/set-dired-dir-to-other ()
"Change the dired directory to the one of another existing dired buffer"
(interactive)
(let ((d (my/get-other-dired-directory)))
(if d
(progn
(setq dired-directory (cdr d)
default-directory (cdr d))
(revert-buffer)
(rename-buffer (generate-new-buffer-name (car d))))
(message "No other dired buffer"))))
(add-hook 'dired-mode-hook
(lambda () (define-key dired-mode-map "z" #'my/set-dired-dir-to-other)))
What this code does is:
This is bound to the z
key. As usual, put this in your init file.
M-x switch-to-buffer-other-window
The default choice is always that the selected window be duplicated in the other window, although it is possible to select a different buffer to be displayed. If you are in the right window, you can run the functionM-x switch-to-buffer
. Arrow keys can be used in the mini-buffer to navigate possible choices, and there is is also tab completion available to suggest buffers matching the pattern presently in the mini-buffer.