mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 12:31:25 +00:00
Sort Eshell aliases when adding new ones
The main point is to make the content of 'eshell-aliases-file' stable so that storing it in git becomes feasible. This also makes the output of the alias command come out in alphabetical order (bug#80401). * lisp/eshell/em-alias.el (eshell/alias): Sort when updating 'eshell-command-aliases-list'. * test/lisp/eshell/em-alias-tests.el (em-alias-test/alias-list-is-sorted): New test. * etc/NEWS: Announce this change.
This commit is contained in:
parent
f7d795d9c9
commit
53111ba9f8
3 changed files with 19 additions and 1 deletions
7
etc/NEWS
7
etc/NEWS
|
|
@ -1977,6 +1977,13 @@ only search in input history. If you customize it to the symbol 'dwim',
|
|||
those commands search in input history only when the point is after the
|
||||
last prompt.
|
||||
|
||||
---
|
||||
*** Eshell 'alias' command now sorts the alias list.
|
||||
When adding an alias interactively, Eshell now sorts the list of aliases
|
||||
before saving the alias file. This maintains the stability of the
|
||||
list of aliases to make the diff between versions more readable if you
|
||||
store your aliases in version control.
|
||||
|
||||
** Mail Utils
|
||||
|
||||
+++
|
||||
|
|
|
|||
|
|
@ -173,7 +173,9 @@ file named by `eshell-aliases-file'.")
|
|||
(setq eshell-command-aliases-list
|
||||
(delq def eshell-command-aliases-list)))
|
||||
(setq eshell-command-aliases-list
|
||||
(cons alias-def eshell-command-aliases-list))))
|
||||
(sort (cons alias-def eshell-command-aliases-list)
|
||||
(lambda (a b)
|
||||
(string< (car a) (car b)))))))
|
||||
(eshell-write-aliases-list))
|
||||
nil)
|
||||
|
||||
|
|
|
|||
|
|
@ -93,4 +93,13 @@
|
|||
(eshell-insert-command "alias add-funny-pair '+ $*[0][: 0] $*[1][: 1]'")
|
||||
(eshell-match-command-output "add-funny-pair 1:2 3:4" "5\n")))
|
||||
|
||||
(ert-deftest em-alias-test/alias-list-is-sorted ()
|
||||
"Test that the alias list is sorted on insert"
|
||||
(with-temp-eshell
|
||||
(eshell-insert-command "alias aaa 'aaa'")
|
||||
(eshell-insert-command "alias ccc 'ccc'")
|
||||
(eshell-insert-command "alias bbb 'bbb'")
|
||||
(eshell-match-command-output
|
||||
"alias" "alias aaa aaa\nalias bbb bbb\nalias ccc ccc\n")))
|
||||
|
||||
;; em-alias-tests.el ends here
|
||||
|
|
|
|||
Loading…
Reference in a new issue