From ee1720b8ade5266efd0895b7b2fd1d820b8cdd56 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 17 Jan 2022 01:19:43 -0600 Subject: Add sort-setq --- lisp/+emacs.el | 6 ++++-- lisp/+lisp.el | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lisp/+emacs.el b/lisp/+emacs.el index 312657e..1679886 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el @@ -43,6 +43,7 @@ Do this only if the buffer is not visiting a file." backup-by-copying t backup-directory-alist `((".*" . ,(.etc "backup/" t))) blink-cursor-blinks 1 + comp-deferred-compilation nil completion-category-defaults nil completion-category-overrides '((file (styles . (partial-completion)))) completion-ignore-case t @@ -68,15 +69,15 @@ Do this only if the buffer is not visiting a file." hscroll-step 1 imenu-auto-rescan t indent-tabs-mode nil - indicate-empty-lines nil indicate-buffer-boundaries 'left + indicate-empty-lines nil inhibit-startup-screen t initial-buffer-choice t kill-do-not-save-duplicates t kill-read-only-ok t kill-ring-max 500 kmacro-ring-max 20 - load-prefer-newer t + load-prefer-newer noninteractive major-mode '+set-major-mode-from-buffer-name mark-ring-max 50 minibuffer-eldef-shorten-default t @@ -88,6 +89,7 @@ Do this only if the buffer is not visiting a file." mouse-wheel-progressive-speed nil mouse-yank-at-point t native-comp-async-report-warnings-errors 'silent + native-comp-deferred-compilation nil read-answer-short t read-buffer-completion-ignore-case t read-extended-command-predicate (when (fboundp diff --git a/lisp/+lisp.el b/lisp/+lisp.el index 07dfcbd..c45fdf6 100644 --- a/lisp/+lisp.el +++ b/lisp/+lisp.el @@ -156,5 +156,38 @@ With a prefix argument N, (un)comment that many sexps." (dotimes (_ (or n 1)) (+lisp-comment-sexp--raw)))) +;;; Sort `setq' constructs +(defun +lisp-sort-setq () + (interactive) + (save-excursion + (save-restriction + (let ((sort-end (progn + (end-of-defun) + (backward-char) + (point-marker))) + (sort-beg (progn + (beginning-of-defun) + (or (re-search-forward "[ \\t]*(" (point-at-eol) t) + (point-at-eol)) + (forward-sexp) + (or (re-search-forward "\\<" (point-at-eol) t) + (point-at-eol)) + (point-marker)))) + (narrow-to-region (1- sort-beg) (1+ sort-end)) + (sort-subr nil #'+lisp-sort-setq-next-record + #'+lisp-sort-setq-end-record))))) + +(defun +lisp-sort-setq-next-record () + (condition-case nil + (progn + (forward-sexp 1) + (backward-sexp)) + ('scan-error (end-of-buffer)))) + +(defun +lisp-sort-setq-end-record () + (condition-case nil + (forward-sexp 2) + ('scan-error (end-of-buffer)))) + (provide '+lisp) ;;; +lisp.el ends here -- cgit 1.4.1-21-gabe81