;;; choose-restaurant.el ;;; ;;; Copyright (C) 2002, 2004, 2007, 2008 Thien-Thi Nguyen ;;; ;;; This file is part of ttn's personal elisp library, released under ;;; the terms of the GNU General Public License as published by the ;;; Free Software Foundation; either version 3, or (at your option) any ;;; later version. There is NO WARRANTY. See file COPYING for details. ;;; Description: Choose a restaurant from ~/.restaurants, perhaps continuously. (defun file-lines (file) (split-string (shell-command-to-string (format "cat %s" file)) "\n")) ;;;###autoload (defun choose-restaurant () ; yummy (interactive) (let ((choices (file-lines "~/.restaurants"))) (message "%s -- go now!" (nth (random (length choices)) choices)))) ;;;###autoload (defun choose-restaurant-continuously () (interactive) (let ((choices (file-lines "~/.restaurants")) (choice t)) (while choice (while (progn (setq choice (nth (random (length choices)) choices)) (message "SPC to stop, q to quit: %s" choice) (sit-for 0.03))) (setq choice (not (= ?q (read-char-exclusive)))) (sleep-for 3)))) (provide 'choose-restaurant) ;;; choose-restaurant.el ends here