XGuru's Blog

技术,是一种态度。关注:高性能后端技术/服务器架构/C++/C/LAMP

   :: 首页 :: 联系 :: 聚合  :: 管理
  20 Posts :: 0 Stories :: 93 Comments :: 0 Trackbacks

公告





twitter / xoXGuru

feedsky
抓虾
google reader
鲜果
QQ邮箱
九点

常用链接

留言簿(12)

搜索

  •  

最新评论

阅读排行榜


                   Emacs是否真的能煮咖啡?        by XGuru









    坊间有传言曰:“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

    这个脚本看起来还是煞有其事的,文中提到"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

    1998年4月1号,愚人节!这个就让人产生了疑问。
    通过查wiki发现,原来互联网国际标准机构也是很有才的恶搞高手。

这里列举其中几个好玩的
    • 2001年,RFC 1149由一班挪威Linux使用者协会的成员实现了。他们传送了9个封包到约5公里外的地方,每个封包由不同的鸽子携带,并有一个ICMP应答要求封包(ping)。他们收到4个回应,封包流失率是55%,回应时间是3000至6000秒。[1]
    • RFC 1607 来自21世纪的观点 Vint Cerf 1994
    • RFC 3091 圆周率数字产生协定 . H. Kennedy 2001年
更多的可以看这里wiki

  
     这里可以大胆地作出推断,这个协议只是 IETF 开的一个善意的joke,而coffee.el的作者Eric Marsden也是一个幽默的程序员,于是就做了一个兼容RFC2324的脚本,他也没想过要真正的控制咖啡机,所以这整个事情都源于程序员的冷幽默。
                          
     然而远程控制咖啡机还是有可能的,这里有一个开源咖啡机;这里还有一个允许网络控制的咖啡机(据说还是兼容RFC2324的)。
     估计IETF应该做梦也没想到自己开的一个玩笑竟然还真的有人做出了实物。 国外的牛人们还真是闲得蛋疼阿。可见geek们还是极富幽默感的。
朋友们,你的心中已经有答案了么?你们想要一台这样的咖啡机不?







PS.在这里BS下CPPBLOG的编辑器,真的很烂啊,文章写到一半时点保存,竟然给发布了!

 Creative commons license

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


posted on 2010-07-27 21:15 XGuru 阅读(12785) 评论(5)  编辑 收藏 引用

Feedback

# re: [趣闻]Emacs是否真的能煮咖啡? 2010-07-27 22:13 besterChen
呵呵,很佩服LZ的考究能力~
当初我听说这个的时候,也很好奇,不过我也就跟 把光驱当做茶杯底座那样理解的,没去考究,毕竟它只是个编辑器……  回复  更多评论
  

# re: [趣闻]Emacs是否真的能煮咖啡? 2012-02-25 22:07 co
真的佩服LZ的探究能力。很期待一个这样的咖啡机啊  回复  更多评论
  

# re: [趣闻]Emacs是否真的能煮咖啡? 2014-02-11 21:10 anopos
这个编辑器真的很好用么?  回复  更多评论
  

# re: [趣闻]Emacs是否真的能煮咖啡? 2014-10-03 01:34 青山
电子专业的做个智能咖啡壶没问题。。。我是这样理解的,结果……  回复  更多评论
  

# re: [趣闻]Emacs是否真的能煮咖啡? 2016-06-30 15:26 Holly
U R great!  回复  更多评论
  


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理