Fix prelude-open-with
Currently, `prelude-open-with` does not work with files whose name has a space or non-ascii character in it. I guess `shell-quote-argument` is not needed for `start-process`. I also refactor the code a little bit, and since we dot not care about the output of `open`, so I removed the buffer name passed to `start-process`
This commit is contained in:
parent
1d52d90af9
commit
933fed932f
1 changed files with 11 additions and 12 deletions
|
@ -42,18 +42,17 @@ When in dired mode, open file under the cursor.
|
||||||
|
|
||||||
With a prefix ARG always prompt for command to use."
|
With a prefix ARG always prompt for command to use."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(let ((current-file-name
|
(let* ((current-file-name
|
||||||
(if (eq major-mode 'dired-mode)
|
(if (eq major-mode 'dired-mode)
|
||||||
(dired-get-file-for-visit)
|
(dired-get-file-for-visit)
|
||||||
buffer-file-name)))
|
buffer-file-name))
|
||||||
(when current-file-name
|
(open (pcase system-type
|
||||||
(start-process "prelude-open-with-process"
|
(`darwin "open")
|
||||||
"*prelude-open-with-output*"
|
((pred (string-prefix-p "gnu")) "xdg-open")))
|
||||||
(cond
|
(program (if (or arg (not open))
|
||||||
((and (not arg) (eq system-type 'darwin)) "open")
|
(read-shell-command "Open current file with: ")
|
||||||
((and (not arg) (member system-type '(gnu gnu/linux gnu/kfreebsd))) "xdg-open")
|
open)))
|
||||||
(t (read-shell-command "Open current file with: ")))
|
(start-process "prelude-open-with-process" nil program current-file-name)))
|
||||||
(shell-quote-argument current-file-name)))))
|
|
||||||
|
|
||||||
(defun prelude-buffer-mode (buffer-or-name)
|
(defun prelude-buffer-mode (buffer-or-name)
|
||||||
"Retrieve the `major-mode' of BUFFER-OR-NAME."
|
"Retrieve the `major-mode' of BUFFER-OR-NAME."
|
||||||
|
|
Loading…
Reference in a new issue