Compare commits
No commits in common. "7db9f8d56cbc3e49addfbe09867d0fcbc595fb1c" and "8df66edf2594467e110db782a6fc55adfd3f0776" have entirely different histories.
7db9f8d56c
...
8df66edf25
4
init.el
4
init.el
@ -589,6 +589,7 @@
|
|||||||
db/run-or-hide-ansi-term
|
db/run-or-hide-ansi-term
|
||||||
db/hex-to-ascii
|
db/hex-to-ascii
|
||||||
db/text-to-hex
|
db/text-to-hex
|
||||||
|
conditionally-enable-lispy
|
||||||
turn-on-lispy-when-available
|
turn-on-lispy-when-available
|
||||||
turn-on-flycheck-when-file
|
turn-on-flycheck-when-file
|
||||||
db/sort-nsm-permanent-settings
|
db/sort-nsm-permanent-settings
|
||||||
@ -611,8 +612,7 @@
|
|||||||
db/sync-magit-repos-from-projectile
|
db/sync-magit-repos-from-projectile
|
||||||
db/replace-variables-in-string
|
db/replace-variables-in-string
|
||||||
db/dired-ediff-files
|
db/dired-ediff-files
|
||||||
db/grep-read-files
|
db/grep-read-files))
|
||||||
db/make-selector-from-table-header))
|
|
||||||
|
|
||||||
(use-package db-hydras
|
(use-package db-hydras
|
||||||
:commands (hydra-toggle/body
|
:commands (hydra-toggle/body
|
||||||
|
|||||||
@ -250,6 +250,16 @@ FORMAT-STRING defaults to some ISO 8601-like format."
|
|||||||
(message time-string)
|
(message time-string)
|
||||||
time-string)))
|
time-string)))
|
||||||
|
|
||||||
|
(defun conditionally-enable-lispy ()
|
||||||
|
"Enable lispy-mode when in `eval-expression’ or in
|
||||||
|
`pp-eval-expression’. lispy must have been loaded for this
|
||||||
|
first, i.e., this function will not automatically load
|
||||||
|
lispy."
|
||||||
|
(when (and (featurep 'lispy)
|
||||||
|
(or (eq this-command 'eval-expression)
|
||||||
|
(eq this-command 'pp-eval-expression)))
|
||||||
|
(lispy-mode 1)))
|
||||||
|
|
||||||
(defun turn-on-lispy-when-available ()
|
(defun turn-on-lispy-when-available ()
|
||||||
"Activate `lispy’ in current buffer when possible.
|
"Activate `lispy’ in current buffer when possible.
|
||||||
Will print a warning in case of failure."
|
Will print a warning in case of failure."
|
||||||
@ -552,60 +562,6 @@ entries, even if I want to use the input directly."
|
|||||||
(or (cdr (assoc files grep-files-aliases))
|
(or (cdr (assoc files grep-files-aliases))
|
||||||
files))))
|
files))))
|
||||||
|
|
||||||
(defun db/make-selector-from-table-header (header)
|
|
||||||
"Return selector function based on names contained in HEADER.
|
|
||||||
|
|
||||||
A selector function is a function that receives a KEY (a symbol)
|
|
||||||
and a ROW (list of values) and returns the value in ROW with the
|
|
||||||
same index that KEY has in HEADER. A use-case for such a
|
|
||||||
selector function is to have a table represented as a list of
|
|
||||||
lists (rows), where the first list (row) is the header and all
|
|
||||||
subsequent lists (rows) are the actual values; to access values
|
|
||||||
in all subsequent rows by name, one can use a selector function
|
|
||||||
on the header to do so.
|
|
||||||
|
|
||||||
HEADER must be a list of strings or symbols and must not contain
|
|
||||||
duplicates when elements are considered as symbols."
|
|
||||||
|
|
||||||
(unless (listp header)
|
|
||||||
(user-error "Header is not a list, cannot create selector"))
|
|
||||||
|
|
||||||
(unless (-all? (-orfn #'stringp #'symbolp) header)
|
|
||||||
(user-error "Header must consist of strings or symbols, cannot create selector"))
|
|
||||||
|
|
||||||
(let ((header (-map #'(lambda (elt)
|
|
||||||
(cond
|
|
||||||
((symbolp elt) elt)
|
|
||||||
((stringp elt) (intern (downcase elt)))))
|
|
||||||
header)))
|
|
||||||
|
|
||||||
;; Check for duplicates in HEADER
|
|
||||||
(when (-reduce-from #'(lambda (val tail)
|
|
||||||
(or val (memq (cl-first tail)
|
|
||||||
(cl-rest tail))))
|
|
||||||
nil
|
|
||||||
(-tails header))
|
|
||||||
(user-error "Header contains duplicates, cannot create selector"))
|
|
||||||
|
|
||||||
;; Return actual selector
|
|
||||||
(let* ((lookup-table (make-hash-table)))
|
|
||||||
|
|
||||||
(mapc #'(lambda (idx)
|
|
||||||
(puthash (nth idx header)
|
|
||||||
idx
|
|
||||||
lookup-table))
|
|
||||||
(-iota (length header)))
|
|
||||||
|
|
||||||
#'(lambda (column row)
|
|
||||||
(let ((key (if (symbolp column)
|
|
||||||
column
|
|
||||||
(user-error "Unknow key type %s of key %s"
|
|
||||||
(type-of column)
|
|
||||||
column))))
|
|
||||||
(if-let ((idx (gethash key lookup-table)))
|
|
||||||
(nth idx row)
|
|
||||||
(user-error "Unknow column name %s" column)))))))
|
|
||||||
|
|
||||||
|
|
||||||
;;; Base45 Decoding
|
;;; Base45 Decoding
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user