diff options
| author | Spencer Baugh | 2023-07-09 22:21:03 -0400 |
|---|---|---|
| committer | Eli Zaretskii | 2023-07-26 17:41:48 +0300 |
| commit | 2aec67f4deb1a7dfd87f7da8479be4b2784bcc39 (patch) | |
| tree | 30f1ffd66cc9385a42d7c34bf4f0bbe4dd269347 /test | |
| parent | 4ef9cc5a5ded7156e573a67474f3f48da6c7afe4 (diff) | |
| download | emacs-2aec67f4deb1a7dfd87f7da8479be4b2784bcc39.tar.gz emacs-2aec67f4deb1a7dfd87f7da8479be4b2784bcc39.zip | |
Support transforming the dirname used by uniquify
By transforming the buffer's directory name, we can add
additional information to use during uniquifying. A basic
one: uniquifying buffer names based on the project name.
* lisp/progmodes/project.el (project-uniquify-dirname-transform): Add.
* lisp/uniquify.el (uniquify-dirname-transform-default)
(uniquify-dirname-transform): Add. (Bug#62621)
(uniquify-rationalize-file-buffer-names, uniquify-buffer-file-name):
Use 'uniquify-dirname-transform'.
* test/lisp/uniquify-tests.el (uniquify-home)
(uniquify-project-transform): Add tests.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/uniquify-tests.el | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/lisp/uniquify-tests.el b/test/lisp/uniquify-tests.el index abd61fa3504..e533c4b644c 100644 --- a/test/lisp/uniquify-tests.el +++ b/test/lisp/uniquify-tests.el | |||
| @@ -88,6 +88,21 @@ | |||
| 88 | '("a/dir/" "b/dir/"))) | 88 | '("a/dir/" "b/dir/"))) |
| 89 | (mapc #'kill-buffer bufs))))) | 89 | (mapc #'kill-buffer bufs))))) |
| 90 | 90 | ||
| 91 | (ert-deftest uniquify-home () | ||
| 92 | "uniquify works, albeit confusingly, in the presence of directories named \"~\"" | ||
| 93 | (let (bufs) | ||
| 94 | (save-excursion | ||
| 95 | (push (find-file-noselect "~") bufs) | ||
| 96 | (push (find-file-noselect "./~") bufs) | ||
| 97 | (should (equal (mapcar #'buffer-name bufs) | ||
| 98 | '("~<test>" "~<>"))) | ||
| 99 | (push (find-file-noselect "~/foo") bufs) | ||
| 100 | (push (find-file-noselect "./~/foo") bufs) | ||
| 101 | (should (equal (mapcar #'buffer-name bufs) | ||
| 102 | '("foo<~>" "foo</nonexistent>" "~<test>" "~<>"))) | ||
| 103 | (while bufs | ||
| 104 | (kill-buffer (pop bufs)))))) | ||
| 105 | |||
| 91 | (ert-deftest uniquify-rename-to-dir () | 106 | (ert-deftest uniquify-rename-to-dir () |
| 92 | "Giving a buffer a name which matches a directory doesn't rename the buffer" | 107 | "Giving a buffer a name which matches a directory doesn't rename the buffer" |
| 93 | (let ((uniquify-buffer-name-style 'forward) | 108 | (let ((uniquify-buffer-name-style 'forward) |
| @@ -125,5 +140,23 @@ uniquify-trailing-separator-p is ignored" | |||
| 125 | (should (equal (buffer-name) "| foo")) | 140 | (should (equal (buffer-name) "| foo")) |
| 126 | (kill-buffer))) | 141 | (kill-buffer))) |
| 127 | 142 | ||
| 143 | (require 'project) | ||
| 144 | (ert-deftest uniquify-project-transform () | ||
| 145 | "`project-uniquify-dirname-transform' works" | ||
| 146 | (let ((uniquify-dirname-transform #'project-uniquify-dirname-transform) | ||
| 147 | (project-vc-name "foo1/bar") | ||
| 148 | bufs) | ||
| 149 | (save-excursion | ||
| 150 | (should (file-exists-p "../README")) | ||
| 151 | (push (find-file-noselect "../README") bufs) | ||
| 152 | (push (find-file-noselect "other/README") bufs) | ||
| 153 | (should (equal (mapcar #'buffer-name bufs) | ||
| 154 | '("README<other>" "README<bar>"))) | ||
| 155 | (push (find-file-noselect "foo2/bar/README") bufs) | ||
| 156 | (should (equal (mapcar #'buffer-name bufs) | ||
| 157 | '("README<foo2/bar>" "README<other>" "README<foo1/bar>"))) | ||
| 158 | (while bufs | ||
| 159 | (kill-buffer (pop bufs)))))) | ||
| 160 | |||
| 128 | (provide 'uniquify-tests) | 161 | (provide 'uniquify-tests) |
| 129 | ;;; uniquify-tests.el ends here | 162 | ;;; uniquify-tests.el ends here |