diff options
| author | Dodge W. Coates <dcoates91@gmail.com> | 2017-02-25 15:03:19 -0500 |
|---|---|---|
| committer | Dodge W. Coates <dcoates91@gmail.com> | 2017-02-25 15:03:19 -0500 |
| commit | 588a36381106f8162fec8bba0993644a7f219968 (patch) | |
| tree | 68429039544270364448551ff2e020d36ffa94a4 | |
| parent | 17a35e2762a670c3475612c3a36ee1d6a8bf0e93 (diff) | |
Add chess-puzzle-set-default-file
| -rw-r--r-- | chess-puzzle.el | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/chess-puzzle.el b/chess-puzzle.el index d581185..1274746 100644 --- a/chess-puzzle.el +++ b/chess-puzzle.el @@ -74,6 +74,26 @@ it. Useful if you have all of your puzzles in a single file." (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. The spacebar in the display buffer is bound to `chess-puzzle-next', @@ -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) |
