;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/vars-opts.el (require 'cl-lib) (defun check-binders (binds) (cl-loop for (n _) in binds with no-opt do (unless (special-variable-p n) (push (symbol-name n) no-opt) ) finally (when no-opt (error "No option%s: %s" (if (< 1 (length no-opt)) "s" "") (mapconcat #'identity (reverse no-opt) ", ") )))) (defmacro opts (binds &rest body) (declare (indent 1) (debug let) ) (check-binders binds) `(let ,binds ,@body) ) ;; (opts ((fill-column 1) ;; (a 0) ) ;; u) ; No option: a ;; ;; (defvar dynavar 2000) ;; ;; (opts ((dynavar 3000) ;; (fill-column 1) ;; (a 0) ;; (y 2) ) ;; y) ; No options: a, y ;; ;; (opts ((dynavar 3000) ;; (fill-column 10) ) ;; (delete-char 2) ;; (fill-paragraph) ) ; eval me (provide 'vars-opts)