Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use xdg-open on Linux and open on macOS instead of browse-url #31

Open
suliveevil opened this issue Dec 8, 2022 · 3 comments
Open

use xdg-open on Linux and open on macOS instead of browse-url #31

suliveevil opened this issue Dec 8, 2022 · 3 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@suliveevil
Copy link

Debugger entered--Lisp error: (wrong-type-argument commandp d2-open-browser)
  call-interactively(d2-open-browser nil nil)
  command-execute(d2-open-browser)

I know how to fix it but didn't learn enough emacs-lisp knowledge to achieve it. 🤣

@suliveevil
Copy link
Author

suliveevil commented Dec 8, 2022

Find a function to open file in default app

;; https://emacs-china.org/t/pdf/14954/5
(defun my/open-with (arg)
  "使用外部程序打开浏览的文件或者当前光标下的链接.
处于 dired mode 时, 打开当前光标下的文件;
若当前光标下存在链接,使用外部程序打开链接;
使用 prefix ARG 时指定使用的外部程序."
  (interactive "P")
  (let ((current-file-name
         (cond ((eq major-mode 'dired-mode) (dired-get-file-for-visit))
               ((help-at-pt-string)
                (pcase (cdr (split-string (help-at-pt-string) ":" t " "))
                  ((or `(,path) `(,(pred (string= "file")) ,path) `(,_ ,path ,_))
                   (expand-file-name path))
                  (`(,proto ,path) (concat proto ":" path))))
               (t (or (thing-at-point 'url) buffer-file-name))))
        (program (if arg
                     (read-shell-command "Open current file with: ")
                   "open")))
    (call-process program nil 0 nil current-file-name)))

@andorsk
Copy link
Owner

andorsk commented Dec 8, 2022

Thanks @suliveevil . I can't address this now but will put this on the docket to address as soon as possible.

@andorsk andorsk self-assigned this Dec 8, 2022
@andorsk andorsk added this to the 0.2 milestone Dec 8, 2022
@andorsk andorsk added the enhancement New feature or request label Dec 13, 2022
@arstum
Copy link

arstum commented Feb 5, 2023

The same as mine, it still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants