![]() |
坊間有傳言曰:“emacs無所不能,甚至能夠用來煮咖啡!” 煮咖啡何解?勾起了我的考究欲望。 上網搜索之,得出幾種初步結論如下: 1.這只是一種好玩的說法,只是用來形容emacs功能無所不包而已。 2.Java的標志就一杯咖啡,用來形象的表示寫代碼 ![]() 3.emacs的確具有煮咖啡的功能,有腳本能夠控制自動咖啡機運行。 |
覺得第一種說法比較符合邏輯;第二種說法感覺有點唐突,畢竟Emacs是Richard Stallman(GNU創始人)所寫,而Java是Bill Joy(vi作者)等人完成的,這兩派都差點上升到宗教沖突了,這種解釋有點差強人意;第三種的如果是真的話就會變得很有趣。
于是就開始了探究,首先追本溯源,找到這段腳本代碼的源頭。發現已經地址已經失效,終于在在debian的一個軟件包里找到了副本。這是emacs常用腳本的一個打包。
代碼如下
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
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
這個腳本看起來還是煞有其事的,文中提到"Submit a BREW request to an RFC2324-compliant coffee device"
能夠向與RFC2324協議兼容的咖啡設備提交BREW請求 ,即兼容Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0)協議。超文本咖啡壺協議,光看這名字就夠喜慶了,但這份協議寫得很規范,看不出一絲破綻。有細心的朋友shrek.wang提醒了我,注意看日期:
Network Working Group L. Masinter
Request for Comments: 2324 1 April 1998
Request for Comments: 2324 1 April 1998
1998年4月1號,愚人節!這個就讓人產生了疑問。
通過查wiki發現,原來互聯網國際標準機構也是很有才的惡搞高手。
這里列舉其中幾個好玩的
這里可以大膽地作出推斷,這個協議只是 IETF 開的一個善意的joke,而coffee.el的作者Eric Marsden也是一個幽默的程序員,于是就做了一個兼容RFC2324的腳本,他也沒想過要真正的控制咖啡機,所以這整個事情都源于程序員的冷幽默。

然而遠程控制咖啡機還是有可能的,這里有一個開源咖啡機;這里還有一個允許網絡控制的咖啡機(據說還是兼容RFC2324的)。
估計IETF應該做夢也沒想到自己開的一個玩笑竟然還真的有人做出了實物。 國外的牛人們還真是閑得蛋疼阿。可見geek們還是極富幽默感的。
朋友們,你的心中已經有答案了么?你們想要一臺這樣的咖啡機不?
PS.在這里BS下CPPBLOG的編輯器,真的很爛啊,文章寫到一半時點保存,竟然給發布了!

by XGuru
is licensed under a Creative
Commons 署名-非商業性使用-相同方式共享 2.5 中國大陸 License.