From d7367761b2a020efb58c5a706872c97aa3410c95 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 12 Mar 2021 09:34:44 -0700 Subject: build consfigurator.el entirely from Lisp Signed-off-by: Sean Whitton --- emacs/Makefile | 11 ++--------- src/property.lisp | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/emacs/Makefile b/emacs/Makefile index 3f9309c..2226d2c 100644 --- a/emacs/Makefile +++ b/emacs/Makefile @@ -2,13 +2,6 @@ LOAD = '(let ((asdf:*user-cache* "/tmp") \ (asdf:*central-registry* (list (truename "..")))) \ (asdf:load-system "consfigurator"))' -SUBSTITUTE = 'BEGIN { open FH, "<", "put-forms.el"; \ - chomp($$forms = join "", map s/^/ /r, grep /^\(put/, ) } \ - s/ \@putforms@/$$forms/' - -consfigurator.el: consfigurator.el.in put-forms.el - perl -wpe$(SUBSTITUTE) consfigurator.el.in >consfigurator.el - -put-forms.el: +consfigurator.el: consfigurator.el.in sbcl --disable-debugger --eval '(require "asdf")' --eval $(LOAD) \ - --eval '(consfigurator::dump-properties-for-emacs "$@")' --quit + --eval '(consfigurator::dump-properties-for-emacs "$<" "$@")' --quit diff --git a/src/property.lisp b/src/property.lisp index 56d8b72..82d1b92 100644 --- a/src/property.lisp +++ b/src/property.lisp @@ -107,15 +107,22 @@ (defvar *properties-for-emacs* nil "List of properties whose symbols have Emacs indentation information.") -(defun dump-properties-for-emacs (file) - (with-open-file (s file :direction :output :if-exists :supersede) - (format s ";; automatically generated by~%") - (format s ";; CONSFIGURATOR::DUMP-PROPERTIES-FOR-EMACS; do not edit~%~%") - (loop for (prop . indent) in (nreverse - (mappend (lambda (s) (get s 'indent)) - *properties-for-emacs*)) - do (format s "(put '~A 'common-lisp-indent-function '~A)~%" - prop indent)))) +(defun dump-properties-for-emacs (from to) + (let ((put-forms + (stripln + (with-output-to-string (s) + (loop + for (prop . indent) + in (nreverse (mappend (lambda (s) (get s 'indent)) + *properties-for-emacs*)) + do (format s " (put '~A 'common-lisp-indent-function '~A)~%" + prop indent)))))) + (with-open-file (in from) + (with-open-file (out to :direction :output :if-exists :supersede) + (loop for line = (read-line in nil) + while line + do (princ (re:regex-replace " @putforms@" line put-forms) out) + (terpri out)))))) (defun store-indentation-info-for-emacs (sym args &optional info) (let* ((short-name -- cgit v1.2.3