diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/acdw.el | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el index 30cf8af..f642c65 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el | |||
@@ -535,5 +535,36 @@ It's called 'require-private' for historical reasons." | |||
535 | (when (fboundp mode) | 535 | (when (fboundp mode) |
536 | (funcall mode -1))))) | 536 | (funcall mode -1))))) |
537 | 537 | ||
538 | |||
539 | ;;; Sort setq... | ||
540 | ;; https://emacs.stackexchange.com/questions/33039/ | ||
541 | |||
542 | (defun sort-setq () | ||
543 | (interactive) | ||
544 | (save-excursion | ||
545 | (save-restriction | ||
546 | (let ((sort-end (progn (end-of-defun) | ||
547 | (backward-char) | ||
548 | (point-marker))) | ||
549 | (sort-beg (progn (beginning-of-defun) | ||
550 | (re-search-forward "[ \\t]*(" (point-at-eol)) | ||
551 | (forward-sexp) | ||
552 | (re-search-forward "\\<" (point-at-eol)) | ||
553 | (point-marker)))) | ||
554 | (narrow-to-region (1- sort-beg) (1+ sort-end)) | ||
555 | (sort-subr nil #'sort-setq-next-record #'sort-setq-end-record))))) | ||
556 | |||
557 | (defun sort-setq-next-record () | ||
558 | (condition-case nil | ||
559 | (progn | ||
560 | (forward-sexp 1) | ||
561 | (backward-sexp)) | ||
562 | ('scan-error (end-of-buffer)))) | ||
563 | |||
564 | (defun sort-setq-end-record () | ||
565 | (condition-case nil | ||
566 | (forward-sexp 2) | ||
567 | ('scan-error (end-of-buffer)))) | ||
568 | |||
538 | (provide 'acdw) | 569 | (provide 'acdw) |
539 | ;;; acdw.el ends here | 570 | ;;; acdw.el ends here |