emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 84/119: more examples


From: Eric Schulte
Subject: [elpa] 84/119: more examples
Date: Mon, 10 Mar 2014 16:57:46 +0000

eschulte pushed a commit to branch master
in repository elpa.

commit 33ac1643ca17ffa9ff198eae510b3af0c08849dc
Author: Eric Schulte <address@hidden>
Date:   Wed Jan 8 13:01:59 2014 -0700

    more examples
---
 NOTES                         |   21 +++++++++++++--------
 examples/10-current-buffer.el |   14 ++++++++++++++
 examples/11-org-agenda.el     |   17 +++++++++++++++++
 examples/12-search-bbdb.el    |   22 ++++++++++++++++++++++
 4 files changed, 66 insertions(+), 8 deletions(-)

diff --git a/NOTES b/NOTES
index 9c6e3a2..a4413f3 100644
--- a/NOTES
+++ b/NOTES
@@ -1,21 +1,22 @@
                                                            -*- org -*-
 
 * Notes
-* Tasks [10/25]
-** TODO web sockets
+* Tasks [14/24]
+** DONE web sockets
 - http://en.wikipedia.org/wiki/WebSocket
 - http://tools.ietf.org/html/rfc6455
 
-** more examples [0/4]
-*** TODO Org-mode agenda
+** more examples [3/3]
+*** DONE Org-mode agenda
 Already exists as part of org-ehtml.
+file:examples/11-org-agenda.el
 
-*** TODO display the current buffer
+*** DONE display the current buffer
 Idea stolen from elnode.
+file:examples/10-current-buffer.el
 
-*** TODO browse the BBDB
-*** TODO browse available ELPA packages
-Also took this idea from elnode.
+*** DONE browse the BBDB
+file:examples/12-search-bbdb.el
 
 ** DONE handle large files
 When large files arrive quickly, the filter functions are called while
@@ -162,3 +163,7 @@ low priority -- just 
[[*running%20behind%20an%20https%20proxy][run behind an htt
 This will be a pain, and will require expanding [[info:emacs-gnutls]] to
 add support for starting server processes, currently only client
 processes are supported.
+* Bugs [0/1]
+** TODO Sometimes servers don't stop cleanly
+- specifically servers with active client process
+- maybe also implement a =ws-stop-all= function
diff --git a/examples/10-current-buffer.el b/examples/10-current-buffer.el
new file mode 100644
index 0000000..73b75da
--- /dev/null
+++ b/examples/10-current-buffer.el
@@ -0,0 +1,14 @@
+;;; current-buffer.el --- Show the current Emacs buffer
+(require 'htmlize)
+
+(ws-start
+ '(((lambda (_) t) .
+    (lambda (request)
+      (with-slots (process headers) request
+        (ws-response-header process 200
+          '("Content-type" . "text/html; charset=utf-8"))
+        (process-send-string process
+          (let ((html-buffer (htmlize-buffer)))
+            (prog1 (with-current-buffer html-buffer (buffer-string))
+              (kill-buffer html-buffer))))))))
+ 9010)
diff --git a/examples/11-org-agenda.el b/examples/11-org-agenda.el
new file mode 100644
index 0000000..578f688
--- /dev/null
+++ b/examples/11-org-agenda.el
@@ -0,0 +1,17 @@
+;;; org-agenda.el --- display the Org-mode agenda
+(require 'htmlize)
+
+(ws-start
+ '(((lambda (_) t) .
+    (lambda (request)
+      (with-slots (process headers) request
+        (ws-response-header process 200
+          '("Content-type" . "text/html; charset=utf-8"))
+        (org-agenda nil "a")
+        (process-send-string process
+          (save-window-excursion
+            (let ((html-buffer (htmlize-buffer)))
+              (prog1 (with-current-buffer html-buffer (buffer-string))
+                (kill-buffer html-buffer)
+                (org-agenda-quit)))))))))
+ 9011)
diff --git a/examples/12-search-bbdb.el b/examples/12-search-bbdb.el
new file mode 100644
index 0000000..2c1a49c
--- /dev/null
+++ b/examples/12-search-bbdb.el
@@ -0,0 +1,22 @@
+;;; search-bbdb.el --- search the Big Brother Data Base for a supplied name
+(ws-start
+ '(((lambda (_) t) .
+    (lambda (request)
+      (with-slots (process headers) request
+        (let ((name (cdr (assoc "name" headers))))
+          (unless name
+            (ws-error process "Must specify a name to search."))
+          (save-excursion
+            (unless (set-buffer (get-buffer "*BBDB*"))
+              (ws-error process "no *BBDB* buffer found"))
+            (bbdb-search-name name)
+            (if (equal (point-min) (point-max))
+                (progn
+                  (ws-response-header process 404
+                    '("Content-type" . "text/plain"))
+                  (process-send-string process
+                    "no matches found"))
+              (ws-response-header process 200
+                '("Content-type" . "text/plain"))
+              (process-send-string process (buffer-string)))))))))
+ 9012)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]