我还以为是在说这个——emacs煮咖啡script... 1 ;;; coffee.el --- Submit a BREW request to an RFC2324-compliant coffee device 2 ;;; 3 ;;; Author: Eric Marsden <emarsden@laas.fr> 4 ;;; Version: 0.2 5 ;;; Copyright: (C) 1999 Eric Marsden 6 ;;; Keywords: coffee, brew, kitchen-sink, can't 7 ;; 8 ;; This program is free software; you can redistribute it and/or 9 ;; modify it under the terms of the GNU General Public License as 10 ;; published by the Free Software Foundation; either version 2 of 11 ;; the License, or (at your option) any later version. 12 ;; 13 ;; This program is distributed in the hope that it will be useful, 14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 ;; GNU General Public License for more details. 17 ;; 18 ;; You should have received a copy of the GNU General Public 19 ;; License along with this program; if not, write to the Free 20 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 21 ;; MA 02111-1307, USA. 22 ;; 23 ;; Please send suggestions and bug reports to <emarsden@laas.fr>. 24 ;; The latest version of this package should be available at 25 ;; 26 ;; <URL:http://purl.org/net/emarsden/home/downloads/> 27 28 ;;; Commentary: 29 ;; 30 ;; This module provides an Emacs interface to RFC2324-compliant coffee 31 ;; devices (Hyper Text Coffee Pot Control Protocol, or HTCPCP). It 32 ;; prompts the user for the different additives, then issues a BREW 33 ;; request to the coffee device. 34 ;; 35 ;; coffee.el requires a special BREW-capable version of Emacs/W3 to be 36 ;; installed. 37 ;; 38 ;; Reference: <URL:ftp://ftp.isi.edu/in-notes/rfc2324.txt> 39 ;; 40 ;; 41 ;; Thanks to Giacomo Boffi <giacomo.boffi@polimi.it> for some typos 42 ;; and the addition of the "Brown-Coffee" sweetener type. 43 44 ;;; Code: 45 46 (require 'cl) 47 48 (defvar coffee-host "coffee" 49 "*The host which provides the coffee service.") 50 51 (defvar coffee-pot-designator 1 52 "*On machines with multiple pots, the number of the pot to brew in") 53 54 (defvar coffee-brew-hook nil 55 "*Hook executed before issuing a BREW request") 56 57 (defconst coffee-milk-types 58 '("Cream" "Half-and-Half" "Whole-Milk" "Part-Skim" "Skim" "Non-Dairy")) 59 60 (defconst coffee-syrup-types '("Vanilla" "Almond" "Raspberry" "Chocolate")) 61 62 (defconst coffee-sweetener-types '("White-Sugar" "Brown-Sugar" "Artificial-Sweetener")) 63 64 (defconst coffee-alcohol-types '("Whiskey" "Rum" "Kahula" "Aquavit")) 65 66 (defconst coffee-addition-types 67 `(("Milk" . ,coffee-milk-types) 68 ("Syrup" . ,coffee-syrup-types) 69 ("Sweetener" . ,coffee-sweetener-types) 70 ("Alcohol" . ,coffee-alcohol-types))) 71 72 ;;;###autoload 73 (defun coffee () 74 "Submit a BREW request to an RFC2324-compliant coffee device" 75 (interactive) 76 (require 'url) 77 (let* ((additions-list 78 (append coffee-milk-types 79 coffee-syrup-types 80 coffee-sweetener-types 81 coffee-alcohol-types)) 82 (additions-string 83 (mapconcat #'identity additions-list ",")) 84 (url (coffee-url)) 85 (url-request-method "BREW") 86 (url-request-extra-headers 87 `(("Content-type" . "message-coffeepot") 88 ("Accept-Additions" . ,additions-string))) 89 (url-request-data "START")) 90 (run-hooks 'coffee-brew-hook) 91 (url-retrieve url))) 92 93 (defun coffee-additions () 94 (let* ((type-name 95 (completing-read "Coffee addition: " coffee-addition-types nil t)) 96 (type (cdr (assoc type-name coffee-addition-types))) 97 (ingredients (mapcar #'(lambda (a) (cons a a)) type)) 98 (ingredient 99 (completing-read "Addition type: " ingredients nil t))) 100 ingredient)) 101 102 (defun coffee-url () 103 (require 'w3-forms) 104 (concat "coffee://" coffee-host "/" 105 (int-to-string coffee-pot-designator) 106 "?" (w3-form-encode-xwfu (coffee-additions)))) 107 108 109 (provide 'coffee) 110 111 ;; coffee.el ends here
载入中