From 4c361a95cc01a34bea140e633f55e0940177593a Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 26 Dec 2015 22:35:48 +0200 Subject: [PATCH] Don't try using /bin/sh in artist.el on MS-Windows * lisp/textmodes/artist.el (artist-figlet-get-font-list-windows): New function. (artist-figlet-choose-font): Use it on MS-Windows and MS-DOS. (Bug#20167) --- lisp/textmodes/artist.el | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lisp/textmodes/artist.el b/lisp/textmodes/artist.el index a29418e6f84..373ab14e3fb 100644 --- a/lisp/textmodes/artist.el +++ b/lisp/textmodes/artist.el @@ -2873,10 +2873,36 @@ Returns a list of strings." (error "Failed to read available fonts: %s (%d)" stderr exit-code)) (artist-string-split stdout ".flf\n"))) +(defun artist-figlet-get-font-list-windows () + "Read in fonts on MS-Windows by collecting output of the `figlet' program. +Returns a list of strings." + (let* ((ls-cmd "figlet -I2") + (result (artist-system shell-file-name nil + (list shell-command-switch ls-cmd))) + (exit-code (elt result 0)) + (stdout (elt result 1)) + (stderr (elt result 2))) + (if (not (= exit-code 0)) + (error "Failed to read available fonts: %s (%d)" stderr exit-code)) + (let ((dir-list (artist-string-split stdout "\n")) + result) + (mapc + (lambda (dir) + (let ((default-directory dir)) + (setq result (append (file-expand-wildcards "*.flf") result)))) + dir-list) + (mapcar + (lambda (file) + (replace-regexp-in-string "\.flf\\'" "" file)) + result)))) + (defun artist-figlet-choose-font () "Read any extra arguments for figlet." (interactive) - (let* ((avail-fonts (artist-figlet-get-font-list)) + (let* ((avail-fonts + (if (memq system-type '(windows-nt ms-dos)) + (artist-figlet-get-font-list-windows) + (artist-figlet-get-font-list))) (font (completing-read (concat "Select font (default " artist-figlet-default-font "): ") -- 2.39.2