Skip to content

Commit 5334bc5

Browse files
committed
Add exec-path
1 parent 7246419 commit 5334bc5

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

lisp/_prepare.el

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,11 @@ other scripts internally. See function `eask-call'.")
228228
(setq command-switch-alist (append command-switch-alist alist))
229229
,@body))
230230

231-
(defun eask-fbound (symbol) (and (fboundp symbol) symbol))
232-
233231
(defconst eask-file-keywords
234232
'("package" "package-file" "files"
235233
"depends-on" "development"
236234
"source" "source-priority"
237-
"load-path" "load-paths")
235+
"exec-path" "exec-paths" "load-path" "load-paths")
238236
"List of Eask file keywords.")
239237

240238
(defun eask--loop-file-keywords (func)
@@ -251,17 +249,16 @@ for function `eask--alias-env'."
251249
Eask file in the workspace."
252250
(declare (indent 0) (debug t))
253251
`(let (result)
252+
;; XXX magic here is we replace all keyword functions with `eask-xxx'...
254253
(eask--loop-file-keywords
255254
(lambda (keyword api old)
256-
(eval `(defvar ,old nil))
257-
(eval `(setq ,old (eask-fbound (quote ,keyword))))
258-
(eval `(defalias (quote ,keyword) (quote ,api)))))
255+
(defalias old (symbol-function keyword))
256+
(defalias keyword (symbol-function api))))
259257
(setq result (progn ,@body))
258+
;; XXX after loading Eask file, we revert those functions back to normal!
260259
(eask--loop-file-keywords
261260
(lambda (keyword api old)
262-
;; TODO: Revert the original function's definition; just in case,
263-
;; anything else don't go wrong
264-
(eval `(defalias (quote ,keyword) (symbol-function ,old)))))
261+
(defalias keyword (symbol-function old))))
265262
result))
266263

267264
(defvar eask-file nil "The Eask file path.")
@@ -304,7 +301,7 @@ Eask file in the workspace."
304301
;; as a sandbox.
305302
(if (eask-file-try-load "./")
306303
(eask-debug "✓ Loading default Eask file in %s... done!" eask-file)
307-
(eask-warn "✗ Loading default Eask file... missing."))
304+
(eask-warn "✗ Loading default Eask file... missing!"))
308305
(message "") ,@body)
309306
(t
310307
(let* ((user-emacs-directory (expand-file-name (concat ".eask/" emacs-version "/")))
@@ -314,7 +311,7 @@ Eask file in the workspace."
314311
(custom-file (locate-user-emacs-file "custom.el")))
315312
(if (eask-file-try-load "../../")
316313
(eask-debug "✓ Loading Eask file in %s... done!" eask-file)
317-
(eask-error "✗ Loading Eask file... missing."))
314+
(eask-error "✗ Loading Eask file... missing!"))
318315
(ignore-errors (make-directory package-user-dir t))
319316
(run-hooks 'eask-before-command-hook)
320317
(run-hooks (intern (concat "eask-before-command-" (eask-command) "-hook")))
@@ -384,6 +381,14 @@ Eask file in the workspace."
384381
"Add all DIRS to load-path."
385382
(dolist (dir dirs) (eask-load-path dir)))
386383

384+
(defun eask-exec-path (dir)
385+
"Add DIR to exec-path."
386+
(add-to-list 'exec-path (expand-file-name dir)))
387+
388+
(defun eask-exec-paths (&rest dirs)
389+
"Add all DIRS to exec-path."
390+
(dolist (dir dirs) (eask-exec-path dir)))
391+
387392
(defun eask-source (name &optional location)
388393
"Add archive NAME with LOCATION."
389394
(setq location (or location (cdr (assq (intern name) eask-source-mapping))))

test/commands/exec/Eask

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
(source "gnu")
21
(source "melpa")
32

43
(package "exec"
@@ -10,6 +9,6 @@
109
(depends-on "emacs" "26.1")
1110
(depends-on "github-elpa")
1211

13-
(load-path "./bin/")
12+
(exec-path "./bin/")
1413

1514
(setq network-security-level 'low) ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432

0 commit comments

Comments
 (0)