Add customization option

This commit is contained in:
Tom Willemse 2013-11-06 23:22:05 +01:00
parent 1b60939449
commit 42d776690b
2 changed files with 15 additions and 4 deletions

3
NEWS
View file

@ -1,5 +1,6 @@
# -*- mode: org; -*- # -*- mode: org; -*-
* v0.2.0 * v0.2.0
- Add =hypo-delete-last=, which deletes the last posted item of the - Add =hypo-delete-last=, which deletes the last posted item of the
current session. current session.
- Add customization group and allow specification of the URL where
hypo runs.

16
hypo.el
View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org> ;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: tools ;; Keywords: tools
;; Version: 0.1.0 ;; Version: 0.1.0.3
;; This program is free software; you can redistribute it and/or modify ;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by ;; it under the terms of the GNU General Public License as published by
@ -31,6 +31,16 @@
(autoload 'beginning-of-sexp "thingatpt") (autoload 'beginning-of-sexp "thingatpt")
(autoload 'end-of-sexp "thingatpt") (autoload 'end-of-sexp "thingatpt")
(defgroup hypo nil
"Customization options for `hypo'."
:group 'convenience)
(defcustom hypo-instance-url "https://ryuslash.org/hypo"
"URL of the hypo instance to communicate with."
:group 'hypo
:risky t
:type 'string)
(defvar hypo--last-post nil (defvar hypo--last-post nil
"The hash of the last snippet sent to hypo. "The hash of the last snippet sent to hypo.
@ -64,7 +74,7 @@ STATUS is ignored."
(read-string "Filename: " (buffer-name)))))) (read-string "Filename: " (buffer-name))))))
(let ((url-request-data (buffer-substring-no-properties start end)) (let ((url-request-data (buffer-substring-no-properties start end))
(url-request-method "PUT")) (url-request-method "PUT"))
(url-retrieve (concat "https://ryuslash.org/hypo/" filename) (url-retrieve (format "%s/%s" hypo-instance-url filename)
#'hypo--collect-and-kill))) #'hypo--collect-and-kill)))
;;;###autoload ;;;###autoload
@ -108,7 +118,7 @@ STATUS is ignored."
(interactive) (interactive)
(unless hypo--last-post (error "Nothing posted this session")) (unless hypo--last-post (error "Nothing posted this session"))
(let ((url-request-method "DELETE")) (let ((url-request-method "DELETE"))
(url-retrieve (concat "https://ryuslash.org/hypo/" hypo--last-post) (url-retrieve (format "%s/%s" hypo-instance-url hypo--last-post)
#'ignore) #'ignore)
(setq hypo--last-post nil))) (setq hypo--last-post nil)))