unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
@ 2012-04-13  3:34 Michael Heerdegen
  2012-10-06 12:56 ` martin rudalics
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Heerdegen @ 2012-04-13  3:34 UTC (permalink / raw)
  To: 11233

Hi,

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.

(Note: if you want to do something like that, please don't forget to
change the tooltips.)


Regards,

Michael.







^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
  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
  2012-10-06 13:48   ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: martin rudalics @ 2012-10-06 12:56 UTC (permalink / raw)
  To: michael_heerdegen; +Cc: 11233

 > 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.








^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
  2012-10-06 12:56 ` martin rudalics
@ 2012-10-06 13:48   ` Stefan Monnier
  2012-10-06 17:19     ` martin rudalics
  2012-11-13 13:50     ` martin rudalics
  0 siblings, 2 replies; 14+ messages in thread
From: Stefan Monnier @ 2012-10-06 13:48 UTC (permalink / raw)
  To: martin rudalics; +Cc: michael_heerdegen, 11233

> +     (define-key map [mouse-1] 'dired-mouse-find-file-this-window)

I don't think we can use this by default (but a user can have it as
a local customization, of course).

> 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.

I hope we can start moving in this direction, indeed.

As mentioned months ago, I'd like to move away from all the
foo(|-other-(frame-window)) madness since I suspect that most users
only use one of those alternatives.

So instead, we should only have `find-file' (which the user could
customize the use this-window, other-window, or other-frame) and that
would be complemented by new prefix commands that cause the next command
to use "other-window" or "this-window" or "other-frame".


        Stefan





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
  2012-10-06 13:48   ` Stefan Monnier
@ 2012-10-06 17:19     ` martin rudalics
  2012-10-06 18:14       ` Stefan Monnier
  2012-11-13 13:50     ` martin rudalics
  1 sibling, 1 reply; 14+ messages in thread
From: martin rudalics @ 2012-10-06 17:19 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: michael_heerdegen, 11233

 > As mentioned months ago, I'd like to move away from all the
 > foo(|-other-(frame-window)) madness since I suspect that most users
 > only use one of those alternatives.
 >
 > So instead, we should only have `find-file'

Would this be `dired-find-file'?

 > (which the user could
 > customize the use this-window, other-window, or other-frame) and that
 > would be complemented by new prefix commands that cause the next command
 > to use "other-window" or "this-window" or "other-frame".

Prefix commands when using the mouse?

martin





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
  2012-10-06 17:19     ` martin rudalics
@ 2012-10-06 18:14       ` Stefan Monnier
  2012-10-08  6:57         ` martin rudalics
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2012-10-06 18:14 UTC (permalink / raw)
  To: martin rudalics; +Cc: michael_heerdegen, 11233

>> As mentioned months ago, I'd like to move away from all the
>> foo(|-other-(frame-window)) madness since I suspect that most users
>> only use one of those alternatives.
>> So instead, we should only have `find-file'
> Would this be `dired-find-file'?

For dired, yes, probably.

>> (which the user could customize the use this-window, other-window, or
>> other-frame) and that would be complemented by new prefix commands
>> that cause the next command to use "other-window" or "this-window" or
>> "other-frame".
> Prefix commands when using the mouse?

Yup.
Just like C-u can be used for them.  Clearly, it's not convenient if
it's a frequent occurrence, but for occasional use, that's
perfectly fine.


        Stefan





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
  2012-10-06 18:14       ` Stefan Monnier
@ 2012-10-08  6:57         ` martin rudalics
  2012-10-08 11:05           ` Juri Linkov
  2012-10-08 14:12           ` Stefan Monnier
  0 siblings, 2 replies; 14+ messages in thread
From: martin rudalics @ 2012-10-08  6:57 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: michael_heerdegen, 11233

 > Just like C-u can be used for them.  Clearly, it's not convenient if
 > it's a frequent occurrence, but for occasional use, that's
 > perfectly fine.

Suppose we wanted to make it convenient for frequent occurrence:
Wouldn't we have enough modifier combinations available for mouse
clicks?  Say C-S for "other window", M-S for "other frame" ...

martin





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
  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-08 14:12           ` Stefan Monnier
  1 sibling, 2 replies; 14+ messages in thread
From: Juri Linkov @ 2012-10-08 11:05 UTC (permalink / raw)
  To: martin rudalics; +Cc: michael_heerdegen, 11233

> Suppose we wanted to make it convenient for frequent occurrence:
> Wouldn't we have enough modifier combinations available for mouse
> clicks?  Say C-S for "other window", M-S for "other frame" ...

I suggest to use the same modifiers as used in web browsers:
mouse-1 opens in the same window, C-mouse-1 opens in other window
(not selected), C-S-mouse-1 opens in other window (and selected),
S-mouse-1 opens in other frame.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
  2012-10-08 11:05           ` Juri Linkov
@ 2012-10-08 13:33             ` Drew Adams
  2012-10-09  9:36             ` martin rudalics
  1 sibling, 0 replies; 14+ messages in thread
From: Drew Adams @ 2012-10-08 13:33 UTC (permalink / raw)
  To: 'Juri Linkov', 'martin rudalics'; +Cc: michael_heerdegen, 11233

> > Suppose we wanted to make it convenient for frequent occurrence:
> > Wouldn't we have enough modifier combinations available for mouse
> > clicks?  Say C-S for "other window", M-S for "other frame" ...
> 
> I suggest to use the same modifiers as used in web browsers:
> mouse-1 opens in the same window, C-mouse-1 opens in other window
> (not selected), C-S-mouse-1 opens in other window (and selected),
> S-mouse-1 opens in other frame.

I haven't followed this thread; excuse if I've misunderstood.

Please do not make mouse-1 follow links etc., except according to
`mouse-1-click-follows-link'.  A user who has set that option to nil should not
be bothered by having mouse-1 do such things.






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
  2012-10-08  6:57         ` martin rudalics
  2012-10-08 11:05           ` Juri Linkov
@ 2012-10-08 14:12           ` Stefan Monnier
  1 sibling, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2012-10-08 14:12 UTC (permalink / raw)
  To: martin rudalics; +Cc: michael_heerdegen, 11233

>> Just like C-u can be used for them.  Clearly, it's not convenient if
>> it's a frequent occurrence, but for occasional use, that's
>> perfectly fine.
> Suppose we wanted to make it convenient for frequent occurrence:
> Wouldn't we have enough modifier combinations available for mouse
> clicks?  Say C-S for "other window", M-S for "other frame" ...

I guess so.  And the two can be done independently.


        Stefan





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
  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
  1 sibling, 1 reply; 14+ messages in thread
From: martin rudalics @ 2012-10-09  9:36 UTC (permalink / raw)
  To: Juri Linkov; +Cc: michael_heerdegen, 11233

 > I suggest to use the same modifiers as used in web browsers:
 > mouse-1 opens in the same window, C-mouse-1 opens in other window
 > (not selected), C-S-mouse-1 opens in other window (and selected),

Does this mean the buffer would appear in two windows?  On Firefox
C-S-mouse-1 behaves just as C-mouse-1 here.

 > S-mouse-1 opens in other frame.

Would we decode this in `find-file' or `dired-find-file'?  IIUC we'd
have to check

(a) whether the mouse was used at all and, if so, which modifier was
     applied,

(b) whether the mouse was over a text with a this-window / other-window
     / other-frame interpretation, and

(c) what any user customizations wrt prefix key and modifiers are in the
     present context.

`push-button' and `button-activate' do something related.  Could we
interact with these functions?

martin





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
  2012-10-09  9:36             ` martin rudalics
@ 2012-10-09 23:15               ` Juri Linkov
  0 siblings, 0 replies; 14+ messages in thread
From: Juri Linkov @ 2012-10-09 23:15 UTC (permalink / raw)
  To: martin rudalics; +Cc: michael_heerdegen, 11233

>> I suggest to use the same modifiers as used in web browsers:
>> mouse-1 opens in the same window, C-mouse-1 opens in other window
>> (not selected), C-S-mouse-1 opens in other window (and selected),
>
> Does this mean the buffer would appear in two windows?

No, only in one window - in the window where the user wants it to appear.

> On Firefox C-S-mouse-1 behaves just as C-mouse-1 here.

I meant the default settings.  But of course, they should be configurable.

>> S-mouse-1 opens in other frame.
>
> Would we decode this in `find-file' or `dired-find-file'?  IIUC we'd
> have to check
>
> (a) whether the mouse was used at all and, if so, which modifier was
>     applied,
>
> (b) whether the mouse was over a text with a this-window / other-window
>     / other-frame interpretation, and
>
> (c) what any user customizations wrt prefix key and modifiers are in the
>     present context.
>
> `push-button' and `button-activate' do something related.  Could we
> interact with these functions?

This could be processed at the same level where `mouse-1-click-follows-link'
and `mouse-1-click-in-non-selected-windows' are already in effect for
the [follow-link] event.

A more difficult question is how to allow packages to override this default
processing, e.g. allow clicking `C-mouse-1' in Info to clone (fork) the
Info buffer, but `mouse-1' should still visit a link in the same buffer.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
  2012-10-06 13:48   ` Stefan Monnier
  2012-10-06 17:19     ` martin rudalics
@ 2012-11-13 13:50     ` martin rudalics
  2012-11-13 17:42       ` Stefan Monnier
  1 sibling, 1 reply; 14+ messages in thread
From: martin rudalics @ 2012-11-13 13:50 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: michael_heerdegen, 11233

 > As mentioned months ago, I'd like to move away from all the
 > foo(|-other-(frame-window)) madness since I suspect that most users
 > only use one of those alternatives.
 >
 > So instead, we should only have `find-file' (which the user could
 > customize the use this-window, other-window, or other-frame) and that
 > would be complemented by new prefix commands that cause the next command
 > to use "other-window" or "this-window" or "other-frame".

What would an appropriate prefix be and how would it coexist with
ctl-x-4-map and ctl-x-5-map?

martin





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
  2012-11-13 13:50     ` martin rudalics
@ 2012-11-13 17:42       ` Stefan Monnier
  2012-11-14 15:35         ` Michael Heerdegen
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2012-11-13 17:42 UTC (permalink / raw)
  To: martin rudalics; +Cc: michael_heerdegen, 11233

>> As mentioned months ago, I'd like to move away from all the
>> foo(|-other-(frame-window)) madness since I suspect that most users
>> only use one of those alternatives.
>> 
>> So instead, we should only have `find-file' (which the user could
>> customize the use this-window, other-window, or other-frame) and that
>> would be complemented by new prefix commands that cause the next command
>> to use "other-window" or "this-window" or "other-frame".

> What would an appropriate prefix be and how would it coexist with
> ctl-x-4-map and ctl-x-5-map?

The way I see it, C-x 4 would be a new command which sets some vars that
affect subsequent commands (i.e. a prefix command, much like C-u or C-x RET
c) and it would also set-temporary-overlay-map with ctl-x-4-map, so that
C-x 4 f can be used as a shorthand for C-x 4 C-x C-f.


        Stefan





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#11233: 24.1.50; Wishlist: dired mouse-2 other window behavior
  2012-11-13 17:42       ` Stefan Monnier
@ 2012-11-14 15:35         ` Michael Heerdegen
  0 siblings, 0 replies; 14+ messages in thread
From: Michael Heerdegen @ 2012-11-14 15:35 UTC (permalink / raw)
  To: 11233

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

> > What would an appropriate prefix be and how would it coexist with
> > ctl-x-4-map and ctl-x-5-map?
>
> The way I see it, C-x 4 would be a new command which sets some vars that
> affect subsequent commands (i.e. a prefix command, much like C-u or C-x RET
> c) and it would also set-temporary-overlay-map with ctl-x-4-map, so that
> C-x 4 f can be used as a shorthand for C-x 4 C-x C-f.

+1 - that would be great, especially if that worked with all stuff like
C-h i, C-x r j, M-x find-function, ...  But I think it's not trivial to
implement this.  E.g. when using C-x 5, I don't necessarily want
*Completions* to pop up in a new frame.





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-11-14 15:35 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).