unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: michael_heerdegen@web.de
Cc: 11233@debbugs.gnu.org
Subject: bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
Date: Sat, 06 Oct 2012 14:56:51 +0200	[thread overview]
Message-ID: <50702A93.7060008@gmx.at> (raw)
In-Reply-To: <86vcl4uwxa.fsf@web.de>

 > 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	other threads:[~2012-10-06 12:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-13  3:34 bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior Michael Heerdegen
2012-10-06 12:56 ` martin rudalics [this message]
2012-10-06 13:48   ` Stefan Monnier
2012-10-06 17:19     ` martin rudalics
2012-10-06 18:14       ` Stefan Monnier
2012-10-08  6:57         ` martin rudalics
2012-10-08 11:05           ` Juri Linkov
2012-10-08 13:33             ` Drew Adams
2012-10-09  9:36             ` martin rudalics
2012-10-09 23:15               ` Juri Linkov
2012-10-08 14:12           ` Stefan Monnier
2012-11-13 13:50     ` martin rudalics
2012-11-13 17:42       ` Stefan Monnier
2012-11-14 15:35         ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50702A93.7060008@gmx.at \
    --to=rudalics@gmx.at \
    --cc=11233@debbugs.gnu.org \
    --cc=michael_heerdegen@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).