From 588a36381106f8162fec8bba0993644a7f219968 Mon Sep 17 00:00:00 2001 From: "Dodge W. Coates" Date: Sat, 25 Feb 2017 15:03:19 -0500 Subject: Add chess-puzzle-set-default-file --- chess-puzzle.el | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/chess-puzzle.el b/chess-puzzle.el index d581185..1274746 100644 --- a/chess-puzzle.el +++ b/chess-puzzle.el @@ -73,6 +73,26 @@ it. Useful if you have all of your puzzles in a single file." '((bad-game-read . "Error reading game at position %d") (end-of-puzzles . "There are no more puzzles in this collection"))) +;;;###autoload +(defun chess-puzzle-set-defualt-file (file) + "Set the default puzzle file to FILE for the current session." + (interactive + (list (let* ((file-name (or chess-puzzle-default-file + (file-name-directory (buffer-file-name)))) + (file-p (not (file-directory-p file-name))) + (def-file (read-file-name + "Set puzzle file to: " + (file-name-directory file-name) + (when file-p file-name) t))) + (if (file-directory-p def-file) + (file-name-as-directory def-file) + def-file)))) + (setq chess-puzzle-default-file file) + (when (yes-or-no-p "Load a chess puzzle?: ") + (let ((chess-puzzle-autoload-file t)) + (unless (call-interactively 'chess-puzzle)))) + (message "chess-puzzle-default-file set to '%s'" file)) + ;;;###autoload (defun chess-puzzle (file &optional index) ;FIXME: index not used! "Pick a random puzzle from FILE, and solve it against the default engine. @@ -89,7 +109,7 @@ making it easy to go on to the next puzzle once you've solved one." (if file-p (concat " (" - (abbreviate-file-name file-name) + (file-name-nondirectory file-name) ")") "")) (file-name-directory file-name) -- cgit v1.2.3