diff options
| author | Basil L. Contovounesios | 2018-06-04 02:12:33 +0100 |
|---|---|---|
| committer | Stefan Monnier | 2018-07-13 11:28:16 -0400 |
| commit | 70d702d3b1c40f72059bb5694bd805b1c65d141d (patch) | |
| tree | cb59139dbdde17172e36b649a598db478829a498 /lisp | |
| parent | 530aa469a4de7b4800557ae783f6c450df59a5b4 (diff) | |
| download | emacs-70d702d3b1c40f72059bb5694bd805b1c65d141d.tar.gz emacs-70d702d3b1c40f72059bb5694bd805b1c65d141d.zip | |
Fix custom-available-themes file expansion
For discussion, see thread starting at
https://lists.gnu.org/archive/html/emacs-devel/2018-05/msg00222.html.
* lisp/custom.el: (custom-available-themes): Use directory-files
instead of performing arbitrary wildcard expansion in file names.
(custom-theme--load-path): Document return value.
* test/lisp/custom-tests.el: New file.
(custom-theme--load-path): New test.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/custom.el | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/lisp/custom.el b/lisp/custom.el index b8ea8811a2a..4536788eb20 100644 --- a/lisp/custom.el +++ b/lisp/custom.el | |||
| @@ -1311,19 +1311,25 @@ The returned symbols may not correspond to themes that have been | |||
| 1311 | loaded, and no effort is made to check that the files contain | 1311 | loaded, and no effort is made to check that the files contain |
| 1312 | valid Custom themes. For a list of loaded themes, check the | 1312 | valid Custom themes. For a list of loaded themes, check the |
| 1313 | variable `custom-known-themes'." | 1313 | variable `custom-known-themes'." |
| 1314 | (let (sym themes) | 1314 | (let ((suffix "-theme\\.el\\'") |
| 1315 | themes) | ||
| 1315 | (dolist (dir (custom-theme--load-path)) | 1316 | (dolist (dir (custom-theme--load-path)) |
| 1316 | (when (file-directory-p dir) | 1317 | ;; `custom-theme--load-path' promises DIR exists and is a |
| 1317 | (dolist (file (file-expand-wildcards | 1318 | ;; directory, but `custom.el' is loaded too early during |
| 1318 | (expand-file-name "*-theme.el" dir) t)) | 1319 | ;; bootstrap to use `cl-lib' macros, so guard with |
| 1319 | (setq file (file-name-nondirectory file)) | 1320 | ;; `file-directory-p' instead of calling `cl-assert'. |
| 1320 | (and (string-match "\\`\\(.+\\)-theme.el\\'" file) | 1321 | (dolist (file (and (file-directory-p dir) |
| 1321 | (setq sym (intern (match-string 1 file))) | 1322 | (directory-files dir nil suffix))) |
| 1322 | (custom-theme-name-valid-p sym) | 1323 | (let ((theme (intern (substring file 0 (string-match-p suffix file))))) |
| 1323 | (push sym themes))))) | 1324 | (and (custom-theme-name-valid-p theme) |
| 1324 | (nreverse (delete-dups themes)))) | 1325 | (not (memq theme themes)) |
| 1326 | (push theme themes))))) | ||
| 1327 | (nreverse themes))) | ||
| 1325 | 1328 | ||
| 1326 | (defun custom-theme--load-path () | 1329 | (defun custom-theme--load-path () |
| 1330 | "Expand `custom-theme-load-path' into a list of directories. | ||
| 1331 | Members of `custom-theme-load-path' that either don't exist or | ||
| 1332 | are not directories are omitted from the expansion." | ||
| 1327 | (let (lpath) | 1333 | (let (lpath) |
| 1328 | (dolist (f custom-theme-load-path) | 1334 | (dolist (f custom-theme-load-path) |
| 1329 | (cond ((eq f 'custom-theme-directory) | 1335 | (cond ((eq f 'custom-theme-directory) |