Add unset capability to set-file-template!

This commit is contained in:
Henrik Lissner 2018-06-21 13:41:51 +02:00
parent 445ca59b67
commit 8bd9b24137
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -1,5 +1,10 @@
;;; feature/file-templates/autoload.el -*- lexical-binding: t; -*-
(defun +file-templates--set (pred plist)
(if (null (car-safe plist))
(setq +file-templates-alist (map-delete +file-templates-alist pred))
(push `(,pred ,@plist) +file-templates-alist)))
;;;###autodef
(defun set-file-template! (pred &rest plist)
"Register a file template.
@ -23,13 +28,14 @@ these properties:
If non-nil, don't expand any template for this file and don't test any other
file template rule against this buffer."
(after! (:when (boundp '+file-templates-alist))
(push `(,pred ,@plist) +file-templates-alist)))
(+file-templates--set pred plist)))
;;;###autodef
(defun set-file-templates! (&rest templates)
"Like `set-file-templates!', but register many file templates at once."
(after! (:when (boundp '+file-templates-alist))
(setq +file-templates-alist (append (list templates) +file-templates-alist))))
(dolist (template templates)
(+file-templates--set (car template) (cdr template)))))
;; FIXME obsolete :file-template
;;;###autoload