Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
(require 'request) ;;
(defvar ginger-rephrase-end-point
(defun ginger-rephrase (&optional $text $beg $end)
(lexical-let* (($text
(cond ($text $text)
((and $beg $end)
(buffer-substring-no-properties $beg $end))
(region-beginning) (region-end)))
(t (error (message "Require region or argument")))))
(deactivate-mark t)
:params `((s . ,$text)
(callback . "jQuery172018291063443757594_1383792045462")
(_ . "1383792068397"))
:parser 'buffer-string
(lambda (&key data &allow-other-keys)
(cond (data
(with-current-buffer (get-buffer-create "*rephrase*")
(pop-to-buffer (current-buffer))
(goto-char (point-min))
(let (($p 0))
(while (setq $p (string-match
data (1+ $p)))
(setq $res (cons (match-string-no-properties 1 data)
(propertize "\n---------------------------------\n"
'face 'font-lock-constant-face)
(insert (concat
"Original: " 'face 'font-lock-preprocessor-face)
$text 'face 'font-lock-function-name-face)
(if $res
(insert (mapconcat 'identity $res "\n"))
(insert "not found"))
(re-search-backward "Original")
(next-line 1)))
(t (error (message "Return no rephrase candidate")))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment