diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..4d838fd --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "ace-jump-mode"] + path = ace-jump-mode + url = https://github.com/winterTTr/ace-jump-mode.git +[submodule "emacs-no-easy-keys"] + path = emacs-no-easy-keys + url = https://github.com/danamlund/emacs-no-easy-keys.git +[submodule "multiple-cursors.el"] + path = multiple-cursors.el + url = https://github.com/magnars/multiple-cursors.el.git diff --git a/ace-jump-mode b/ace-jump-mode new file mode 160000 index 0000000..07b7137 --- /dev/null +++ b/ace-jump-mode @@ -0,0 +1 @@ +Subproject commit 07b713792aec8cfb1bed7e1effaa9bf2b1cf3282 diff --git a/emacs-no-easy-keys b/emacs-no-easy-keys new file mode 160000 index 0000000..90f4435 --- /dev/null +++ b/emacs-no-easy-keys @@ -0,0 +1 @@ +Subproject commit 90f44351c28a0d9c8206f60f0bef02ae9c0c9733 diff --git a/multiple-cursors.el b/multiple-cursors.el new file mode 160000 index 0000000..a3e6ec7 --- /dev/null +++ b/multiple-cursors.el @@ -0,0 +1 @@ +Subproject commit a3e6ec7c93c376f35c9add3ff8d155bdf2e079a4 diff --git a/wordnik-synonym.el b/wordnik-synonym.el new file mode 100644 index 0000000..6ef7cd7 --- /dev/null +++ b/wordnik-synonym.el @@ -0,0 +1,47 @@ +(require 'json) +(require 'thingatpt) + +(setq wordnik-api-key "fa815fa92045b7fa23699014d0a01c081b3d9c3c761292bf3") + +(defun wordnik-get-syn-buffer-for-word (word) + (url-retrieve-synchronously (concat "http://api.wordnik.com//v4/word.json/" word "/relatedWords?relationshipTypes=synonym&limitPerRelationshipType=25&api_key=" wordnik-api-key))) + +(defun thesaurus-process-http-headers () + "In the buffer created by `url-retrieve-synchronously', +there are HTTP headers, and content. This fn removes the headers +from the buffer, parsing the Content-Length header to verify that +a substantive response was received. + +This implementation deletes each line until finding a blank line, +which in correctly-formatted HTTP messages signals the end of the +headers and the beginning of the message content. +" + (let ((clength -1)) + (while (/= (point) (line-end-position)) + (when (and (< clength 0) + (re-search-forward "^[Cc]ontent-[Ll]ength ?: *\\(.*\\)$" (line-end-position) t)) + (setq clength (string-to-number (match-string 1))) + (goto-char (line-beginning-position))) + (delete-region (point) (line-end-position)) + (delete-char 1)) + (delete-char 1) + clength)) + +(defun wn/synonym-list (word) + "Look up synonyms for (word) on wordnik and return them as an array of strings" + (let ((buf (wordnik-get-syn-buffer-for-word word))) + (if buf + (progn + (with-current-buffer buf + (goto-char (point-min)) + (thesaurus-process-http-headers) + (let ((json-object-type 'alist)) + (cdr (assoc 'words (elt (json-read-from-string (buffer-substring-no-properties (point) (line-end-position))) 0))))))))) + +(defun wn/synonym-at-point () + (interactive) + (let ((word (word-at-point))) + (message "Synonyms for %s: %S" word (wn/synonym-list word)))) + +(provide 'wordnik-synonym) +