unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#64079: 28.2; dired-mouse-find-file does not respect dired-kill-when-opening-new-dired-buffer
@ 2023-06-15  8:54 Fadi Moukayed
  2023-06-15 10:48 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Fadi Moukayed @ 2023-06-15  8:54 UTC (permalink / raw)
  To: 64079

Hi all,

While attempting to rebind mouse-3 to `dired-mouse-find-file', I noticed
that the `dired-kill-when-opening-new-dired-buffer' customization option
is not being respected. `dired-mouse-find-file' opens directories in new
dired buffers in all cases.

Steps to reproduce:

1. Start Emacs
2. Open a `dired' buffer, e.g. using C-x d
3. Use M-: and evaluate the expression `(define-key dired-mode-map [mouse-3]
'dired-mouse-find-file)'
4. Navigate a nested directory tree (e.g. a/b/c/d) in dired by right-clicking
on the directory names.

Expected behavior:

Only a dired buffer for d is retained.

Observed behavior:

dired buffers a, b, c are created and retained in addition to d.

Hints:

`dired-mouse-find-file' needs to contain similar logic to
`dired--find-possibly-alternative-file' for checking the customization
variable, or needs to delegate to the latter function.

---

In GNU Emacs 28.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20,
cairo version 1.16.0)
 of 2023-06-02 built on lcy02-amd64-102
Repository revision: 08cc469f8738bad2a31ce5b4c4c55301b71d598b
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12201001
System Description: Ubuntu 22.04.2 LTS

Configured using:
 'configure --prefix=/snap/emacs/current/usr --with-x-toolkit=gtk3
 --without-xaw3d --with-modules --with-cairo --with-native-compilation
 'CFLAGS=-isystem/build/emacs/parts/emacs/install/usr/include
 -isystem/build/emacs/parts/emacs/install/usr/include/x86_64-linux-gnu
 -O2' 'CPPFLAGS=-isystem/build/emacs/parts/emacs/install/usr/include
 -isystem/build/emacs/parts/emacs/install/usr/include/x86_64-linux-gnu'
 'LDFLAGS=-L/build/emacs/parts/emacs/install/lib
 -L/build/emacs/parts/emacs/install/usr/lib
 -L/build/emacs/parts/emacs/install/lib/x86_64-linux-gnu
 -L/build/emacs/parts/emacs/install/usr/lib/x86_64-linux-gnu''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB

Important settings:
  value of $LANG: de_DE.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Org

Minor modes in effect:
  display-line-numbers-mode: t
  shell-dirtrack-mode: t
  delete-selection-mode: t
  recentf-mode: t
  global-whitespace-mode: t
  global-goto-address-mode: t
  goto-address-mode: t
  fido-vertical-mode: t
  icomplete-vertical-mode: t
  icomplete-mode: t
  fido-mode: t
  desktop-save-mode: t
  cua-mode: t
  windmove-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  prettify-symbols-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug sendmail display-line-numbers
org-element avl-tree generator ol-eww eww xdg url-queue mm-url ol-rmail
ol-mhe ol-irc ol-info ol-gnus nnselect gnus-search eieio-opt speedbar
ezimage dframe gnus-art mm-uu mml2015 mm-view mml-smime smime dig
gnus-sum shr kinsoku svg dom gnus-group gnus-undo gnus-start gnus-dbus
dbus xml gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo gnus-spec
gnus-int gnus-range message rmc puny rfc822 mml mml-sec epa derived epg
rfc6068 epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader gnus-win gnus nnheader gnus-util rmail
rmail-loaddefs rfc2047 rfc2045 ietf-drums text-property-search
mail-utils mm-util mail-prsvr ol-docview doc-view jka-compr image-mode
exif dired dired-loaddefs ol-bibtex ol-bbdb ol-w3m ol-doi org-link-doi
org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote
org-src ob-comint org-pcomplete org-list org-faces org-entities noutline
outline easy-mmode org-version ob-emacs-lisp ob-core ob-eval org-table
oc-basic bibtex ol org-keys oc org-compat advice org-macs org-loaddefs
find-func cal-menu calendar cal-loaddefs tramp-cache tramp-sh tramp
tramp-loaddefs trampver tramp-integration files-x tramp-compat shell
pcomplete comint ansi-color ring parse-time iso8601 time-date ls-lisp
format-spec disp-table dracula-theme pcase delsel recentf tree-widget
wid-edit whitespace goto-addr thingatpt icomplete desktop frameset
cua-base cus-load finder-inf windmove edmacro kmacro site-start comp
comp-cstr warnings rx cl-extra help-mode info slime-autoloads package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice
button loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 495514 24906)
 (symbols 48 30214 1)
 (strings 32 149409 4103)
 (string-bytes 1 4176844)
 (vectors 16 55880)
 (vector-slots 8 1622923 37169)
 (floats 8 363 740)
 (intervals 56 619 88)
 (buffers 992 12))





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

* bug#64079: 28.2; dired-mouse-find-file does not respect dired-kill-when-opening-new-dired-buffer
  2023-06-15  8:54 bug#64079: 28.2; dired-mouse-find-file does not respect dired-kill-when-opening-new-dired-buffer Fadi Moukayed
@ 2023-06-15 10:48 ` Eli Zaretskii
  2023-06-15 11:10   ` Fadi Moukayed
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2023-06-15 10:48 UTC (permalink / raw)
  To: Fadi Moukayed; +Cc: 64079

> From: Fadi Moukayed <smfadi@gmail.com>
> Date: Thu, 15 Jun 2023 10:54:27 +0200
> 
> 1. Start Emacs
> 2. Open a `dired' buffer, e.g. using C-x d
> 3. Use M-: and evaluate the expression `(define-key dired-mode-map [mouse-3]
> 'dired-mouse-find-file)'
> 4. Navigate a nested directory tree (e.g. a/b/c/d) in dired by right-clicking
> on the directory names.
> 
> Expected behavior:
> 
> Only a dired buffer for d is retained.
> 
> Observed behavior:
> 
> dired buffers a, b, c are created and retained in addition to d.
> 
> Hints:
> 
> `dired-mouse-find-file' needs to contain similar logic to
> `dired--find-possibly-alternative-file' for checking the customization
> variable, or needs to delegate to the latter function.

Thanks.  Does the patch below give good results?

diff --git a/lisp/dired.el b/lisp/dired.el
index 4a4ecc9..de87530 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -2765,10 +2765,11 @@ dired-mouse-find-file
 The optional arguments FIND-FILE-FUNC and FIND-DIR-FUNC specify
 functions to visit the file and directory, respectively.  If
 omitted or nil, these arguments default to `find-file' and `dired',
-respectively."
+respectively.  If `dired-kill-when-opening-new-dired-buffer' is
+non-nil, FIND-DIR-FUNC defaults to `find-alternate-file' instead,
+so that the original Dired buffer is not kept."
   (interactive "e")
   (or find-file-func (setq find-file-func 'find-file))
-  (or find-dir-func (setq find-dir-func 'dired))
   (let (window pos file)
     (save-excursion
       (setq window (posn-window (event-end event))
@@ -2776,6 +2777,12 @@ dired-mouse-find-file
       (if (not (windowp window))
 	  (error "No file chosen"))
       (set-buffer (window-buffer window))
+      (unless find-dir-func
+        (setq find-dir-func
+              (if (and dired-kill-when-opening-new-dired-buffer
+                       (< (length (get-buffer-window-list)) 2))
+                  'find-alternate-file
+                'dired)))
       (goto-char pos)
       (setq file (dired-get-file-for-visit)))
     (if (file-directory-p file)





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

* bug#64079: 28.2; dired-mouse-find-file does not respect dired-kill-when-opening-new-dired-buffer
  2023-06-15 10:48 ` Eli Zaretskii
@ 2023-06-15 11:10   ` Fadi Moukayed
  2023-06-15 13:14     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Fadi Moukayed @ 2023-06-15 11:10 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 64079

Hi Eli,

Thanks a lot. Just tested your patch a few moments ago (with
dired-kill-when-opening-new-dired-bufferset to t) and it fixes the issue.

I also tested the default behavior (with
dired-kill-when-opening-new-dired-buffer
set to nil), and everything works as expected in that case as well.

Cheers.

Am Do., 15. Juni 2023 um 12:48 Uhr schrieb Eli Zaretskii <eliz@gnu.org>:
>
> > From: Fadi Moukayed <smfadi@gmail.com>
> > Date: Thu, 15 Jun 2023 10:54:27 +0200
> >
> > 1. Start Emacs
> > 2. Open a `dired' buffer, e.g. using C-x d
> > 3. Use M-: and evaluate the expression `(define-key dired-mode-map [mouse-3]
> > 'dired-mouse-find-file)'
> > 4. Navigate a nested directory tree (e.g. a/b/c/d) in dired by right-clicking
> > on the directory names.
> >
> > Expected behavior:
> >
> > Only a dired buffer for d is retained.
> >
> > Observed behavior:
> >
> > dired buffers a, b, c are created and retained in addition to d.
> >
> > Hints:
> >
> > `dired-mouse-find-file' needs to contain similar logic to
> > `dired--find-possibly-alternative-file' for checking the customization
> > variable, or needs to delegate to the latter function.
>
> Thanks.  Does the patch below give good results?
>
> diff --git a/lisp/dired.el b/lisp/dired.el
> index 4a4ecc9..de87530 100644
> --- a/lisp/dired.el
> +++ b/lisp/dired.el
> @@ -2765,10 +2765,11 @@ dired-mouse-find-file
>  The optional arguments FIND-FILE-FUNC and FIND-DIR-FUNC specify
>  functions to visit the file and directory, respectively.  If
>  omitted or nil, these arguments default to `find-file' and `dired',
> -respectively."
> +respectively.  If `dired-kill-when-opening-new-dired-buffer' is
> +non-nil, FIND-DIR-FUNC defaults to `find-alternate-file' instead,
> +so that the original Dired buffer is not kept."
>    (interactive "e")
>    (or find-file-func (setq find-file-func 'find-file))
> -  (or find-dir-func (setq find-dir-func 'dired))
>    (let (window pos file)
>      (save-excursion
>        (setq window (posn-window (event-end event))
> @@ -2776,6 +2777,12 @@ dired-mouse-find-file
>        (if (not (windowp window))
>           (error "No file chosen"))
>        (set-buffer (window-buffer window))
> +      (unless find-dir-func
> +        (setq find-dir-func
> +              (if (and dired-kill-when-opening-new-dired-buffer
> +                       (< (length (get-buffer-window-list)) 2))
> +                  'find-alternate-file
> +                'dired)))
>        (goto-char pos)
>        (setq file (dired-get-file-for-visit)))
>      (if (file-directory-p file)





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

* bug#64079: 28.2; dired-mouse-find-file does not respect dired-kill-when-opening-new-dired-buffer
  2023-06-15 11:10   ` Fadi Moukayed
@ 2023-06-15 13:14     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2023-06-15 13:14 UTC (permalink / raw)
  To: Fadi Moukayed; +Cc: 64079-done

> From: Fadi Moukayed <smfadi@gmail.com>
> Date: Thu, 15 Jun 2023 13:10:25 +0200
> Cc: 64079@debbugs.gnu.org
> 
> Hi Eli,
> 
> Thanks a lot. Just tested your patch a few moments ago (with
> dired-kill-when-opening-new-dired-bufferset to t) and it fixes the issue.
> 
> I also tested the default behavior (with
> dired-kill-when-opening-new-dired-buffer
> set to nil), and everything works as expected in that case as well.

Thanks for testing.  I've now installed the fix on the emacs-29
branch, and I'm closing this bug.





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

end of thread, other threads:[~2023-06-15 13:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-15  8:54 bug#64079: 28.2; dired-mouse-find-file does not respect dired-kill-when-opening-new-dired-buffer Fadi Moukayed
2023-06-15 10:48 ` Eli Zaretskii
2023-06-15 11:10   ` Fadi Moukayed
2023-06-15 13:14     ` Eli Zaretskii

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