2

I exclusively use frames and I've long wondered if there's a way to get dired-dwim-target to suggest a dired buffer from another frame instead of just another window.

1

Redefine dired-dwim-target-directory so that in the call to get-window-with-predicate it passes a non-nil value (e.g., visible) for optional arg ALL-FRAMES:

(defun dired-dwim-target-directory ()
  ;; Try to guess which target directory the user may want.
  ;; If there is a dired buffer displayed in one of the next windows,
  ;; use its current subdir, else use current subdir of this dired buffer.
  (let ((this-dir (and (eq major-mode 'dired-mode)
               (dired-current-directory))))
    ;; non-dired buffer may want to profit from this function, e.g. vm-uudecode
    (if dired-dwim-target
    (let* ((other-win (get-window-with-predicate
                       (lambda (window)
                         (with-current-buffer (window-buffer window)
                           (eq major-mode 'dired-mode)))
                         nil
                         'visible)) ; <========================
           (other-dir (and other-win
                           (with-current-buffer (window-buffer other-win)
                             (and (eq major-mode 'dired-mode)
                                  (dired-current-directory))))))
      (or other-dir this-dir))
      this-dir)))

And please consider filing an enhancement request (M-x report-emacs-bug), suggesting, for example, that this argument be taken from the value of pop-up-frames (or from a new user option or from something else). The idea is to let users decide whether the Dired buffer is to be in another window of the same frame or in any (visible) frame.


UPDATE

I've added this to Dired+ (dired+.el), so it should work out-of-the-box. It respects a new Boolean option, diredp-dwim-any-frame-flag: non-nil means look also in other frames. The default value is the value of pop-up-frames (so if that option is non-nil then so is diredp-dwim-any-frame-flag).

  • A gentleman and scholar. Thank you! – Tom Davis Mar 8 '15 at 20:10
  • Still, please consider filing an enhancement request for vanilla Emacs. Emacs developers tend to overlook the use cases of "exclusively using frames". That's understandable, I guess, but it doesn't mean that improvements to handle such use cases are not desirable. ;-) – Drew Mar 8 '15 at 21:34

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.