Fix #14213 remove dash and ht from core libs
- delete dash and ht in core - reimplemented all ht functions we need in `spacemacs-ht.el` and use them - add dash to spacemacs-bootstrap
This commit is contained in:
parent
884dc44a48
commit
ae65f3cedd
|
@ -1,10 +1,8 @@
|
|||
https://raw.githubusercontent.com/magnars/dash.el/master/dash.el core/libs/dash.el
|
||||
https://raw.githubusercontent.com/creichert/ido-vertical-mode.el/master/ido-vertical-mode.el core/libs/ido-vertical-mode.el
|
||||
https://raw.githubusercontent.com/melpa/package-build/master/package-build.el core/libs/package-build.el
|
||||
https://raw.githubusercontent.com/melpa/package-build/master/package-recipe-mode.el core/libs/package-recipe-mode.el
|
||||
https://raw.githubusercontent.com/quelpa/quelpa/master/quelpa.el core/libs/quelpa.el
|
||||
https://raw.githubusercontent.com/Malabarba/spinner.el/master/spinner.el core/libs/spinner.el
|
||||
https://raw.githubusercontent.com/Wilfred/ht.el/master/ht.el core/libs/ht.el
|
||||
https://raw.githubusercontent.com/melpa/package-build/master/package-build-badges.el core/libs/package-build-badges.el
|
||||
https://raw.githubusercontent.com/melpa/package-build/master/package-recipe.el core/libs/package-recipe.el
|
||||
https://raw.githubusercontent.com/purcell/page-break-lines/master/page-break-lines.el core/libs/page-break-lines.el
|
||||
|
|
|
@ -21,9 +21,8 @@
|
|||
(defconst spacemacs--compiled-files
|
||||
'(;; Built-in libs that we changed
|
||||
"core/libs/forks/load-env-vars.el"
|
||||
"core/libs/forks/spacemacs-ht.el"
|
||||
;; Rest of built-in libs.
|
||||
"core/libs/dash.el"
|
||||
"core/libs/ht.el"
|
||||
"core/libs/ido-vertical-mode.el"
|
||||
"core/libs/package-build-badges.el"
|
||||
"core/libs/package-build.el"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
(require 'package)
|
||||
(require 'warnings)
|
||||
(require 'help-mode)
|
||||
(require 'ht)
|
||||
(require 'spacemacs-ht)
|
||||
(require 'core-dotspacemacs)
|
||||
(require 'core-funcs)
|
||||
(require 'core-progress-bar)
|
||||
|
@ -1149,21 +1149,21 @@ USEDP non-nil means that PKG is a used layer."
|
|||
(defun configuration-layer/get-layer (layer-name)
|
||||
"Return a layer object with name LAYER-NAME.
|
||||
Return nil if layer object is not found."
|
||||
(when (ht-contains? configuration-layer--indexed-layers layer-name)
|
||||
(ht-get configuration-layer--indexed-layers layer-name)))
|
||||
(when (spacemacs-ht-contains? configuration-layer--indexed-layers layer-name)
|
||||
(spacemacs-ht-get configuration-layer--indexed-layers layer-name)))
|
||||
|
||||
(defun configuration-layer/get-layers-list ()
|
||||
"Return a list of all discovered layer symbols."
|
||||
(ht-keys configuration-layer--indexed-layers))
|
||||
(spacemacs-ht-keys configuration-layer--indexed-layers))
|
||||
|
||||
(defun configuration-layer/get-layer-local-dir (layer)
|
||||
"Return the value of SLOT for the given LAYER."
|
||||
(let ((obj (ht-get configuration-layer--indexed-layers layer)))
|
||||
(let ((obj (spacemacs-ht-get configuration-layer--indexed-layers layer)))
|
||||
(when obj (concat (oref obj :dir) "local/"))))
|
||||
|
||||
(defun configuration-layer/get-layer-path (layer)
|
||||
"Return the path for LAYER symbol."
|
||||
(let ((obj (ht-get configuration-layer--indexed-layers layer)))
|
||||
(let ((obj (spacemacs-ht-get configuration-layer--indexed-layers layer)))
|
||||
(when obj (oref obj :dir))))
|
||||
|
||||
(defun configuration-layer//add-package (pkg &optional usedp)
|
||||
|
@ -1176,13 +1176,13 @@ USEDP non-nil means that PKG is a used package."
|
|||
|
||||
(defun configuration-layer/get-packages-list ()
|
||||
"Return a list of all package symbols."
|
||||
(ht-keys configuration-layer--indexed-packages))
|
||||
(spacemacs-ht-keys configuration-layer--indexed-packages))
|
||||
|
||||
(defun configuration-layer/get-package (pkg-name)
|
||||
"Return a package object with name PKG-NAME.
|
||||
Return nil if package object is not found."
|
||||
(when (ht-contains? configuration-layer--indexed-packages pkg-name)
|
||||
(ht-get configuration-layer--indexed-packages pkg-name)))
|
||||
(when (spacemacs-ht-contains? configuration-layer--indexed-packages pkg-name)
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages pkg-name)))
|
||||
|
||||
(defun configuration-layer//sort-packages (packages)
|
||||
"Return a sorted list of PACKAGES objects."
|
||||
|
@ -2272,7 +2272,7 @@ depends on it."
|
|||
(deps (configuration-layer//get-package-deps-from-alist pkg-sym)))
|
||||
(dolist (dep deps)
|
||||
(let* ((dep-sym (car dep))
|
||||
(value (ht-get result dep-sym)))
|
||||
(value (spacemacs-ht-get result dep-sym)))
|
||||
(puthash dep-sym
|
||||
(if value (add-to-list 'value pkg-sym) (list pkg-sym))
|
||||
result)))))
|
||||
|
@ -2301,8 +2301,8 @@ depends on it."
|
|||
"Returns not nil if PKG-NAME is the name of an orphan package."
|
||||
(unless (or (memq pkg-name dist-pkgs)
|
||||
(memq pkg-name configuration-layer--protected-packages))
|
||||
(if (ht-contains? dependencies pkg-name)
|
||||
(let ((parents (ht-get dependencies pkg-name)))
|
||||
(if (spacemacs-ht-contains? dependencies pkg-name)
|
||||
(let ((parents (spacemacs-ht-get dependencies pkg-name)))
|
||||
(cl-reduce (lambda (x y) (and x y))
|
||||
(mapcar (lambda (p) (configuration-layer//is-package-orphan
|
||||
p dist-pkgs dependencies))
|
||||
|
@ -2497,7 +2497,7 @@ depends on it."
|
|||
"Return a list of all ELPA packages in indexed packages and dependencies."
|
||||
(let (result)
|
||||
(dolist (pkg-sym (configuration-layer//filter-distant-packages
|
||||
(ht-keys configuration-layer--indexed-packages) nil))
|
||||
(spacemacs-ht-keys configuration-layer--indexed-packages) nil))
|
||||
(when (assq pkg-sym package-archive-contents)
|
||||
(let* ((deps (mapcar 'car
|
||||
(configuration-layer//get-package-deps-from-archive
|
||||
|
|
3198
core/libs/dash.el
3198
core/libs/dash.el
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,64 @@
|
|||
;;; spacemacs-ht.el --- hash table util -*- lexical-binding: t; -*-
|
||||
;; Copyright (C) 2013 Wilfred Hughes - original implementation
|
||||
;; Copyright (C) 2021 Sylvain Benner & Contributors - fork
|
||||
;;
|
||||
;; Author: Thanh Vuong
|
||||
;; URL: https://github.com/thanhvg
|
||||
;;
|
||||
;; This file is not part of GNU Emacs.
|
||||
;;
|
||||
;;; License: GPLv3
|
||||
;;; Commentary: This is a fork of ht.el by Wilfred Hughes
|
||||
;; https://github.com/Wilfred/ht.el/blob/master/ht.el
|
||||
;;
|
||||
;;; Commentary:
|
||||
;; Spacemacs only uses 6 out 29 functions provded by the original ht.el
|
||||
;; but ht.el also requires dash.el
|
||||
;; To avoid extra dependency we define those 6 ht functions and add the
|
||||
;; spacemacs- prefix to avoid any conflict.
|
||||
|
||||
(define-inline spacemacs-ht-get (table key &optional default)
|
||||
"Look up KEY in TABLE, and return the matching value.
|
||||
If KEY isn't present, return DEFAULT (nil if not specified)."
|
||||
(declare (side-effect-free t))
|
||||
(inline-quote
|
||||
(gethash ,key ,table ,default)))
|
||||
|
||||
(define-inline spacemacs-ht-contains? (table key)
|
||||
"Return 't if TABLE contains KEY."
|
||||
(declare (side-effect-free t))
|
||||
(inline-quote
|
||||
(let ((not-found-symbol (make-symbol "spacemacs-ht--not-found")))
|
||||
(not (eq (spacemacs-ht-get ,table ,key not-found-symbol) not-found-symbol)))))
|
||||
|
||||
(defun spacemacs-ht-map (function table)
|
||||
"Apply FUNCTION to each key-value pair of TABLE, and make a list of the results.
|
||||
FUNCTION is called with two arguments, KEY and VALUE."
|
||||
(let (results)
|
||||
(maphash
|
||||
(lambda (key value)
|
||||
(push (funcall function key value) results))
|
||||
table)
|
||||
results))
|
||||
|
||||
(defun spacemacs-ht-keys (table)
|
||||
"Return a list of all the keys in TABLE."
|
||||
(declare (side-effect-free t))
|
||||
(spacemacs-ht-map (lambda (key _value) key) table))
|
||||
|
||||
(define-inline spacemacs-ht-set! (table key value)
|
||||
"Associate KEY in TABLE with VALUE."
|
||||
(inline-quote
|
||||
(prog1 nil
|
||||
(puthash ,key ,value ,table))))
|
||||
|
||||
(define-inline spacemacs-ht-create (&optional test)
|
||||
"Create an empty hash table.
|
||||
|
||||
TEST indicates the function used to compare the hash
|
||||
keys. Default is `equal'. It can be `eq', `eql', `equal' or a
|
||||
user-supplied test created via `define-hash-table-test'."
|
||||
(declare (side-effect-free t))
|
||||
(inline-quote (make-hash-table :test (or ,test 'equal))))
|
||||
|
||||
(provide 'spacemacs-ht)
|
335
core/libs/ht.el
335
core/libs/ht.el
|
@ -1,335 +0,0 @@
|
|||
;;; ht.el --- The missing hash table library for Emacs -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2013 Wilfred Hughes
|
||||
|
||||
;; Author: Wilfred Hughes <me@wilfred.me.uk>
|
||||
;; Version: 2.4
|
||||
;; Keywords: hash table, hash map, hash
|
||||
;; Package-Requires: ((dash "2.12.0"))
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; The missing hash table library for Emacs.
|
||||
;;
|
||||
;; See documentation at https://github.com/Wilfred/ht.el
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'dash)
|
||||
(require 'gv)
|
||||
(eval-when-compile
|
||||
(require 'inline))
|
||||
|
||||
(defmacro ht (&rest pairs)
|
||||
"Create a hash table with the key-value pairs given.
|
||||
Keys are compared with `equal'.
|
||||
|
||||
\(fn (KEY-1 VALUE-1) (KEY-2 VALUE-2) ...)"
|
||||
(let* ((table-symbol (make-symbol "ht-temp"))
|
||||
(assignments
|
||||
(mapcar
|
||||
(lambda (pair) `(ht-set! ,table-symbol ,@pair))
|
||||
pairs)))
|
||||
`(let ((,table-symbol (ht-create)))
|
||||
,@assignments
|
||||
,table-symbol)))
|
||||
|
||||
(define-inline ht-set! (table key value)
|
||||
"Associate KEY in TABLE with VALUE."
|
||||
(inline-quote
|
||||
(prog1 nil
|
||||
(puthash ,key ,value ,table))))
|
||||
|
||||
(defalias 'ht-set 'ht-set!)
|
||||
|
||||
(define-inline ht-create (&optional test)
|
||||
"Create an empty hash table.
|
||||
|
||||
TEST indicates the function used to compare the hash
|
||||
keys. Default is `equal'. It can be `eq', `eql', `equal' or a
|
||||
user-supplied test created via `define-hash-table-test'."
|
||||
(declare (side-effect-free t))
|
||||
(inline-quote (make-hash-table :test (or ,test 'equal))))
|
||||
|
||||
(defun ht<-alist (alist &optional test)
|
||||
"Create a hash table with initial values according to ALIST.
|
||||
|
||||
TEST indicates the function used to compare the hash
|
||||
keys. Default is `equal'. It can be `eq', `eql', `equal' or a
|
||||
user-supplied test created via `define-hash-table-test'."
|
||||
(declare (side-effect-free t))
|
||||
(let ((h (ht-create test)))
|
||||
;; the first key-value pair in an alist gets precedence, so we
|
||||
;; start from the end of the list:
|
||||
(dolist (pair (reverse alist) h)
|
||||
(let ((key (car pair))
|
||||
(value (cdr pair)))
|
||||
(ht-set! h key value)))))
|
||||
|
||||
(defalias 'ht-from-alist 'ht<-alist)
|
||||
|
||||
(defun ht<-plist (plist &optional test)
|
||||
"Create a hash table with initial values according to PLIST.
|
||||
|
||||
TEST indicates the function used to compare the hash
|
||||
keys. Default is `equal'. It can be `eq', `eql', `equal' or a
|
||||
user-supplied test created via `define-hash-table-test'."
|
||||
(declare (side-effect-free t))
|
||||
(let ((h (ht-create test)))
|
||||
(dolist (pair (nreverse (-partition 2 plist)) h)
|
||||
(let ((key (car pair))
|
||||
(value (cadr pair)))
|
||||
(ht-set! h key value)))))
|
||||
|
||||
(defalias 'ht-from-plist 'ht<-plist)
|
||||
|
||||
(define-inline ht-get (table key &optional default)
|
||||
"Look up KEY in TABLE, and return the matching value.
|
||||
If KEY isn't present, return DEFAULT (nil if not specified)."
|
||||
(declare (side-effect-free t))
|
||||
(inline-quote
|
||||
(gethash ,key ,table ,default)))
|
||||
|
||||
;; Don't use `ht-set!' here, gv setter was assumed to return the value
|
||||
;; to be set.
|
||||
(gv-define-setter ht-get (value table key) `(puthash ,key ,value ,table))
|
||||
|
||||
(define-inline ht-get* (table &rest keys)
|
||||
"Look up KEYS in nested hash tables, starting with TABLE.
|
||||
The lookup for each key should return another hash table, except
|
||||
for the final key, which may return any value."
|
||||
(declare (side-effect-free t))
|
||||
(inline-letevals (table keys)
|
||||
(inline-quote
|
||||
(progn
|
||||
(while ,keys
|
||||
(setf ,table (ht-get ,table (pop ,keys))))
|
||||
,table))))
|
||||
|
||||
(put 'ht-get* 'compiler-macro
|
||||
(lambda (_ table &rest keys)
|
||||
(--reduce-from `(ht-get ,acc ,it) table keys)))
|
||||
|
||||
(defun ht-update! (table from-table)
|
||||
"Update TABLE according to every key-value pair in FROM-TABLE."
|
||||
(maphash
|
||||
(lambda (key value) (puthash key value table))
|
||||
from-table)
|
||||
nil)
|
||||
|
||||
(defalias 'ht-update 'ht-update!)
|
||||
|
||||
(defun ht-merge (&rest tables)
|
||||
"Crete a new tables that includes all the key-value pairs from TABLES.
|
||||
If multiple have tables have the same key, the value in the last
|
||||
table is used."
|
||||
(let ((merged (ht-create)))
|
||||
(mapc (lambda (table) (ht-update! merged table)) tables)
|
||||
merged))
|
||||
|
||||
(define-inline ht-remove! (table key)
|
||||
"Remove KEY from TABLE."
|
||||
(inline-quote (remhash ,key ,table)))
|
||||
|
||||
(defalias 'ht-remove 'ht-remove!)
|
||||
|
||||
(define-inline ht-clear! (table)
|
||||
"Remove all keys from TABLE."
|
||||
(inline-quote
|
||||
(prog1 nil
|
||||
(clrhash ,table))))
|
||||
|
||||
(defalias 'ht-clear 'ht-clear!)
|
||||
|
||||
(defun ht-map (function table)
|
||||
"Apply FUNCTION to each key-value pair of TABLE, and make a list of the results.
|
||||
FUNCTION is called with two arguments, KEY and VALUE."
|
||||
(let (results)
|
||||
(maphash
|
||||
(lambda (key value)
|
||||
(push (funcall function key value) results))
|
||||
table)
|
||||
results))
|
||||
|
||||
(defmacro ht-amap (form table)
|
||||
"Anaphoric version of `ht-map'.
|
||||
For every key-value pair in TABLE, evaluate FORM with the
|
||||
variables KEY and VALUE bound. If you don't use both of
|
||||
these variables, then use `ht-map' to avoid warnings."
|
||||
`(ht-map (lambda (key value) ,form) ,table))
|
||||
|
||||
(defun ht-keys (table)
|
||||
"Return a list of all the keys in TABLE."
|
||||
(declare (side-effect-free t))
|
||||
(ht-map (lambda (key _value) key) table))
|
||||
|
||||
(defun ht-values (table)
|
||||
"Return a list of all the values in TABLE."
|
||||
(declare (side-effect-free t))
|
||||
(ht-map (lambda (_key value) value) table))
|
||||
|
||||
(defun ht-items (table)
|
||||
"Return a list of two-element lists '(key value) from TABLE."
|
||||
(declare (side-effect-free t))
|
||||
(ht-amap (list key value) table))
|
||||
|
||||
(defalias 'ht-each 'maphash
|
||||
"Apply FUNCTION to each key-value pair of TABLE.
|
||||
Returns nil, used for side-effects only.")
|
||||
|
||||
(defmacro ht-aeach (form table)
|
||||
"Anaphoric version of `ht-each'.
|
||||
For every key-value pair in TABLE, evaluate FORM with the
|
||||
variables key and value bound."
|
||||
`(ht-each (lambda (key value) ,form) ,table))
|
||||
|
||||
(defun ht-select-keys (table keys)
|
||||
"Return a copy of TABLE with only the specified KEYS."
|
||||
(declare (side-effect-free t))
|
||||
(let (result)
|
||||
(setq result (make-hash-table :test (hash-table-test table)))
|
||||
(dolist (key keys result)
|
||||
(if (not (equal (gethash key table 'key-not-found) 'key-not-found))
|
||||
(puthash key (gethash key table) result)))))
|
||||
|
||||
(defun ht->plist (table)
|
||||
"Return a flat list '(key1 value1 key2 value2...) from TABLE.
|
||||
|
||||
Note that hash tables are unordered, so this cannot be an exact
|
||||
inverse of `ht<-plist'. The following is not guaranteed:
|
||||
|
||||
\(let ((data '(a b c d)))
|
||||
(equalp data
|
||||
(ht->plist (ht<-plist data))))"
|
||||
(declare (side-effect-free t))
|
||||
(apply 'append (ht-items table)))
|
||||
|
||||
(defalias 'ht-to-plist 'ht->plist)
|
||||
|
||||
(define-inline ht-copy (table)
|
||||
"Return a shallow copy of TABLE (keys and values are shared)."
|
||||
(declare (side-effect-free t))
|
||||
(inline-quote (copy-hash-table ,table)))
|
||||
|
||||
(defun ht->alist (table)
|
||||
"Return a list of two-element lists '(key . value) from TABLE.
|
||||
|
||||
Note that hash tables are unordered, so this cannot be an exact
|
||||
inverse of `ht<-alist'. The following is not guaranteed:
|
||||
|
||||
\(let ((data '((a . b) (c . d))))
|
||||
(equalp data
|
||||
(ht->alist (ht<-alist data))))"
|
||||
(declare (side-effect-free t))
|
||||
(ht-amap (cons key value) table))
|
||||
|
||||
(defalias 'ht-to-alist 'ht->alist)
|
||||
|
||||
(defalias 'ht? 'hash-table-p)
|
||||
|
||||
(defalias 'ht-p 'hash-table-p)
|
||||
|
||||
(define-inline ht-contains? (table key)
|
||||
"Return 't if TABLE contains KEY."
|
||||
(declare (side-effect-free t))
|
||||
(inline-quote
|
||||
(let ((not-found-symbol (make-symbol "ht--not-found")))
|
||||
(not (eq (ht-get ,table ,key not-found-symbol) not-found-symbol)))))
|
||||
|
||||
(defalias 'ht-contains-p 'ht-contains?)
|
||||
|
||||
(define-inline ht-size (table)
|
||||
"Return the actual number of entries in TABLE."
|
||||
(declare (side-effect-free t))
|
||||
(inline-quote
|
||||
(hash-table-count ,table)))
|
||||
|
||||
(define-inline ht-empty? (table)
|
||||
"Return true if the actual number of entries in TABLE is zero."
|
||||
(declare (side-effect-free t))
|
||||
(inline-quote
|
||||
(zerop (ht-size ,table))))
|
||||
|
||||
(defalias 'ht-empty-p 'ht-empty?)
|
||||
|
||||
(defun ht-select (function table)
|
||||
"Return a hash table containing all entries in TABLE for which
|
||||
FUNCTION returns a truthy value.
|
||||
|
||||
FUNCTION is called with two arguments, KEY and VALUE."
|
||||
(let ((results (ht-create)))
|
||||
(ht-each
|
||||
(lambda (key value)
|
||||
(when (funcall function key value)
|
||||
(ht-set! results key value)))
|
||||
table)
|
||||
results))
|
||||
|
||||
(defun ht-reject (function table)
|
||||
"Return a hash table containing all entries in TABLE for which
|
||||
FUNCTION returns a falsy value.
|
||||
|
||||
FUNCTION is called with two arguments, KEY and VALUE."
|
||||
(let ((results (ht-create)))
|
||||
(ht-each
|
||||
(lambda (key value)
|
||||
(unless (funcall function key value)
|
||||
(ht-set! results key value)))
|
||||
table)
|
||||
results))
|
||||
|
||||
(defun ht-reject! (function table)
|
||||
"Delete entries from TABLE for which FUNCTION returns a falsy value.
|
||||
|
||||
FUNCTION is called with two arguments, KEY and VALUE."
|
||||
(ht-each
|
||||
(lambda (key value)
|
||||
(when (funcall function key value)
|
||||
(remhash key table)))
|
||||
table)
|
||||
nil)
|
||||
|
||||
(defalias 'ht-delete-if 'ht-reject!)
|
||||
|
||||
(defun ht-find (function table)
|
||||
"Return (key, value) from TABLE for which FUNCTION returns a truthy value.
|
||||
Return nil otherwise.
|
||||
|
||||
FUNCTION is called with two arguments, KEY and VALUE."
|
||||
(catch 'break
|
||||
(ht-each
|
||||
(lambda (key value)
|
||||
(when (funcall function key value)
|
||||
(throw 'break (list key value))))
|
||||
table)))
|
||||
|
||||
(defun ht-equal? (table1 table2)
|
||||
"Return t if TABLE1 and TABLE2 have the same keys and values.
|
||||
Does not compare equality predicates."
|
||||
(declare (side-effect-free t))
|
||||
(let ((keys1 (ht-keys table1))
|
||||
(keys2 (ht-keys table2))
|
||||
(sentinel (make-symbol "ht-sentinel")))
|
||||
(and (equal (length keys1) (length keys2))
|
||||
(--all?
|
||||
(equal (ht-get table1 it)
|
||||
(ht-get table2 it sentinel))
|
||||
keys1))))
|
||||
|
||||
(defalias 'ht-equal-p 'ht-equal?)
|
||||
|
||||
(provide 'ht)
|
||||
;;; ht.el ends here
|
|
@ -27,7 +27,6 @@
|
|||
;;; Code:
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'ht)
|
||||
(require 'helm)
|
||||
(require 'helm-command)
|
||||
(require 'core-configuration-layer)
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
;;; Code:
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'ht)
|
||||
(require 'ivy)
|
||||
(require 'core-configuration-layer)
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
(holy-mode :location local :step pre)
|
||||
(hybrid-mode :location (recipe :fetcher local) :step pre)
|
||||
(spacemacs-theme :location built-in)
|
||||
dash
|
||||
))
|
||||
|
||||
|
||||
|
@ -616,3 +617,7 @@ Press \\[which-key-toggle-persistent] to hide."
|
|||
(defun spacemacs-bootstrap/init-spacemacs-theme ()
|
||||
(use-package spacemacs-theme
|
||||
:defer t))
|
||||
|
||||
(defun spacemacs-bootstrap/init-dash ()
|
||||
(use-package dash
|
||||
:defer t))
|
||||
|
|
|
@ -73,5 +73,5 @@ in case none of the regular names can be used for a new layout.")
|
|||
(defvar spacemacs--layout-local-variables nil
|
||||
"List of variables that will be local to the current layout.")
|
||||
|
||||
(defvar spacemacs--layout-local-map (ht-create)
|
||||
(defvar spacemacs--layout-local-map (spacemacs-ht-create)
|
||||
"Map of layouts to their local variable values.")
|
||||
|
|
|
@ -850,7 +850,7 @@ Accepts a list of VARIABLE, DEFAULT-VALUE pairs.
|
|||
(-map 'car
|
||||
spacemacs--layout-local-variables))))
|
||||
;; save the current layout
|
||||
(ht-set! spacemacs--layout-local-map
|
||||
(spacemacs-ht-set! spacemacs--layout-local-map
|
||||
(spacemacs//current-layout-name)
|
||||
(--map (cons it (symbol-value it))
|
||||
layout-local-vars))
|
||||
|
@ -858,6 +858,6 @@ Accepts a list of VARIABLE, DEFAULT-VALUE pairs.
|
|||
(--each layout-local-vars
|
||||
(set it (alist-get it spacemacs--layout-local-variables)))
|
||||
;; override with the previously bound values for the new layout
|
||||
(--when-let (ht-get spacemacs--layout-local-map persp-name)
|
||||
(--when-let (spacemacs-ht-get spacemacs--layout-local-map persp-name)
|
||||
(-each it
|
||||
(-lambda ((var . val)) (set var val))))))
|
||||
|
|
|
@ -1623,11 +1623,11 @@
|
|||
(configuration-layer/make-packages-from-layers '(layer1))
|
||||
(should
|
||||
(and (equal (cfgl-package "pkg3" :name 'pkg3 :owners '(layer1))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg3))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg3))
|
||||
(equal (cfgl-package "pkg2" :name 'pkg2 :owners '(layer1))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg2))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg2))
|
||||
(equal (cfgl-package "pkg1" :name 'pkg1 :owners '(layer1))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--lists-only ()
|
||||
(let* ((layer1 (cfgl-layer "layer1"
|
||||
|
@ -1651,14 +1651,14 @@
|
|||
:owners '(layer1)
|
||||
:location 'local
|
||||
:step 'pre)
|
||||
(ht-get configuration-layer--indexed-packages 'pkg3))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg3))
|
||||
(equal (cfgl-package "pkg2"
|
||||
:name 'pkg2
|
||||
:owners '(layer1)
|
||||
:location '(recipe blahblah))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg2))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg2))
|
||||
(equal (cfgl-package "pkg1" :name 'pkg1 :owners '(layer1) :excluded t)
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--symbols-and-lists ()
|
||||
(let* ((layer1 (cfgl-layer "layer1"
|
||||
|
@ -1680,20 +1680,20 @@
|
|||
(configuration-layer/make-packages-from-layers '(layer1))
|
||||
(should
|
||||
(and (equal (cfgl-package "pkg4" :name 'pkg4 :owners '(layer1))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg4))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg4))
|
||||
(equal (cfgl-package "pkg3"
|
||||
:name 'pkg3
|
||||
:owners '(layer1)
|
||||
:location 'local
|
||||
:step 'pre)
|
||||
(ht-get configuration-layer--indexed-packages 'pkg3))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg3))
|
||||
(equal (cfgl-package "pkg2"
|
||||
:name 'pkg2
|
||||
:owners '(layer1)
|
||||
:location '(recipe blahblah))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg2))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg2))
|
||||
(equal (cfgl-package "pkg1" :name 'pkg1 :owners '(layer1))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--pkg2-has-no-owner-because-no-init-function ()
|
||||
(let* ((layer2 (cfgl-layer "layer2"
|
||||
|
@ -1713,11 +1713,11 @@
|
|||
(configuration-layer/make-packages-from-layers '(layer2))
|
||||
(should
|
||||
(and (equal (cfgl-package "pkg3" :name 'pkg3 :owners '(layer2))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg3))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg3))
|
||||
(equal (cfgl-package "pkg2" :name 'pkg2)
|
||||
(ht-get configuration-layer--indexed-packages 'pkg2))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg2))
|
||||
(equal (cfgl-package "pkg1" :name 'pkg1 :owners '(layer2))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1)))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1)))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--pre-init-function ()
|
||||
(let* ((layer3 (cfgl-layer "layer3"
|
||||
|
@ -1740,7 +1740,7 @@
|
|||
:name 'pkg1
|
||||
:owners '(layer3)
|
||||
:pre-layers '(layer4))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1)))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1)))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--post-init-function ()
|
||||
(let* ((layer3 (cfgl-layer "layer3"
|
||||
|
@ -1763,7 +1763,7 @@
|
|||
:name 'pkg1
|
||||
:owners '(layer3)
|
||||
:post-layers '(layer5))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1)))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1)))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--pre-and-post-init-functions ()
|
||||
(let* ((layer3 (cfgl-layer "layer3"
|
||||
|
@ -1788,7 +1788,7 @@
|
|||
:owners '(layer3)
|
||||
:pre-layers '(layer6)
|
||||
:post-layers '(layer6))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1)))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1)))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--several-init-functions-last-one-is-the-owner ()
|
||||
(let* ((layer7 (cfgl-layer "layer7"
|
||||
|
@ -1813,7 +1813,7 @@
|
|||
(should (equal (cfgl-package "pkg1"
|
||||
:name 'pkg1
|
||||
:owners '(layer8 layer7))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--layer-10-excludes-pkg2-in-layer-9 ()
|
||||
(let* ((layer9 (cfgl-layer "layer9"
|
||||
|
@ -1835,11 +1835,11 @@
|
|||
(configuration-layer/make-packages-from-layers '(layer9 layer10))
|
||||
(should
|
||||
(and (equal (cfgl-package "pkg3" :name 'pkg3 :owners '(layer10))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg3))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg3))
|
||||
(equal (cfgl-package "pkg2" :name 'pkg2 :owners '(layer9) :excluded t)
|
||||
(ht-get configuration-layer--indexed-packages 'pkg2))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg2))
|
||||
(equal (cfgl-package "pkg1" :name 'pkg1 :owners '(layer9))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--last-owner-can-overwrite-location ()
|
||||
(let* ((layer13 (cfgl-layer "layer13"
|
||||
|
@ -1865,7 +1865,7 @@
|
|||
:name 'pkg1
|
||||
:owners '(layer14 layer13)
|
||||
:location 'local)
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--last-owner-can-overwrite-step-nil-to-pre ()
|
||||
(let* ((layer15 (cfgl-layer "layer15"
|
||||
|
@ -1891,7 +1891,7 @@
|
|||
:name 'pkg1
|
||||
:owners '(layer16 layer15)
|
||||
:step 'pre)
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--last-owner-cannot-overwrite-step-pre-to-nil ()
|
||||
(let* ((layer15 (cfgl-layer "layer15"
|
||||
|
@ -1917,7 +1917,7 @@
|
|||
:name 'pkg1
|
||||
:owners '(layer16 layer15)
|
||||
:step 'pre)
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--last-owner-can-overwrite-exclude ()
|
||||
(let* ((layer17 (cfgl-layer "layer17"
|
||||
|
@ -1944,7 +1944,7 @@
|
|||
:name 'pkg1
|
||||
:owners '(layer18 layer17)
|
||||
:excluded t)
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--owner-layer-can-define-toggle ()
|
||||
(let* ((layer19 (cfgl-layer "layer19"
|
||||
|
@ -1963,7 +1963,7 @@
|
|||
:name 'pkg1
|
||||
:owners '(layer19)
|
||||
:toggle '(foo-toggle))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1)))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1)))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--not-owner-layer-can-define-toggle-with-warning ()
|
||||
(let* ((layer20 (cfgl-layer "layer20"
|
||||
|
@ -1990,7 +1990,7 @@
|
|||
:owners '(layer20)
|
||||
:post-layers '(layer21)
|
||||
:toggle '(foo-toggle))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--layer-can-override-toggle ()
|
||||
(let* ((layer22 (cfgl-layer "layer22"
|
||||
|
@ -2016,7 +2016,7 @@
|
|||
:name 'pkg1
|
||||
:owners '(layer23 layer22)
|
||||
:toggle '(bar-toggle))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--not-selected-packages-are-not-excluded ()
|
||||
(let* ((layer24 (cfgl-layer "layer24"
|
||||
|
@ -2044,13 +2044,13 @@
|
|||
:name 'pkg1
|
||||
:owners '(layer25)
|
||||
:excluded nil)
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))
|
||||
(equal (cfgl-package "pkg2"
|
||||
:name 'pkg2
|
||||
:owners '(layer24)
|
||||
:location 'local
|
||||
:excluded nil)
|
||||
(ht-get configuration-layer--indexed-packages 'pkg2))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg2))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--not-selected-package-in-a-layer-can-still-be-created-with-no-owner ()
|
||||
(let* ((layer26 (cfgl-layer "layer26"
|
||||
|
@ -2077,13 +2077,13 @@
|
|||
:name 'pkg1
|
||||
:post-layers '(layer27)
|
||||
:owners nil)
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))
|
||||
(equal (cfgl-package "pkg2"
|
||||
:name 'pkg2
|
||||
:owners '(layer26)
|
||||
:post-layers '(layer27)
|
||||
:location 'local)
|
||||
(ht-get configuration-layer--indexed-packages 'pkg2))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg2))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-layers--package-properties-read-only ()
|
||||
;; we expect that :excluded is still nil
|
||||
|
@ -2109,7 +2109,7 @@
|
|||
(let ((configuration-layer--package-properties-read-onlyp t))
|
||||
(configuration-layer/make-packages-from-layers '(layer28 layer29)))
|
||||
(should
|
||||
(equal expected (ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
(equal expected (spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; configuration-layer/make-packages-from-dotfile
|
||||
|
@ -2132,11 +2132,11 @@
|
|||
(configuration-layer/make-packages-from-dotfile 'used)
|
||||
(should
|
||||
(and (equal (cfgl-package "pkg3" :name 'pkg3 :owners '(dotfile))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg3))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg3))
|
||||
(equal (cfgl-package "pkg2" :name 'pkg2 :owners '(layer-dotfile-1))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg2))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg2))
|
||||
(equal (cfgl-package "pkg1" :name 'pkg1 :owners '(layer-dotfile-1))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
|
||||
(ert-deftest test-make-packages-from-dotfile--dotfile-cannot-own-package-owned-by-layer ()
|
||||
(let* ((layer-dotfile-2 (cfgl-layer "layer-dotfile-2"
|
||||
|
@ -2154,7 +2154,7 @@
|
|||
(configuration-layer/make-packages-from-dotfile 'used)
|
||||
(should
|
||||
(equal (cfgl-package "pkg1" :name 'pkg1 :owners '(layer-dotfile-2))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1)))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1)))))
|
||||
|
||||
(ert-deftest test-make-packages-from-dotfile--dotfile-excludes-pkg2-in-layer-11 ()
|
||||
(let* ((layer-dotfile-3 (cfgl-layer "layer-dotfile-3"
|
||||
|
@ -2175,12 +2175,12 @@
|
|||
(configuration-layer/make-packages-from-dotfile 'used)
|
||||
(should
|
||||
(and (equal (cfgl-package "pkg3" :name 'pkg3 :owners '(layer-dotfile-3))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg3))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg3))
|
||||
(equal (cfgl-package "pkg2" :name 'pkg2 :owners '(layer-dotfile-3)
|
||||
:excluded t)
|
||||
(ht-get configuration-layer--indexed-packages 'pkg2))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg2))
|
||||
(equal (cfgl-package "pkg1" :name 'pkg1 :owners '(layer-dotfile-3))
|
||||
(ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
(spacemacs-ht-get configuration-layer--indexed-packages 'pkg1))))))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; configuration-layer/make-all-packages
|
||||
|
@ -2240,7 +2240,7 @@
|
|||
pkg4
|
||||
pkg9
|
||||
pkg5)
|
||||
(ht-keys configuration-layer--indexed-packages))))))
|
||||
(spacemacs-ht-keys configuration-layer--indexed-packages))))))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; configuration-layer//pre-configure-package
|
||||
|
|
Loading…
Reference in New Issue