6868 package-archives nil ; Leave it to custom use
6969 package-archive-priorities nil )
7070
71+ (defvar eask-dot-emacs-file nil
72+ " Variable hold .emacs file location." )
73+
7174(defun eask--load--adv (fnc &rest args )
7275 " Prevent `_prepare.el' loading twice.
7376
@@ -136,7 +139,10 @@ will return `lint/checkdoc' with a dash between two subcommands."
136139 " /" ))))
137140
138141(defun eask-special-p ()
139- " Return t if the command that can be run without Eask-file existence."
142+ " Return t if the command that can be run without Eask-file existence.
143+
144+ These commands will first respect the current workspace. If the current
145+ workspace has no valid Eask-file; it will load global workspace instead."
140146 (member (eask-command) '(" init/cask" " init/eldev" " init/keg"
141147 " init/source"
142148 " bump" " cat" " keywords"
@@ -907,14 +913,7 @@ If the optional argument INDEX is non-nil, return the element."
907913 " Execute BODY with workspace setup."
908914 (declare (indent 0 ) (debug t ))
909915 `(eask--batch-mode
910- (let (; ; XXX: this will make command `info' , `files' work as expected;
911- ; ; but the relative paths file spec will be lost...
912- ; ;
913- ; ; So commands like `load' would NOT work!
914- (default-directory (cond ((eask-global-p) eask-homedir)
915- ((eask-config-p) user-emacs-directory)
916- (t default-directory)))
917- (alist))
916+ (let ((alist))
918917 (dolist (cmd eask--command-list)
919918 (push (cons cmd (lambda (&rest _ ))) alist))
920919 (setq command-switch-alist (append command-switch-alist alist))
@@ -1049,10 +1048,24 @@ This uses function `locate-dominating-file' to look up directory tree."
10491048 `(let* ((user-emacs-directory (expand-file-name (concat " .eask/" emacs-version " /" ) , dir ))
10501049 (package-user-dir (expand-file-name " elpa" user-emacs-directory))
10511050 (early-init-file (locate-user-emacs-file " early-init.el" ))
1051+ (eask-dot-emacs-file (locate-user-emacs-file " .emacs" ))
10521052 (user-init-file (locate-user-emacs-file " init.el" ))
10531053 (custom-file (locate-user-emacs-file " custom.el" )))
10541054 ,@body ))
10551055
1056+ (defun eask--load-config ()
1057+ " Load configuration if valid."
1058+ (let ((inhibit-config (eask-quick-p)))
1059+ (eask-with-progress
1060+ (ansi-green " Loading configuration... " )
1061+ (eask-with-verbosity 'all
1062+ (unless inhibit-config
1063+ (when (version<= " 27" emacs-version)
1064+ (load early-init-file t ))
1065+ (load eask-dot-emacs-file t )
1066+ (load user-init-file t )))
1067+ (ansi-green (if inhibit-config " skipped ✗" " done ✓" )))))
1068+
10561069(defmacro eask-start (&rest body )
10571070 " Execute BODY with workspace setup."
10581071 (declare (indent 0 ) (debug t ))
@@ -1062,44 +1075,59 @@ This uses function `locate-dominating-file' to look up directory tree."
10621075 (eask--setup-env
10631076 (eask--handle-global-options)
10641077 (cond
1065- ((or (eask-global-p) (eask-special-p)) ; Commands without Eask-file needed!
1078+ ((eask-config-p)
1079+ (let ((early-init-file (locate-user-emacs-file " early-init.el" ))
1080+ (eask-dot-emacs-file (locate-user-emacs-file " ../.emacs" ))
1081+ (user-init-file (locate-user-emacs-file " init.el" )))
1082+ ; ; We accept Eask-file in `config' scope, but it shouldn't be used
1083+ ; ; for the sandbox.
1084+ (eask-with-verbosity 'debug
1085+ (if (eask-file-try-load user-emacs-directory)
1086+ (eask-msg " ✓ Loading config Eask file in %s... done!" eask-file)
1087+ (eask-msg " ✗ Loading config Eask file... missing!" ))
1088+ (eask-msg " " ))
1089+ (package-activate-all )
1090+ (eask--load-config)
1091+ (eask--with-hooks ,@body )))
1092+ ((eask-global-p)
10661093 (eask--setup-home (concat eask-homedir " ../" ) ; `/home/user/' , escape `.eask'
10671094 (let ((eask--first-init-p (not (file-directory-p user-emacs-directory))))
10681095 ; ; We accept Eask-file in `global' scope, but it shouldn't be used
10691096 ; ; for the sandbox.
10701097 (eask-with-verbosity 'debug
1071- (eask-ignore-errors ; Again, without Eask-file needed !
1072- (if (eask-file-try-load " ./ " )
1098+ (eask-ignore-errors ; Eask-file is optional !
1099+ (if (eask-file-try-load eask-homedir )
10731100 (eask-msg " ✓ Loading global Eask file in %s... done!" eask-file)
10741101 (eask-msg " ✗ Loading global Eask file... missing!" )))
10751102 (eask-msg " " ))
10761103 (package-activate-all )
10771104 (ignore-errors (make-directory package-user-dir t ))
1105+ (eask-with-verbosity 'debug (eask--load-config))
1106+ (eask--with-hooks ,@body ))))
1107+ ((eask-special-p) ; Commands without Eask-file needed!
1108+ ; ; First, try to find a valid Eask-file!
1109+ (eask-file-try-load default-directory)
1110+ ; ; Then setup the user directory according to the Eask-file!
1111+ (eask--setup-home (or eask-file-root
1112+ (concat eask-homedir " ../" ))
1113+ (let ((eask--first-init-p (not (file-directory-p user-emacs-directory)))
1114+ (scope (if eask-file-root " " " global " )))
1115+ (eask-with-verbosity 'debug
1116+ (eask-ignore-errors ; Again, without Eask-file needed!
1117+ (if (or eask-file-root
1118+ (eask-file-try-load eask-homedir))
1119+ (eask-msg " ✓ Loading %sEask file in %s... done!" scope eask-file)
1120+ (eask-msg " ✗ Loading %sEask file... missing!" scope)))
1121+ (eask-msg " " ))
1122+ (package-activate-all )
1123+ (ignore-errors (make-directory package-user-dir t ))
1124+ (eask-with-verbosity 'debug (eask--load-config))
10781125 (eask--with-hooks ,@body ))))
1079- ((eask-config-p)
1080- (let ((inhibit-config (eask-quick-p)))
1081- ; ; We accept Eask-file in `config' scope, but it shouldn't be used
1082- ; ; for the sandbox.
1083- (eask-with-verbosity 'debug
1084- (if (eask-file-try-load " ./" )
1085- (eask-msg " ✓ Loading config Eask file in %s... done!" eask-file)
1086- (eask-msg " ✗ Loading config Eask file... missing!" ))
1087- (eask-msg " " ))
1088- (package-activate-all )
1089- (eask-with-progress
1090- (ansi-green " Loading your configuration... " )
1091- (eask-with-verbosity 'all
1092- (unless inhibit-config
1093- (load (locate-user-emacs-file " early-init.el" ) t )
1094- (load (locate-user-emacs-file " ../.emacs" ) t )
1095- (load (locate-user-emacs-file " init.el" ) t )))
1096- (ansi-green (if inhibit-config " skipped ✗" " done ✓" )))
1097- (eask--with-hooks ,@body )))
10981126 (t
10991127 (eask--setup-home nil ; `nil' is the `default-directory'
11001128 (let ((eask--first-init-p (not (file-directory-p user-emacs-directory))))
11011129 (eask-with-verbosity 'debug
1102- (if (eask-file-try-load " ./ " )
1130+ (if (eask-file-try-load default-directory )
11031131 (eask-msg " ✓ Loading Eask file in %s... done!" eask-file)
11041132 (eask-msg " ✗ Loading Eask file... missing!" ))
11051133 (eask-msg " " ))
@@ -1108,6 +1136,7 @@ This uses function `locate-dominating-file' to look up directory tree."
11081136 (package-activate-all )
11091137 (ignore-errors (make-directory package-user-dir t ))
11101138 (eask--silent (eask-setup-paths))
1139+ (eask-with-verbosity 'debug (eask--load-config))
11111140 (eask--with-hooks ,@body ))))))))))
11121141
11131142; ;
0 commit comments