bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior


From: martin rudalics
Subject: bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
Date: Sat, 06 Oct 2012 14:56:51 +0200

> here is a question that Emacs newbies ask often: "How can I configure
> dired so that mouse clicks don't create a new window/frame."
> Unfortunately, this is currently not trivial.
>
> Obviously, Emacs dired differs from most "common" file browsers which
> just replace the current buffer/tab with the content of the clicked
> file.
>
> Not every user will like the behavior of Emacs here - we should give
> users the possibility to configure this easily.
>
> At least, we should define a new command dired-mouse-find-file
> (without "-other-window") which users can bind if they want.  It's
> missing.
>
> But since dired is a very basic and widely used tool, and many newbies
> will not know hooks, I think it would be a better solution if we could
> provide a new user option that controls the behavior of mouse-2 in
> dired in this regard.

The basic problem is that the default for `mouse-1-click-follows-link'
has a short mouse-1 click do the same as mouse-2 whatever the latter is
bound to.  If you set `mouse-1-click-follows-link' to nil, the patch
below should do what you want.

Alternatively, we could bind mouse-2 to a command
`dired-mouse-find-file' which according to some option say
`dired-mouse-find-file-other-window' would visit the file in the
selected or another window.

martin


*** lisp/dired.el       2012-09-30 09:10:59 +0000
--- lisp/dired.el       2012-10-06 10:25:26 +0000
***************
*** 1383,1388 ****
--- 1383,1389 ----
    ;;  (define-key dired-mode-map "\C-d" 'dired-flag-file-deletion)
    (let ((map (make-keymap)))
      (set-keymap-parent map special-mode-map)
+     (define-key map [mouse-1] 'dired-mouse-find-file-this-window)
      (define-key map [mouse-2] 'dired-mouse-find-file-other-window)
      (define-key map [follow-link] 'mouse-face)
      ;; Commands to mark or flag certain categories of files
***************
*** 2047,2055 ****
  ;; Don't override the setting from .emacs.
  ;;;###autoload (put 'dired-find-alternate-file 'disabled t)

! (defun dired-mouse-find-file-other-window (event)
!   "In Dired, visit the file or directory name you click on."
!   (interactive "e")
    (let (window pos file)
      (save-excursion
        (setq window (posn-window (event-end event))
--- 2048,2055 ----
  ;; Don't override the setting from .emacs.
  ;;;###autoload (put 'dired-find-alternate-file 'disabled t)

! (defun dired-mouse-find-file (event &optional other-window)
!   "Subroutine for visting file or directory name clicked on."
    (let (window pos file)
      (save-excursion
        (setq window (posn-window (event-end event))
***************
*** 2064,2072 ****
                 (dired-goto-subdir file))
            (progn
              (select-window window)
!             (dired-other-window file)))
        (select-window window)
!       (find-file-other-window (file-name-sans-versions file t)))))

  (defun dired-view-file ()
    "In Dired, examine a file in view mode, returning to Dired when done.
--- 2064,2086 ----
                 (dired-goto-subdir file))
            (progn
              (select-window window)
!             (if other-window
!                 (dired-other-window file)
!               (dired file))))
        (select-window window)
!       (if other-window
!         (find-file-other-window (file-name-sans-versions file t))
!       (find-file (file-name-sans-versions file t))))))
!
! (defun dired-mouse-find-file-this-window (event)
!   "In Dired, visit the file or directory name you click on in this window."
!   (interactive "e")
!   (dired-mouse-find-file event))
!
! (defun dired-mouse-find-file-other-window (event)
!   "In Dired, visit the file or directory name you click on in other window."
!   (interactive "e")
!   (dired-mouse-find-file event t))

  (defun dired-view-file ()
    "In Dired, examine a file in view mode, returning to Dired when done.








reply via email to

[Prev in Thread] Current Thread [Next in Thread]