branch: elpa-admin commit 8283500398688134f2a05a7c0a2a8131ec76b8df Author: Stefan Monnier <monn...@iro.umontreal.ca> Commit: Stefan Monnier <monn...@iro.umontreal.ca>
* elpa-admin.el (elpaa--sort-packages): New command --- elpa-admin.el | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/elpa-admin.el b/elpa-admin.el index ecae2795e2..eab88bd8d4 100644 --- a/elpa-admin.el +++ b/elpa-admin.el @@ -2451,5 +2451,31 @@ relative to elpa root." (write-region (point-min) (point-max) dstfile nil 'silent)))) +;;; Edit support for `elpa-packages' + +(defun elpaa--sort-packages () + "Sort packages by alphabetical order." + (interactive) + (goto-char (point-min)) + (down-list 1) + (sort-subr nil + (lambda () + (unless (save-excursion + (forward-comment (point-max)) + (looking-at "(")) + (goto-char (point-max)))) + (lambda () + (forward-sexp 1) + (skip-chars-forward " \t") + (when (or (eolp) (looking-at ";")) + ;; A comment was found between the two entries. + ;; Since it's right after the end (on the same line), + ;; it belongs to this record, otherwise it belongs + ;; to the next. + (forward-line 1)) + (skip-chars-forward " \t\n") + (skip-chars-backward " \t")) + (lambda () (forward-comment (point-max))))) + (provide 'elpa-admin) ;;; elpa-admin.el ends here