From f084476603f0236100f57e442421c30cf0c86c1b Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Sun, 13 Jan 2019 21:53:51 +0800 Subject: [PATCH] Reformat and silence warnings. --- doom-version-parser.el | 45 ++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/doom-version-parser.el b/doom-version-parser.el index 219fdbb..c9ca610 100644 --- a/doom-version-parser.el +++ b/doom-version-parser.el @@ -1,6 +1,6 @@ ;;; doom-version-parser.el --- A version parser for doom-modeline -*- lexical-binding: t -*- -;; Copyright (C) 2019 Justin Barclay +;; Copyright (C) 2019 Justin Barclay, Vincent Zhang ;; Version: 1.4.5 ;; @@ -19,20 +19,29 @@ ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth ;; Floor, Boston, MA 02110-1301, USA. ;; +;;; Commentary: +;; +;; Parse programming environment version. +;; + +;;; Code: (require 'subr-x) (defun doom-version-parser--ruby (line) + "Parse Ruby version from LINE." (car (split-string (cadr (split-string line)) "p"))) (defun doom-version-parser--elixir (line) + "Parse Elixir version from LINE." (cadr (split-string line))) (defun doom-version-parser--rustc (line) + "Parse Rust version from LINE." (car (split-string (cadr @@ -40,6 +49,7 @@ "-"))) (defun doom-version-parser--go (line) + "Parse Go version from LINE." (cadr (split-string (cadr @@ -49,6 +59,7 @@ "go"))) (defun doom-version-parser--perl (line) + "Parse Perl version from LINE." (cadr (split-string (car @@ -59,26 +70,34 @@ "v"))) (defun doom-version-parser--python (line) + "Parse Python version from LINE." (cadr (split-string line))) (defun doom-version-parser--get (prog args callback) - "Starts a sub process using prog and applies the args to the sub process. - Once it recieves information from STDOUT, it closes off the subprocess and - passes on the information into the callback. - Ex: (doom-version-parser--get \"ruby\" '(\"version\") (lambda (line) (message (doom-modeline-parser--ruby)))" + "Start a sub process using PROG and apply the ARGS to the sub process. +Once it recieves information from STDOUT, it closes off the subprocess and +passes on the information into the CALLBACK. + Example: + (doom-version-parser--get + \"ruby\" + '(\"version\") + (lambda (line) + (message (doom-modeline-parser--ruby line)))" (let ((proc (apply 'start-process - (append ;; Flaten process-args into a single list so we can handle variadic length args + (append ;; Flaten process-args into a single list so we can handle variadic length args (list "doom-modeline-prog" "doom-modeline-prog" prog) args))) (parser callback)) - (set-process-filter proc (lambda (proc1 line) - (defvar old-buffer-query-functions kill-buffer-query-functions) ;; Store old query function - (setq kill-buffer-query-functions nil) ;; No need to query user when we kill this buffer and process - (kill-process proc1) ;; Clean up after ourselves - (kill-buffer "doom-modeline-prog") - (setq kill-buffer-query-functions old-buffer-query-functions) ;; let's restore everthing - (funcall parser line))) + (set-process-filter + proc + (lambda (proc1 line) + (defvar old-buffer-query-functions kill-buffer-query-functions) ;; Store old query function + (setq kill-buffer-query-functions nil) ;; No need to query user when we kill this buffer and process + (kill-process proc1) ;; Clean up after ourselves + (kill-buffer "doom-modeline-prog") + (setq kill-buffer-query-functions old-buffer-query-functions) ;; let's restore everthing + (funcall parser line))) nil)) (provide 'doom-version-parser)