Skip to content

Commit

Permalink
feat(core): add function to get/set the standard values
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Jan 1, 2024
1 parent 3c5d6e9 commit 540ad79
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions core/me-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,21 @@ value of this method instead of the original alist, to ensure correct results."

;;; Missing primitive utilities

;; See: emacs.stackexchange.com/q/3022/37002
(defun +set-standard-value (variable value)
"Set the standard value of VARIABLE to VALUE."
(put variable 'standard-value `((funcall (function ,(lambda nil "" value))))))

(defun +standard-value (variable)
"Return the standard value for VARIABLE."
(eval (car (get variable 'standard-value)) t))

(defun +reset-sym (sym)
"Reset SYM to its standard value."
(set sym (eval (car (get sym 'standard-value)))))
(set sym (+standard-value sym)))

(defmacro +reset-var! (var)
"Reset VAR to its standard value."
`(setq ,var (eval (car (get ',var 'standard-value)))))
`(setq ,var (+standard-value ',var)))

;; Adapted from `evil-unquote', takes functions into account
(defun +unquote (expr)
Expand Down

0 comments on commit 540ad79

Please sign in to comment.