From 4cf60c3fea16b60eb18c9a7d8403b75c89aeffef Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 21 Oct 2022 21:37:30 -0500 Subject: blhe --- lisp/yoke.el | 72 +++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 30 deletions(-) (limited to 'lisp/yoke.el') diff --git a/lisp/yoke.el b/lisp/yoke.el index 4f40869..68b02c4 100644 --- a/lisp/yoke.el +++ b/lisp/yoke.el @@ -47,20 +47,20 @@ installed to `yoke-dir'." (let ((generated-autoload-file (expand-file-name (format "%s-autoloads.el" pkg) dir)) (backup-inhibited t) - (version-control 'never) - (message-log-max nil) - (inhibit-message t)) - (unless (file-exists-p generated-autoload-file) - (let ((find-file-hook nil) - (write-file-functions nil) - (debug-on-error nil) - (left-margin 0)) - (if (fboundp 'make-directory-autoloads) - (make-directory-autoloads dir generated-autoload-file) - (and (fboundp 'update-directory-autoloads) - (update-directory-autoloads dir))))) - (when-let ((buf (find-buffer-visiting generated-autoload-file))) - (kill-buffer buf)) + (version-control 'never) + (message-log-max nil) + (inhibit-message t)) + (unless (file-exists-p generated-autoload-file) + (let ((find-file-hook nil) + (write-file-functions nil) + (debug-on-error nil) + (left-margin 0)) + (if (fboundp 'make-directory-autoloads) + (make-directory-autoloads dir generated-autoload-file) + (and (fboundp 'update-directory-autoloads) + (update-directory-autoloads dir))))) + (when-let ((buf (find-buffer-visiting generated-autoload-file))) + (kill-buffer buf)) (load generated-autoload-file :noerror :nomessage))) (t (user-error "Directory \"%s\" doesn't exist." dir))) dir)) @@ -83,13 +83,13 @@ Similar-ish to `plist-get', but works on non-proper plists." ,g)))) (defun delete2 (list &rest elems) - "Delete ELEM and the next item from LIST." + "Delete each element of ELEMS, and the next item, from LIST." (let ((r nil)) (while (consp list) (if (member (car list) elems) - (setq list (cdr list)) - (setq r (cons (car list) r))) - (setq list (cdr list))) + (setf list (cdr list)) + (setf r (cons (car list) r))) + (setf list (cdr list))) (reverse r))) (defun eval-after-init (fn) @@ -105,17 +105,17 @@ FEATURES can be an atom or a list; as an atom it works like `with-eval-after-load'. The special feature `init' will evaluate BODY after Emacs is finished initializing." (declare (indent 1) - (debug (form def-body))) + (debug (form def-body))) (if (eq features 'init) `(eval-after-init (lambda () ,@body)) (unless (listp features) - (setq features (list features))) + (setf features (list features))) (if (null features) - (macroexp-progn body) + (macroexp-progn body) (let* ((this (car features)) - (rest (cdr features))) - `(with-eval-after-load ',this - (eval-after ,rest ,@body)))))) + (rest (cdr features))) + `(with-eval-after-load ',this + (eval-after ,rest ,@body)))))) (defun yoke-pkg-name (pkg) (intern (format "yoke:%s" pkg))) @@ -131,7 +131,7 @@ BODY after Emacs is finished initializing." (unless nil unlessp) ; :unless PREDICATE &allow-other-keys) "Yoke a PKG into your Emacs session." - (declare (indent defun)) + (declare (indent 2)) (let ((name (yoke-pkg-name pkg)) (body (delete2 body :depends :when :unless :after :load))) @@ -141,11 +141,11 @@ BODY after Emacs is finished initializing." (*yoke-repo* ,repo) (*yoke-dest* ,(when repo `(yoke-repo-dir ',pkg ,repo)))) ,@(cond - ((and whenp unlessp) - `((when (or (not ,when) ,unless) - (cl-return-from ,name nil)))) - (whenp `((unless ,when (cl-return-from ,name nil)))) - (unlessp `((when ,unless (cl-return-from ,name nil))))) + ((and whenp unlessp) + `((when (or (not ,when) ,unless) + (cl-return-from ,name nil)))) + (whenp `((unless ,when (cl-return-from ,name nil)))) + (unlessp `((when ,unless (cl-return-from ,name nil))))) ,@(cl-loop for (pkg* repo* load-path*) in depends collect `(or (yoke-lasso ',pkg* ,repo* ,load-path*) (cl-return-from ,name nil))) @@ -157,3 +157,15 @@ BODY after Emacs is finished initializing." body)) (:success ',pkg) (t (message "%s: %s" ',name e)))))) + +;;; Extras + +(defun yoke-imenu-insinuate () + "Insinuate `yoke' forms for `imenu'." + (require 'imenu) + (setf (alist-get "Yoke" imenu-generic-expression nil nil #'equal) + (list (rx (: "(yoke" (+ space) + (group (+ (not space))) + (+ space) + (group (+ (not space))))) + 1))) -- cgit 1.4.1-21-gabe81