summary refs log tree commit diff stats
path: root/lisp/+lisp.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/+lisp.el')
-rw-r--r--lisp/+lisp.el33
1 files changed, 33 insertions, 0 deletions
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."
156 (dotimes (_ (or n 1)) 156 (dotimes (_ (or n 1))
157 (+lisp-comment-sexp--raw)))) 157 (+lisp-comment-sexp--raw))))
158 158
159;;; Sort `setq' constructs
160(defun +lisp-sort-setq ()
161 (interactive)
162 (save-excursion
163 (save-restriction
164 (let ((sort-end (progn
165 (end-of-defun)
166 (backward-char)
167 (point-marker)))
168 (sort-beg (progn
169 (beginning-of-defun)
170 (or (re-search-forward "[ \\t]*(" (point-at-eol) t)
171 (point-at-eol))
172 (forward-sexp)
173 (or (re-search-forward "\\<" (point-at-eol) t)
174 (point-at-eol))
175 (point-marker))))
176 (narrow-to-region (1- sort-beg) (1+ sort-end))
177 (sort-subr nil #'+lisp-sort-setq-next-record
178 #'+lisp-sort-setq-end-record)))))
179
180(defun +lisp-sort-setq-next-record ()
181 (condition-case nil
182 (progn
183 (forward-sexp 1)
184 (backward-sexp))
185 ('scan-error (end-of-buffer))))
186
187(defun +lisp-sort-setq-end-record ()
188 (condition-case nil
189 (forward-sexp 2)
190 ('scan-error (end-of-buffer))))
191
159(provide '+lisp) 192(provide '+lisp)
160;;; +lisp.el ends here 193;;; +lisp.el ends here