mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-24 03:00:10 +00:00
Reformat and silence warnings.
This commit is contained in:
parent
539e361d9a
commit
f084476603
1 changed files with 32 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
||||||
;;; doom-version-parser.el --- A version parser for doom-modeline -*- lexical-binding: t -*-
|
;;; 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
|
;; Version: 1.4.5
|
||||||
;;
|
;;
|
||||||
|
@ -19,20 +19,29 @@
|
||||||
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||||
;; Floor, Boston, MA 02110-1301, USA.
|
;; Floor, Boston, MA 02110-1301, USA.
|
||||||
;;
|
;;
|
||||||
|
;;; Commentary:
|
||||||
|
;;
|
||||||
|
;; Parse programming environment version.
|
||||||
|
;;
|
||||||
|
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
(require 'subr-x)
|
(require 'subr-x)
|
||||||
|
|
||||||
(defun doom-version-parser--ruby (line)
|
(defun doom-version-parser--ruby (line)
|
||||||
|
"Parse Ruby version from LINE."
|
||||||
(car (split-string
|
(car (split-string
|
||||||
(cadr
|
(cadr
|
||||||
(split-string line))
|
(split-string line))
|
||||||
"p")))
|
"p")))
|
||||||
|
|
||||||
(defun doom-version-parser--elixir (line)
|
(defun doom-version-parser--elixir (line)
|
||||||
|
"Parse Elixir version from LINE."
|
||||||
(cadr
|
(cadr
|
||||||
(split-string line)))
|
(split-string line)))
|
||||||
|
|
||||||
(defun doom-version-parser--rustc (line)
|
(defun doom-version-parser--rustc (line)
|
||||||
|
"Parse Rust version from LINE."
|
||||||
(car
|
(car
|
||||||
(split-string
|
(split-string
|
||||||
(cadr
|
(cadr
|
||||||
|
@ -40,6 +49,7 @@
|
||||||
"-")))
|
"-")))
|
||||||
|
|
||||||
(defun doom-version-parser--go (line)
|
(defun doom-version-parser--go (line)
|
||||||
|
"Parse Go version from LINE."
|
||||||
(cadr
|
(cadr
|
||||||
(split-string
|
(split-string
|
||||||
(cadr
|
(cadr
|
||||||
|
@ -49,6 +59,7 @@
|
||||||
"go")))
|
"go")))
|
||||||
|
|
||||||
(defun doom-version-parser--perl (line)
|
(defun doom-version-parser--perl (line)
|
||||||
|
"Parse Perl version from LINE."
|
||||||
(cadr
|
(cadr
|
||||||
(split-string
|
(split-string
|
||||||
(car
|
(car
|
||||||
|
@ -59,20 +70,28 @@
|
||||||
"v")))
|
"v")))
|
||||||
|
|
||||||
(defun doom-version-parser--python (line)
|
(defun doom-version-parser--python (line)
|
||||||
|
"Parse Python version from LINE."
|
||||||
(cadr
|
(cadr
|
||||||
(split-string line)))
|
(split-string line)))
|
||||||
|
|
||||||
(defun doom-version-parser--get (prog args callback)
|
(defun doom-version-parser--get (prog args callback)
|
||||||
"Starts a sub process using prog and applies the args to the sub process.
|
"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
|
Once it recieves information from STDOUT, it closes off the subprocess and
|
||||||
passes on the information into the callback.
|
passes on the information into the CALLBACK.
|
||||||
Ex: (doom-version-parser--get \"ruby\" '(\"version\") (lambda (line) (message (doom-modeline-parser--ruby)))"
|
Example:
|
||||||
|
(doom-version-parser--get
|
||||||
|
\"ruby\"
|
||||||
|
'(\"version\")
|
||||||
|
(lambda (line)
|
||||||
|
(message (doom-modeline-parser--ruby line)))"
|
||||||
(let ((proc (apply 'start-process
|
(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)
|
(list "doom-modeline-prog" "doom-modeline-prog" prog)
|
||||||
args)))
|
args)))
|
||||||
(parser callback))
|
(parser callback))
|
||||||
(set-process-filter proc (lambda (proc1 line)
|
(set-process-filter
|
||||||
|
proc
|
||||||
|
(lambda (proc1 line)
|
||||||
(defvar old-buffer-query-functions kill-buffer-query-functions) ;; Store old query function
|
(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
|
(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-process proc1) ;; Clean up after ourselves
|
||||||
|
|
Loading…
Reference in a new issue