From: Drew Adams <drew.adams@oracle.com>
To: Juri Linkov <juri@linkov.net>, Howard Melman <hmelman@gmail.com>
Cc: "18132@debbugs.gnu.org" <18132@debbugs.gnu.org>
Subject: bug#18132: [External] : bug#18132: Time for a smarter dired-guess-shell-alist-default? (dired-x.el)
Date: Sat, 23 Oct 2021 19:22:33 +0000 [thread overview]
Message-ID: <SJ0PR10MB5488E976659A2B15E4F920A1F3819@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <87sfwr8utt.fsf@mail.linkov.net>
> Such a command is long overdue. I used the following command
> for a long time, and forgot it's not in dired-x. I don't suggest
> to use this implementation, but something like this.
Likewise. There are lots of similar possibilities.
These are what I use, for MS Windows. In Dired,
I have these bindings (plus mouse versions):
C-RET dired-w32explore
M-RET dired-w32-browser
C-M-RET dired-multiple-w32-browser
(defun dired-w32-browser ()
"Run default Windows application associated with current line's file.
If file is a directory, then `dired-find-file' instead.
If no application is associated with file, then `find-file'."
(interactive)
(let ((file (dired-get-filename nil t)))
(if (file-directory-p file)
(dired-find-file)
(w32-browser (subst-char-in-string ?/ ?\\ file)))))
(defun w32-browser (file)
"Run default Windows application associated with FILE.
If no associated application, then `find-file' FILE."
(interactive "fFile: ")
(or (condition-case nil
(w32-shell-execute nil file) ; Use Windows file association
(error nil))
(find-file file)))
(defun dired-w32explore ()
"Open Windows Explorer to current file or folder."
(interactive)
(w32explore (dired-get-filename nil t)))
(defun w32explore (file)
"Open Windows Explorer to FILE (a file or a folder)."
(interactive "fFile: ")
(let ((w32file (subst-char-in-string ?/ ?\\ (expand-file-name file))))
(if (file-directory-p w32file)
(w32-shell-execute "explore" w32file "/e,/select,")
(w32-shell-execute "open" "explorer" (concat "/e,/select," w32file)))))
(defun dired-multiple-w32-browser ()
"Run default Windows applications associated with marked files."
(interactive)
(let ((files (dired-get-marked-files)))
(while files
(w32-browser (car files))
(sleep-for w32-browser-wait-time)
(setq files (cdr files)))))
(defun dlgopen-open-files (&optional flip)
"Open files using the Windows standard Open dialog box.
Var `dlgopen-executable-path' is path of executable `getfile.exe'.
If `w32-browser' is defined, then it is used to open the selected
files. Otherwise, standard Emacs `find-file' functions are used.
If `w32-browser' is not defined, then `dlgopen-other-window'
controls how selected files are opened:
non-nil => Display chosen file(s) in separate windows.
nil => Display a single chosen file in the current window;
don't display multiple chosen files.
Optional prefix arg FLIP non-nil reverses the effect of variable
`dlgopen-other-window', for this call."
(interactive "P")
(unless (eq system-type 'windows-nt)
(error "Command `dlgopen-open-files' is for Windows only"))
(let ((buffer "")
(file-fqn "")
(lines-in-page 0)
(dir-path "")
(other-win (if flip
(not dlgopen-other-window)
dlgopen-other-window)))
(setq buffer (generate-new-buffer "files-to-open"))
(when (call-process dlgopen-executable-path nil buffer)
(with-current-buffer buffer
(save-excursion
(goto-line 1)
(setq dir-path (get-current-line))
;; If buffer empty, then user has cancelled or the open failed.
;; If only one line in buffer, then only one file selected, so use it.
(when (> (buffer-size) 0)
(if (= 1 (setq lines-in-page (count-lines 1 (buffer-size))))
(if (fboundp 'w32-browser)
(w32-browser dir-path)
(if other-win
(find-file-other-window dir-path)
(find-file dir-path)))
(while (> lines-in-page 1)
(decf lines-in-page)
(forward-line)
(setq file-fqn (concat dir-path "/" (get-current-line)))
(save-excursion
(if (fboundp 'w32-browser)
(w32-browser file-fqn)
(if other-win
(find-file-other-window file-fqn)
(find-file-noselect file-fqn)))))))))) ; no display
(kill-buffer buffer)))
next prev parent reply other threads:[~2021-10-23 19:22 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-28 18:26 bug#18132: Time for a smarter dired-guess-shell-alist-default? (dired-x.el) Reuben Thomas
2014-07-28 18:44 ` bug#18132: Sample code Reuben Thomas
2014-07-29 23:49 ` bug#18132: Time for a smarter dired-guess-shell-alist-default? (dired-x.el) Juri Linkov
2014-07-30 9:12 ` Reuben Thomas
2014-07-30 16:32 ` Juri Linkov
2014-07-30 16:44 ` Reuben Thomas
2014-08-04 23:45 ` Juri Linkov
2014-08-05 9:41 ` Reuben Thomas
2021-10-23 5:25 ` Stefan Kangas
2021-10-23 7:44 ` Eli Zaretskii
2021-10-23 8:16 ` Stefan Kangas
2021-10-23 8:34 ` Eli Zaretskii
2021-10-23 9:48 ` Stefan Kangas
2021-10-23 11:48 ` Eli Zaretskii
2021-10-23 13:06 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-23 13:20 ` Eli Zaretskii
2021-10-23 13:01 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-23 13:56 ` Stefan Kangas
2021-10-23 14:03 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-23 15:45 ` Stefan Kangas
2021-10-23 17:17 ` Gregory Heytings
2021-10-23 20:53 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-24 6:02 ` Eli Zaretskii
2021-10-24 7:56 ` Juri Linkov
2023-11-23 17:49 ` Juri Linkov
2023-11-23 19:40 ` Eli Zaretskii
2023-11-24 7:51 ` Juri Linkov
2023-11-24 14:24 ` Eli Zaretskii
2023-11-25 18:10 ` Juri Linkov
2023-11-26 10:37 ` Eli Zaretskii
2023-11-27 17:32 ` Juri Linkov
2023-11-28 17:05 ` Juri Linkov
2023-11-28 17:35 ` Eli Zaretskii
2023-11-29 7:09 ` Juri Linkov
2023-11-29 13:07 ` Eli Zaretskii
2023-12-02 17:44 ` Juri Linkov
2023-12-02 18:37 ` Drew Adams
2023-12-03 17:04 ` Juri Linkov
2023-12-03 21:16 ` Drew Adams
2023-12-06 17:28 ` Juri Linkov
2023-12-07 17:33 ` Juri Linkov
2023-12-07 17:48 ` Eli Zaretskii
2023-12-08 7:37 ` Juri Linkov
2023-12-08 8:08 ` Eli Zaretskii
2023-12-09 17:13 ` Juri Linkov
2021-10-23 17:57 ` Howard Melman
2021-10-23 18:29 ` Juri Linkov
2021-10-23 19:22 ` Drew Adams [this message]
2021-10-24 16:35 ` Howard Melman
2021-10-24 19:08 ` Juri Linkov
2021-10-24 5:10 ` Thierry Volpiatto
2014-07-30 3:56 ` Eli Zaretskii
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=SJ0PR10MB5488E976659A2B15E4F920A1F3819@SJ0PR10MB5488.namprd10.prod.outlook.com \
--to=drew.adams@oracle.com \
--cc=18132@debbugs.gnu.org \
--cc=hmelman@gmail.com \
--cc=juri@linkov.net \
/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).