Skip to content

Commit

Permalink
refactor: simplify the code
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Oct 28, 2023
1 parent 7e22ce2 commit d6ba81b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion core/me-splash.el
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
(defun minemacs-splash ()
"MinEmacs splash screen"
;; If there are buffer associated with filenames, we don't show splash screen.
(when (zerop (length (seq-filter #'identity (mapcar #'buffer-file-name (buffer-list)))))
(unless (seq-filter #'identity (mapcar #'buffer-file-name (buffer-list)))
(let* ((buffer (get-buffer-create minemacs-splash-buffer-name))
(height (- (window-body-height nil) 1))
(padding-center (min 5 (- (/ height 3) 1)))
Expand Down
4 changes: 1 addition & 3 deletions core/me-vars.el
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ This list is automatically constructed from the environment variables

(defconst minemacs-config-dir
(file-name-as-directory
(or (getenv "MINEMACS_DIR")
(getenv "MINEMACSDIR")
"~/.minemacs.d/"))
(or (getenv "MINEMACS_DIR") (getenv "MINEMACSDIR") "~/.minemacs.d/"))
"MinEmacs user customization directory.")

(defconst minemacs-debug
Expand Down
2 changes: 1 addition & 1 deletion elisp/+minemacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ If N and M = 1, there's no benefit to using this macro over `remove-hook'.
((rx (or "tsch" "csh")) "-dc")
(_ "-ilc")))

;; https://emacs.stackexchange.com/a/21432/37002
;; Inspired by: emacs.stackexchange.com/a/21432/37002
(defun +shell-command-to-string-ignore-stderr (command)
"Execute shell command COMMAND and return its output as a string.
Expand Down
26 changes: 10 additions & 16 deletions elisp/+primitives.el
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Adapted from `org-plist-delete'."

;;;###autoload
(defun +plist-to-alist (plist &optional trim-col)
(let ((res '()))
(let (res)
(while plist
(let* ((key (pop plist))
(val (pop plist))
Expand All @@ -79,29 +79,23 @@ Adapted from `org-plist-delete'."

;;;###autoload
(defun +alist-to-plist (alist &optional add-col)
(let ((res '()))
(let (res)
(dolist (x alist)
(push (if add-col (intern (format ":%s" (car x))) (car x)) res)
(push (cdr x) res))
(nreverse res)))

;; Taken from: emacs.stackexchange.com/q/33892/12534
;;;###autoload
(defun +alist-set (key val alist &optional symbol)
"Set property KEY to VAL in ALIST. Return new alist.
This creates the association if it is missing, and otherwise sets
the cdr of the first matching association in the list. It does
not create duplicate associations. By default, key comparison is
done with `equal'. However, if SYMBOL is non-nil, then `eq' is
used instead.
This method may mutate the original alist, but you still need to
use the return value of this method instead of the original
alist, to ensure correct results."
;; Implementation taken from `straight--alist-set'
;; See [1] for the genesis of this method, which should really be
;; built in.
;;
;; [1]: emacs.stackexchange.com/q/33892/12534
This creates the association if it is missing, and otherwise sets the cdr of the
first matching association in the list. It does not create duplicate
associations. By default, key comparison is done with `equal'. However, if
SYMBOL is non-nil, then `eq' is used instead.
This method may mutate the original alist, but you still need to use the return
value of this method instead of the original alist, to ensure correct results."
(if-let ((pair (if symbol (assq key alist) (assoc key alist))))
(setcdr pair val)
(push (cons key val) alist))
Expand Down

0 comments on commit d6ba81b

Please sign in to comment.