# HG changeset patch # User Richard Westhaver # Date 1727225867 14400 # Node ID ca09f470abb3f27d96588b1847b0d5fccc739c19 # Parent 176715089769600d7497eaf65eee562be57486c0 rm dir-locals and makefile, added dir-locals hacks in sk.el diff -r 176715089769 -r ca09f470abb3 .dir-locals.el --- a/.dir-locals.el Tue Sep 24 16:47:38 2024 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -((nil . ((indent-tabs-mode . nil))) -(rust-mode . ((eglot-workspace-configuration - . (:rust-analyzer (:cargo (:buildScripts (:enable t) (:features "all"))))))) -(nushell-mode . ((nushell-indent-offset . 2))) -(nushell-ts-mode . ((nushell-indent-offset . 2))) -(sh-mode . (sh-indentation . 2)) -(makefile-mode . ((indent-tabs-mode . t))) -(slint-mode . ((slint-indent-level . 2)))) diff -r 176715089769 -r ca09f470abb3 emacs/default.el --- a/emacs/default.el Tue Sep 24 16:47:38 2024 -0400 +++ b/emacs/default.el Tue Sep 24 20:57:47 2024 -0400 @@ -365,10 +365,10 @@ (setq sh-basic-offset 2) ;;; Graphviz -(use-package graphviz-dot-mode - :ensure t - :config - (setq graphviz-dot-indent-width 2)) +;; (use-package graphviz-dot-mode +;; :ensure t +;; :config +;; (setq graphviz-dot-indent-width 2)) ;;; Comments (defcustom prog-comment-keywords '("TODO" "REVIEW" "FIX" "HACK" "RESEARCH") @@ -783,7 +783,7 @@ tramp-default-host "localhost") ;;; Imenu -(use-package imenu-list :ensure t) +;; (use-package imenu-list :ensure t) ;;; Org (require 'org) diff -r 176715089769 -r ca09f470abb3 emacs/emacs.sk --- a/emacs/emacs.sk Tue Sep 24 16:47:38 2024 -0400 +++ b/emacs/emacs.sk Tue Sep 24 20:57:47 2024 -0400 @@ -1,4 +1,3 @@ -;;; core/lisp skel system :name "core/emacs" :path "emacs" ;; :components ((:org "babel")) diff -r 176715089769 -r ca09f470abb3 emacs/lib/sk.el --- a/emacs/lib/sk.el Tue Sep 24 16:47:38 2024 -0400 +++ b/emacs/lib/sk.el Tue Sep 24 20:57:47 2024 -0400 @@ -150,11 +150,59 @@ (add-to-list 'auto-mode-alist '("skelfile" . skel-mode)) (add-to-list 'auto-mode-alist '("\\.sk" . skel-mode))) +(defun project-skelfile-path (&optional project) + "Find skelfile associated with PROJECT. Defaults to current +directory and returns name of skelfile. When PROJECT is T uses +`project-current'." + (let* ((dir (unless (eql t project) (expand-file-name (or project default-directory)))) + (project-root (project-root (project-current nil dir)))) + (or + (when dir + (cl-find-if + (lambda (x) + (when (string-match + (rx (or "skelfile" (and (* any) ".sk"))) + (file-name-nondirectory x)) + x)) + (directory-files dir t))) + (when project + (cl-find-if (lambda (x) + (when (string-match (rx (or "skelfile" (and (* any) ".sk"))) + (file-name-nondirectory x)) + x)) + (directory-files project-root t)))))) + +(defun read-skelfile-bind (&optional project) + (let ((buffer (find-file-noselect (project-skelfile-path project)))) + (with-current-buffer buffer + (goto-char (point-min)) + (goto-char (search-forward-regexp (rx bol ":bind" (* space)))) + (read buffer)))) + +(defun project-skelfile-dir-locals (&optional project) + "Return a list of dir-local bindings from a skelfile." + (let ((form (read-skelfile-bind project))) + (cl-loop for f in form + do (cond + ((eql (car f) :dir-locals) (cl-return (cdr f))) + ;; when used as second element, the first is the name + ;; of the CL-local binding, here we discard it and + ;; just take the CDDR. + ((eql (cadr f) :dir-locals) (cl-return (cddr f))))))) + (defun skel-dir-local--get-variables () "Compute and return the list of :DIR-LOCAL bindings found in the current project's skelfile, if any. Typically added to `hack-dir-local--get-variables'." - ) + (let ((root (project-root (project-current)))) + (cons (expand-file-name root) (project-skelfile-dir-locals root)))) + +(defun %skel-dir-local--get-variables () + (let ((root (expand-file-name (project-root (project-current))))) + (unless (assoc-string root dir-locals-class-alist) + (push (skel-dir-local--get-variables) dir-locals-class-alist)))) + +(add-hook 'skel-minor-mode-hook '%skel-dir-local--get-variables) (provide 'skel) (provide 'sk) diff -r 176715089769 -r ca09f470abb3 emacs/makefile --- a/emacs/makefile Tue Sep 24 16:47:38 2024 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -DOTEMACS:=$(HOME)/.emacs.d -install:$(wildcard *.el) lib - mkdir -pv $(DOTEMACS) - cp -rf $^ $(DOTEMACS)/ -.PHONY: c -clean:;rm -rf $(DOTEMACS)/{*.el,lisp,site-lisp} diff -r 176715089769 -r ca09f470abb3 skelfile --- a/skelfile Tue Sep 24 16:47:38 2024 -0400 +++ b/skelfile Tue Sep 24 20:57:47 2024 -0400 @@ -12,14 +12,14 @@ :bind ((stash ".stash") ;; (cc :env "clang") (emacs-locals :dir-locals - (nil . ((indent-tabs-mode . nil))) - (rust-mode . ((eglot-workspace-configuration - . (:rust-analyzer (:cargo (:buildScripts (:enable t) (:features "all"))))))) - (nushell-mode . ((nushell-indent-offset . 2))) - (nushell-ts-mode . ((nushell-indent-offset . 2))) - (sh-mode . (sh-indentation . 2)) - (makefile-mode . ((indent-tabs-mode . t))) - (slint-mode . ((slint-indent-level . 2))))) + (nil . ((indent-tabs-mode . nil))) + (rust-mode . ((eglot-workspace-configuration + . (:rust-analyzer (:cargo (:buildScripts (:enable t) (:features "all"))))))) + (nushell-mode . ((nushell-indent-offset . 2))) + (nushell-ts-mode . ((nushell-indent-offset . 2))) + (sh-mode . (sh-indentation . 2)) + (makefile-mode . ((indent-tabs-mode . t))) + (slint-mode . ((slint-indent-level . 2))))) :components ((:org "readme") (:mod "emacs") (:mod "lisp")