summaryrefslogtreecommitdiff
path: root/modules/external-open.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-10 15:37:36 -0500
committerCraig Jennings <c@cjennings.net>2026-05-10 15:37:36 -0500
commit618bc7813b9acfcf1dfccc9c6590f6f5aece86cf (patch)
tree5719792c87bbc74ae380eb020a39d42b2ac86e48 /modules/external-open.el
parentf59ff9606fd96c6b1b9037ea5befb39b5e5a57b9 (diff)
downloaddotemacs-618bc7813b9acfcf1dfccc9c6590f6f5aece86cf.tar.gz
dotemacs-618bc7813b9acfcf1dfccc9c6590f6f5aece86cf.zip
refactor(external-open): extract external-open-lib for shared helpers
Same shared-helpers split-pattern that ai-vterm/vterm-config use through cj-window-toggle-lib and that calendar-sync uses through cj-org-text-lib. Pull the two pure dispatch helpers out of the external-open feature module into a sibling library so consumers that only need the dispatch don't have to require the whole feature. New `modules/external-open-lib.el' carries: - `cj/external-open-command' - `cj/external-open-launcher-p' `modules/external-open.el' stays as the feature module: the `default-open-extensions' defcustom, the `find-file' advice (`cj/find-file-auto'), and the interactive commands (`cj/xdg-open', `cj/open-this-file-with'). It now requires external-open-lib for the dispatch helpers. Migrate consumers: - system-utils.el used to require `external-open' for `cj/external-open-launcher-p' alone -- now requires `external-open-lib' directly. - dirvish-config.el calls `cj/external-open-command' from `cj/dirvish-open-file-manager-here' -- add an explicit `(require \='external-open-lib)'. Test files renamed to match the system-lib naming pattern (test-<library>-<feature>.el): - test-external-open-command.el -> test-external-open-lib-command.el - test-external-open-launcher-p.el -> test-external-open-lib-launcher-p.el No behavior change.
Diffstat (limited to 'modules/external-open.el')
-rw-r--r--modules/external-open.el23
1 files changed, 1 insertions, 22 deletions
diff --git a/modules/external-open.el b/modules/external-open.el
index c9b5f1f6..0d6ec520 100644
--- a/modules/external-open.el
+++ b/modules/external-open.el
@@ -23,6 +23,7 @@
(require 'host-environment) ;; environment information functions
(require 'system-lib) ;; for cj/file-from-context
+(require 'external-open-lib) ;; pure dispatch helpers
(require 'cl-lib)
;; Declare platform-specific functions
@@ -89,28 +90,6 @@
:type '(repeat (regexp :tag "File extension regexp"))
:group 'external-open)
-;; ----------------------- External-Open Command Resolution -------------------
-
-(defun cj/external-open-command ()
- "Return the OS-default \"open\" command for this host, or nil if unsupported.
-Returns one of \"xdg-open\" (Linux), \"open\" (macOS), \"start\" (Windows).
-Callers that require a command should error on nil with a contextual
-message so the user sees what feature is unavailable."
- (cond
- ((env-linux-p) "xdg-open")
- ((env-macos-p) "open")
- ((env-windows-p) "start")
- (t nil)))
-
-(defun cj/external-open-launcher-p (command)
- "Return non-nil when COMMAND is a desktop launcher.
-Launchers (xdg-open, open, start) need to be called with `call-process'
-and a zero BUFFER argument so they fully detach from Emacs. Other
-commands get `start-process-shell-command' so their output is visible."
- (and (stringp command)
- (member command '("xdg-open" "open" "start"))
- t))
-
(defun cj/xdg-open (&optional filename)
"Open FILENAME (or the file at point) with the OS default handler.
Logs output and exit code to buffer *external-open.log*."