summaryrefslogtreecommitdiff
path: root/examples/010-current-buffer.el
blob: 0233abf0becf99c3764320d2e1c3bb079b785765 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
;;; current-buffer.el --- Show the current Emacs buffer  -*- lexical-binding: t; -*-
;; Copyright (C) 2014-2020  Free Software Foundation, Inc.

(if t (require 'htmlize))               ;Don't require during compilation.

(ws-start
 (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)