;ELC   
;;; Compiled by nelhage@mit.edu on Wed Mar  7 14:36:37 2007
;;; from file /home/nelhage/.elisp/site/g-client/g-utils.el
;;; in Emacs version 23.0.0.2
;;; with all optimizations.
;;; Function definitions are lazy-loaded.

;;; This file uses dynamic docstrings, first added in Emacs 19.29.
(if (and (boundp 'emacs-version)
	 (< (aref emacs-version (1- (length emacs-version))) ?A)
	 (or (and (boundp 'epoch::version) epoch::version)
	     (string-lessp emacs-version "19.29")))
    (error "`g-utils.el' was compiled for Emacs 19.29 or later"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(byte-code "\300\301!\210\300\302!\210\300\303!\210\304\305!\207" [require cl backquote json proclaim (optimize (safety 0) (speed 3))] 2)
#@45 Directory where Google Client is installed.
(defvar g-directory (byte-code "\205 \301!\207" [load-file-name file-name-directory] 2) (#$ . 765))
#@43 Scratch buffer we do authentication work.
(defvar g-scratch-buffer " *g scratch*" (#$ . 918))
#@26 Name of CURL executable.
(custom-declare-variable 'g-curl-program '"curl" '(#$ . 1018) :type 'string :group 'g)
#@46 XSLT transform to convert Atom feed to HTML.
(custom-declare-variable 'g-atom-view-xsl '(expand-file-name "atom-view.xsl" g-directory) '(#$ . 1136) :type 'string :group 'g)
#@92 XSLT transform used to tidy up an entry before posting.
For now, this is blogger specific.
(custom-declare-variable 'g-atom-edit-filter '(expand-file-name "blogger-edit-post.xsl" g-directory) '(#$ . 1315) :type 'string :group 'g)
#@49 Common options to pass to all Curl invocations.
(custom-declare-variable 'g-curl-common-options '"--compressed --silent --location --location-trusted" '(#$ . 1551) :type 'string :group 'g)
#@80 Function that processes HTML.
Receives buffer containing HTML as its argument.
(custom-declare-variable 'g-html-handler ''browse-url-of-buffer '(#$ . 1746) :type '(choice (function-item browse-url-of-buffer) (function-item switch-to-buffer) (function :format "%t %v" :tag "Custom:")) :group 'g)
#@48 Function used to get URL from current context.
(custom-declare-variable 'g-url-under-point ''browse-url-url-at-point '(#$ . 2047) :type '(choice (function-item browse-url-url-at-point) (function-item w3-view-this-url) (function :format "%t %v" :tag "Custom:")) :group 'g)
#@17 XSLT Processor.
(custom-declare-variable 'g-xslt-program '"xsltproc" '(#$ . 2325) :type 'string :group 'g)
#@81 Cookie jar used for Google services.
Customize this to live on your local disk.
(custom-declare-variable 'g-cookie-jar '(expand-file-name "~/.g-cookie-jar") '(#$ . 2438) :type 'file :set '(lambda (sym val) (declare (special g-cookie-options)) (setq g-cookie-options (format "--cookie %s --cookie-jar %s" val val)) (set-default sym val)) :group 'g)
#@43 Options to pass for using our cookie jar.
(defvar g-cookie-options (byte-code "\301\302\211#\207" [g-cookie-jar format "--cookie %s --cookie-jar %s"] 4) (#$ . 2792))
#@37 Set to T to see Curl stderr output.
(custom-declare-variable 'g-curl-debug 'nil '(#$ . 2965) :type 'boolean :group 'g)
#@42 Set to T to see xsltproc  stderr output.
(custom-declare-variable 'g-xslt-debug 'nil '(#$ . 3090) :type 'boolean :group 'g)
#@38 Determines if we show stderr output.
(defalias 'g-curl-debug #[nil #@65 ("\2030\301\207\302\207" . [g-curl-debug " 2>/dev/null" ""])(#$ . 3293) nil 1 (#$ . 3220)])
(put 'g-curl-debug 'byte-optimizer 'byte-compile-inline-expand)
#@38 Determines if we show stderr output.
(defalias 'g-xslt-debug #[nil #@65 ("\2030\301\207\302\207" . [g-xslt-debug " 2>/dev/null" ""])(#$ . 3531) nil 1 (#$ . 3458)])
(put 'g-xslt-debug 'byte-optimizer 'byte-compile-inline-expand)
#@21 URL encode  string.
(defalias 'g-url-encode #[(str) #@246 ("\301\302\303#\207" . [str mapconcat #[(c) "\301U\2030\302\207\303Y\2030\304X\204,0\305Y\203 0\306X\204,0\307Y\20300\310X\20300\311!\207\312\313\"\226\207" [c 32 "+" 97 122 65 90 48 57 char-to-string format "%%%02x"] 3] ""])(#$ . 3755) nil 4 (#$ . 3696)])
(put 'g-url-encode 'byte-optimizer 'byte-compile-inline-expand)
#@51 Replace region by result of transforming via XSL.
(defalias 'g-xsl-transform-region #[(start end xsl) #@173 ("\305	\306\307\n\f\2030\310\2020\311$\312$\207" . [start end g-xslt-program xsl g-xslt-debug shell-command-on-region format "%s %s - %s" " 2>/dev/null" "" replace])(#$ . 4210) nil 8 (#$ . 4101)])
(put 'g-xsl-transform-region 'byte-optimizer 'byte-compile-inline-expand)
#@47 Alist of HTML character entities to unescape.
(defvar g-html-charent-alist '(("&lt;" . "<") ("&gt;" . ">") ("&quot;" . "\"") ("&apos;" . "'") ("&amp;" . "&")) (#$ . 4493))
#@25 Unescape HTML entities.
(defalias 'g-html-unescape-region #[(start end) #@218 ("\212\306	:\203.0	@\211@\nAb\210\307\f\n\310#\203&0\311!\210\2020*	A\211\2020+\306\207" . [g-html-charent-alist #1=#:--cl-var-- entry replacement entity start nil search-forward t replace-match end])(#$ . 4750) nil 5 (#$ . 4671)])
(put 'g-html-unescape-region 'byte-optimizer 'byte-compile-inline-expand)
#@23 Escape HTML entities.
(defalias 'g-html-escape-region #[(start end) #@218 ("\212\306	:\203.0	@\211A\n@b\210\307\f\n\310#\203&0\311!\210\2020*	A\211\2020+\306\207" . [g-html-charent-alist #1=#:--cl-var-- entry replacement entity start nil search-forward t replace-match end])(#$ . 5153) nil 5 (#$ . 5078)])
(put 'g-html-escape-region 'byte-optimizer 'byte-compile-inline-expand)
#@57 Return object.key from json object or nil if not found.
(defalias 'g-json-get #[(key object) #@40 ("\302	\"A\207" . [key object assoc])(#$ . 5578) nil 3 (#$ . 5479)])
(byte-code "\300\301\302\303#\210\304\305\306\"\207" [put g-json-get byte-optimizer byte-compile-inline-expand defalias g-json-aref aref] 4)
#@53 Evaluate forms in a  ready to use temporary buffer.
(defalias 'g-using-scratch '(macro . #[(&rest body) #@257 ("\301\302\303\304\305\306\307\310\301B\257EE\207" . [body progn (declare (special g-scratch-buffer)) let ((buffer (get-buffer-create g-scratch-buffer)) (buffer-undo-list t)) save-excursion (set-buffer buffer) (kill-all-local-variables) (erase-buffer)])(#$ . 5906) nil 10 (#$ . 5795)]))
#@36 Run command and return its output.
(defalias 'g-get-result #[(command) #@219 ("\304!\305\212\nq\210\306 \210\307 \210\310p\311#\210\312 +\207" . [g-scratch-buffer buffer-undo-list buffer command get-buffer-create t kill-all-local-variables erase-buffer shell-command replace buffer-string])(#$ . 6279) nil 4 (#$ . 6201)])
(put 'g-get-result 'byte-optimizer 'byte-compile-inline-expand)
#@69 Get command results and return json object read from result
string.
(defalias 'g-json-get-result #[(command) #@247 ("\304\305	!\306\212q\210\307 \210\310 \210\311p\312#\210\313 ,!\207" . [command g-scratch-buffer buffer-undo-list buffer json-read-from-string get-buffer-create t kill-all-local-variables erase-buffer shell-command replace buffer-string])(#$ . 6714) nil 5 (#$ . 6598)])
(put 'g-json-get-result 'byte-optimizer 'byte-compile-inline-expand)
#@171 Display result retrieved by command using specified style.
Typically, content is pulled using Curl , converted to HTML using style  and
  previewed via `g-html-handler'.
(defalias 'g-display-result #[(command style) #@398 ("\306!\307\212\nq\210\310 \210\311 \210\312p\"\210\f\203:0ed\f\313\314\315\20340\316\20250\317$\320$\210+p!+\207" . [g-scratch-buffer buffer-undo-list buffer command style xsl get-buffer-create t kill-all-local-variables erase-buffer shell-command shell-command-on-region format "%s %s - %s" " 2>/dev/null" "" replace end start g-xslt-program g-xslt-debug g-html-handler])(#$ . 7290) nil 8 (#$ . 7067)])
(put 'g-display-result 'byte-optimizer 'byte-compile-inline-expand)
#@118 Display XML string  using specified style.
XML string is transformed via style
  and previewed via `g-html-handler'.
(defalias 'g-display-xml-string #[(string style) #@377 ("\306!\307\212\nq\210\310 \210\311 \210c\210\f\20380ed\f\312\313\314\20320\315\20230\316$\317$\210+p!+\207" . [g-scratch-buffer buffer-undo-list buffer string style xsl get-buffer-create t kill-all-local-variables erase-buffer shell-command-on-region format "%s %s - %s" " 2>/dev/null" "" replace end start g-xslt-program g-xslt-debug g-html-handler])(#$ . 7966) nil 8 (#$ . 7793)])
(put 'g-display-xml-string 'byte-optimizer 'byte-compile-inline-expand)
#@98 HTTP headers are ended by a CRLF pair.
Note that in the Curl output, we see lf rather than crlf.
(defvar g-crlf-pair (byte-code "\300\301\302\211#\207" [format "%c%c" 10] 4) (#$ . 8451))
#@51 Parse HTTP headers in region and return an alist.
(defalias 'g-http-headers #[(start end) #@473 ("b\210\306	\n\307#\2030`\214\n}\210\310\211\211eb\210\311\312!\203;0\313\314!\210\313\315!\210`\313\314!\210\316\317\f`\"BB\320y\210m\204c0\321\317\322 \323 \"\324\"\211G\325U\203]0@\211A@)BB\320y\210\202;0,\207" . [start g-crlf-pair end fields pos headers search-forward no-error nil looking-at "HTTP/[0-9.]+" skip-syntax-forward "^ " " " "Status" buffer-substring-no-properties 1 split-string line-beginning-position line-end-position ": " 2 x])(#$ . 8741) nil 5 (#$ . 8644)])
(put 'g-http-headers 'byte-optimizer 'byte-compile-inline-expand)
#@33 Return body from HTTP response.
(defalias 'g-http-body #[(start end) #@136 ("b\210\303	\n\304#\2030\305`\n\"\207\306\207" . [start g-crlf-pair end search-forward no-error buffer-substring-no-properties ""])(#$ . 9392) nil 4 (#$ . 9316)])
(put 'g-http-body 'byte-optimizer 'byte-compile-inline-expand)
#@45 Return specified header from headers-alist.
(defalias 'g-http-header #[(name header-alist) #@63 ("\302	\"\205\f0\302	\"A\207" . [name header-alist assoc])(#$ . 9724) nil 3 (#$ . 9627)])
(byte-code "\300\301\302\303#\210\304\305!\207" [put g-http-header byte-optimizer byte-compile-inline-expand provide g-utils] 4)
