diff options
-rw-r--r-- | eia.el | 50 |
1 files changed, 50 insertions, 0 deletions
@@ -0,0 +1,50 @@ +;;; eia.el --- Emacs interface for the Internet Archive CLI -*- lexical-binding: t; -*- + +;; Copyright (C) 2023 Grant Shangreaux + +;; Author: <shoshin@cicadas.surf> +;; Keywords: unix + +;; 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 +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program 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 this program. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Requires the Internet Archive's CLI program in your path. +;; https://archive.org/developers/internetarchive/cli.html + +;;; Code: + +(defun eia-command (command &rest args) + "Execute COMMAND asynchronusly; display output." + (eia-start-process command args)) + +(defun eia-start-process (command args) + (with-current-buffer "*EIA*" (erase-buffer)) + (let ((process (apply #'start-process "eia-process" "*EIA*" "ia" command args))) + (set-process-sentinel process #'eia-process-sentinel))) + +(defun eia-process-sentinel (process event) + "Default sentinel used by `magit-start-process'." + (when (memq (process-status process) '(exit signal)) + (setq event (substring event 0 -1)) + (when (string-match "^finished" event) + (message (concat (capitalize (process-name process)) " finished"))) + (eia-process-buffer))) + +(defun eia-process-buffer () + (interactive) + (display-buffer "*EIA*")) + +(provide 'eia) +;;; eia.el ends here |