File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -337,6 +337,29 @@ current process."
337
337
(delete-file (+lock--file name))
338
338
t ))
339
339
340
+ (autoload #'mailcap-extension-to-mime " mailcap" )
341
+
342
+ ;;;### autoload
343
+ (defun +open-with-default-app (&optional file-or-url)
344
+ " Open FILE-OR-URL in the system's default application (via \" xdg-open\" ).
345
+
346
+ When FILE-OR-URL is nil, try to guess a file/directory name or ask for one."
347
+ (interactive )
348
+ (let* ((file (or file-or-url
349
+ ; ; When in `dired' , get file at point
350
+ (and (derived-mode-p 'dired-mode ) (dired-x-guess-file-name-at-point))
351
+ (thing-at-point 'existing-filename )
352
+ (thing-at-point 'url )
353
+ (read-file-name " File or directory to open: " nil default-directory)))
354
+ (file-ext (file-name-extension file))
355
+ (file-mime (and file-ext (mailcap-extension-to-mime file-ext)))
356
+ (default-app (or (and file-mime (car (xdg-mime-apps file-mime))) " " )))
357
+ (if (and file-mime (string-match-p " ^emacs\\ (client\\ )?$" (file-name-base default-app)))
358
+ (progn (message " The default application for %S files (*.%s ) is Emacs, openning with `find-file' . " file-mime file-ext)
359
+ (find-file file))
360
+ (message " Opening %S with the default system application... " (abbreviate-file-name file))
361
+ (call-process-shell-command (format " xdg-open %S " (expand-file-name file))))))
362
+
340
363
;;;### autoload
341
364
(defun +minemacs-root-dir-cleanup ()
342
365
(let ((default-directory minemacs-root-dir))
You can’t perform that action at this time.
0 commit comments