Skip to content

Instantly share code, notes, and snippets.

@emallson
Last active August 29, 2015 14:25
Show Gist options
  • Save emallson/7f7586da28b99f1e7d99 to your computer and use it in GitHub Desktop.
Save emallson/7f7586da28b99f1e7d99 to your computer and use it in GitHub Desktop.
Grab commit messages from whatthecommit.com
;;; -*- lexical-binding: t; -*-
;;; auto-commit-msg.el --- Fetch and insert commit messages.
;;; Commentary:
;; "Generates" commit messages automatically by making a request to `whatthecommit.com'.
;;; Code:
; note: (el-get-install 'request) or (package-install 'request)
(require 'request)
(require 'cl-lib)
(defun auto-commit-msg-fetch (success error &optional timeout)
(request
"http://whatthecommit.com/index.txt"
:parser #'buffer-string
:success (cl-function
(lambda (&key data &allow-other-keys)
(funcall success data)))
:error error
:timeout (or timeout 2)))
(defun auto-commit-msg (pos)
"Insert automatic commit message at point position `POS'."
(interactive "d")
(auto-commit-msg-fetch
(lambda (msg)
(save-excursion
(goto-char pos)
(insert msg)))
#'princ))
(provide 'auto-commit-msg)
;;; auto-commit-msg.el ends here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment