Boop boop: new project
I'm not entirely sure what this project is about, it's a loose Zimbatm's h emacs adaptation. To be 100% honest, it's mostly an excuse to dig a bit deeper into emacs elisp. Currently, we have a very bare test file able to parse a HTTP response code status and a JSON HTTP body. What a time to be alive!
This commit is contained in:
commit
69028afabf
|
@ -0,0 +1,85 @@
|
|||
;;; h.el --- Zimbatm's h tool for emacs.
|
||||
|
||||
;; Author: Félix Baylac Jacqué <felix@alternativebit.fr>
|
||||
;; Created: 25 October 2020
|
||||
;; Version: 0.1
|
||||
;; Package-Requires: ((dash "2.8.0") (s "1.9.0") (cl-lib "0.5"))
|
||||
;;; Commentary:
|
||||
|
||||
;; Please see README.md for documentation, or read it online at
|
||||
;; https://github.com/Wilfred/ag.el/#agel
|
||||
|
||||
;;; License:
|
||||
|
||||
;; This file is not part of GNU Emacs.
|
||||
;; However, it is distributed under the same license.
|
||||
|
||||
;; GNU Emacs is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation; either version 3, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'json)
|
||||
(require 'magit)
|
||||
(require 'url)
|
||||
|
||||
(defgroup h-essentials nil
|
||||
"Options that every h user should briefly thing about"
|
||||
:group 'tools)
|
||||
|
||||
(defcustom h-code-root nil
|
||||
"Root directory where your git repositories will be stored."
|
||||
:type '(directory)
|
||||
:group 'h-essentials
|
||||
)
|
||||
|
||||
(setq magit-repository-directories
|
||||
'(h-root-directory . 3)
|
||||
)
|
||||
|
||||
(goto-char (point-min))
|
||||
|
||||
(defun h--extract-http-status-from-header ()
|
||||
"Private function, it'll eat your kittens.
|
||||
|
||||
RESPONSE-BUFFER: url-retrieve response buffer."
|
||||
(goto-char (point-min))
|
||||
(search-forward-regexp "^status: ")
|
||||
(let* ((current-point (point))
|
||||
(move-to-beginning (goto-char (point-min)))
|
||||
(look-for-status (search-forward-regexp "^status: "))
|
||||
(http-status (buffer-substring (point) (point-at-eol)))
|
||||
(reset-previous-ponit (goto-char current-point)))
|
||||
http-status))
|
||||
|
||||
(url-retrieve
|
||||
"https://api.github.com/repos/zimbatm/h"
|
||||
(lambda (status)
|
||||
(split-window-below)
|
||||
(display-buffer (current-buffer))
|
||||
(message (h--extract-http-status-from-header))
|
||||
(delete-region (point-min) (search-forward "\n\n"))
|
||||
(let ((json-object-type 'plist)
|
||||
(json-key-type 'symbol)
|
||||
(json-array-type 'vector))
|
||||
(let ((result (json-read)))
|
||||
result
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;; repo url path owner
|
||||
|
||||
;;; h.el ends here
|
Loading…
Reference in New Issue