Replace calls to (getenv "BRIEFCASE") with constants/briefcase
I would prefer to define constants/briefcase in terms of `(getenv "BRIEFCASE")` and assert that `(f-exists? (getenv "BRIEFCASE"))`, in one location: constants.el
This commit is contained in:
		
							parent
							
								
									21ce27b0ca
								
							
						
					
					
						commit
						8eed16dc67
					
				
					 4 changed files with 17 additions and 10 deletions
				
			
		|  | @ -21,6 +21,7 @@ | ||||||
| (require 'list) | (require 'list) | ||||||
| (require 'string) | (require 'string) | ||||||
| (require 'set) | (require 'set) | ||||||
|  | (require 'constants) | ||||||
| 
 | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| ;; Constants | ;; Constants | ||||||
|  | @ -60,7 +61,7 @@ Otherwise, open with `counsel-find-file'." | ||||||
|                   :path "~/depot" |                   :path "~/depot" | ||||||
|                   :kbd "t") |                   :kbd "t") | ||||||
|    (make-bookmark :label "briefcase" |    (make-bookmark :label "briefcase" | ||||||
|                   :path (getenv "BRIEFCASE") |                   :path constants/briefcase | ||||||
|                   :kbd "b") |                   :kbd "b") | ||||||
|    (make-bookmark :label "current project" |    (make-bookmark :label "current project" | ||||||
|                   :path constants/current-project |                   :path constants/current-project | ||||||
|  |  | ||||||
|  | @ -13,19 +13,24 @@ | ||||||
| (require 'prelude) | (require 'prelude) | ||||||
| (require 'f) | (require 'f) | ||||||
| 
 | 
 | ||||||
|  | (prelude/assert (f-exists? (getenv "BRIEFCASE"))) | ||||||
|  | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| ;; Configuration | ;; Configuration | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| 
 | 
 | ||||||
|  | (defconst constants/briefcase | ||||||
|  |   (getenv "BRIEFCASE") | ||||||
|  |   "Path to my monorepo, which various parts of my configuration rely on.") | ||||||
|  | 
 | ||||||
| ;; TODO: Consider merging `ui.el' and `misc.el' because those are the only | ;; TODO: Consider merging `ui.el' and `misc.el' because those are the only | ||||||
| ;; current consumers of these constants, and I'm unsure if the indirection that | ;; current consumers of these constants, and I'm unsure if the indirection that | ||||||
| ;; globally defined constants introduces is worth it. | ;; globally defined constants introduces is worth it. | ||||||
| 
 | 
 | ||||||
| (defconst constants/current-project "~/briefcase" | (defconst constants/current-project | ||||||
|  |   constants/briefcase | ||||||
|   "Variable holding the directory for my currently active project.") |   "Variable holding the directory for my currently active project.") | ||||||
| 
 | 
 | ||||||
| (prelude/assert (f-directory? constants/current-project)) |  | ||||||
| 
 |  | ||||||
| (defconst constants/mouse-kbds | (defconst constants/mouse-kbds | ||||||
|   '([mouse-1] [down-mouse-1] [drag-mouse-1] [double-mouse-1] [triple-mouse-1] |   '([mouse-1] [down-mouse-1] [drag-mouse-1] [double-mouse-1] [triple-mouse-1] | ||||||
|     [mouse-2] [down-mouse-2] [drag-mouse-2] [double-mouse-2] [triple-mouse-2] |     [mouse-2] [down-mouse-2] [drag-mouse-2] [double-mouse-2] [triple-mouse-2] | ||||||
|  |  | ||||||
|  | @ -13,6 +13,7 @@ | ||||||
| (require 'project) | (require 'project) | ||||||
| (require 'f) | (require 'f) | ||||||
| (require 'dash) | (require 'dash) | ||||||
|  | (require 'constants) | ||||||
| 
 | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| ;; Configuration | ;; Configuration | ||||||
|  | @ -180,10 +181,11 @@ | ||||||
| ;; trim whitespace on save | ;; trim whitespace on save | ||||||
| (add-hook 'before-save-hook #'delete-trailing-whitespace) | (add-hook 'before-save-hook #'delete-trailing-whitespace) | ||||||
| 
 | 
 | ||||||
| ;; call `git secret hide` after saving ~/briefcase/secrets.json | ;; call `git secret hide` after saving secrets.json | ||||||
| (add-hook 'after-save-hook | (add-hook 'after-save-hook | ||||||
|           (lambda () |           (lambda () | ||||||
|             (when (f-equal? (buffer-file-name) "~/briefcase/secrets.json") |             (when (f-equal? (buffer-file-name) | ||||||
|  |                             (f-join constants/briefcase "secrets.json")) | ||||||
|               (shell-command "git secret hide")))) |               (shell-command "git secret hide")))) | ||||||
| 
 | 
 | ||||||
| ;; use tabs instead of spaces | ;; use tabs instead of spaces | ||||||
|  | @ -207,7 +209,7 @@ | ||||||
| (defun project-find-function--briefcase (dir) | (defun project-find-function--briefcase (dir) | ||||||
|   "Find the nearest default.nix file; otherwise, terminate at the .git |   "Find the nearest default.nix file; otherwise, terminate at the .git | ||||||
|   directory." |   directory." | ||||||
|   (when (s-starts-with? (getenv "BRIEFCASE") (f-expand dir)) |   (when (s-starts-with? constants/briefcase (f-expand dir)) | ||||||
|     (if (f-exists? (f-join dir "default.nix")) |     (if (f-exists? (f-join dir "default.nix")) | ||||||
|         (cons 'transient dir) |         (cons 'transient dir) | ||||||
|       (project-find-function--briefcase (f-parent dir))))) |       (project-find-function--briefcase (f-parent dir))))) | ||||||
|  |  | ||||||
|  | @ -9,8 +9,7 @@ | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| 
 | 
 | ||||||
| (require 'device) | (require 'device) | ||||||
| 
 | (require 'constants) | ||||||
| (prelude/assert (f-exists? (getenv "BRIEFCASE"))) |  | ||||||
| 
 | 
 | ||||||
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||||||
| ;; Library | ;; Library | ||||||
|  | @ -28,7 +27,7 @@ | ||||||
|          (bname (format "*%s*" pname))) |          (bname (format "*%s*" pname))) | ||||||
|     (start-process pname bname |     (start-process pname bname | ||||||
|                    "nix-env" |                    "nix-env" | ||||||
|                    "-I" (format "briefcase=%s" (getenv "BRIEFCASE")) |                    "-I" (format "briefcase=%s" constants/briefcase) | ||||||
|                    "-f" "<briefcase>" "-iA" emacs) |                    "-f" "<briefcase>" "-iA" emacs) | ||||||
|     (display-buffer bname))) |     (display-buffer bname))) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue