emacs/lisp/compat.el

35 lines
1.1 KiB
EmacsLisp
Raw Normal View History

2022-01-21 22:34:55 +00:00
;;; compat.el --- Thin backward-compatibility shim -*- lexical-binding: t; -*-
;;; Commentary:
;; I use different versionso of Emacs. Sometimes I have to copy-paste functions
;; from newer Emacs to make my customizations work. This is that file.
;; This is probably ill-advised.
;;; Code:
2022-02-07 04:14:50 +00:00
;; Load stuff in compat/ subdirectory
(dolist (file (directory-files (locate-user-emacs-file "lisp/compat") :full "\\.el\\'"))
(load file :noerror))
2022-01-21 22:34:55 +00:00
2022-04-12 18:16:49 +00:00
;; Other stuff...
(unless (fboundp 'dlet)
(defmacro dlet (binders &rest body)
"Like `let' but using dynamic scoping."
(declare (indent 1) (debug let))
;; (defvar FOO) only affects the current scope, but in order for
;; this not to affect code after the main `let' we need to create a new scope,
;; which is what the surrounding `let' is for.
;; FIXME: (let () ...) currently doesn't actually create a new scope,
;; which is why we use (let (_) ...).
`(let (_)
,@(mapcar (lambda (binder)
`(defvar ,(if (consp binder) (car binder) binder)))
binders)
(let ,binders ,@body))))
2022-01-21 22:34:55 +00:00
(provide 'compat)
;;; compat.el ends here