mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
Rename doom-modeline-version to doom-modeline-env-version.
This commit is contained in:
parent
11481cc647
commit
81635fdf36
4 changed files with 40 additions and 39 deletions
|
@ -179,7 +179,7 @@ Strongly recommend to use
|
|||
(setq doom-modeline-github-interval (* 30 60))
|
||||
|
||||
;; Whether display environment version or not.
|
||||
(setq doom-modeline-version t)
|
||||
(setq doom-modeline-env-version t)
|
||||
|
||||
;; Whether display mu4e notifications or not. Requires `mu4e-alert' package.
|
||||
(setq doom-modeline-mu4e t)
|
||||
|
|
|
@ -122,8 +122,9 @@ The icons may not be showed correctly in terminal and on Windows.")
|
|||
(defvar doom-modeline-github-interval (* 30 60)
|
||||
"The interval of checking github.")
|
||||
|
||||
(defvar doom-modeline-version t
|
||||
(defvar doom-modeline-env-version t
|
||||
"Whether display environment version or not.")
|
||||
(define-obsolete-variable-alias 'doom-modeline-version 'doom-modeline-env-version "1.7.4")
|
||||
|
||||
(defvar doom-modeline-mu4e t
|
||||
"Whether display mu4e notifications or not. Requires `mu4e-alert' package.")
|
||||
|
|
|
@ -31,32 +31,32 @@
|
|||
(require 'doom-modeline-core)
|
||||
|
||||
;; Show version string for multi-version managers like rvm, rbenv, pyenv, etc.
|
||||
(defvar-local doom-modeline-env-version nil
|
||||
(defvar-local doom-modeline-env--version nil
|
||||
"The version to display with major-mode in mode-line.
|
||||
Example: \"2.6.0\"")
|
||||
(defvar-local doom-modeline-env-command nil
|
||||
(defvar-local doom-modeline-env--command nil
|
||||
"A program that we're looking to extract version information from.
|
||||
Example: \"ruby\"")
|
||||
(defvar-local doom-modeline-env-command-args nil
|
||||
"A list of arguments to pass to `doom-modeline-env-command` to extract the version from.
|
||||
(defvar-local doom-modeline-env--command-args nil
|
||||
"A list of arguments to pass to `doom-modeline-env--command` to extract the version from.
|
||||
Example: '(\"--version\") ")
|
||||
(defvar-local doom-modeline-env-parser nil
|
||||
(defvar-local doom-modeline-env--parser nil
|
||||
"A function that returns version number from a programs --version (or similar) command.
|
||||
Example: 'doom-modeline-env--ruby")
|
||||
|
||||
(defun doom-modeline-update-env ()
|
||||
"Update environment info on mode-line."
|
||||
(when (and doom-modeline-version
|
||||
doom-modeline-env-command
|
||||
(executable-find doom-modeline-env-command)
|
||||
doom-modeline-env-command-args
|
||||
doom-modeline-env-parser)
|
||||
(when (and doom-modeline-env-version
|
||||
doom-modeline-env--command
|
||||
(executable-find doom-modeline-env--command)
|
||||
doom-modeline-env--command-args
|
||||
doom-modeline-env--parser)
|
||||
(let ((default-directory (doom-modeline-project-root)))
|
||||
(doom-modeline-env--get doom-modeline-env-command
|
||||
doom-modeline-env-command-args
|
||||
(doom-modeline-env--get doom-modeline-env--command
|
||||
doom-modeline-env--command-args
|
||||
(lambda (prog-version)
|
||||
(setq doom-modeline-env-version
|
||||
(funcall doom-modeline-env-parser prog-version)))))))
|
||||
(setq doom-modeline-env--version
|
||||
(funcall doom-modeline-env--parser prog-version)))))))
|
||||
|
||||
(add-hook 'find-file-hook #'doom-modeline-update-env)
|
||||
(with-no-warnings
|
||||
|
@ -148,40 +148,40 @@ Example:
|
|||
(add-hook 'python-mode-hook
|
||||
(lambda ()
|
||||
(cond ((and (fboundp 'pipenv-project-p) (pipenv-project-p) (executable-find "pipenv"))
|
||||
(setq doom-modeline-env-parser 'doom-modeline-env--python)
|
||||
(setq doom-modeline-env-command "pipenv")
|
||||
(setq doom-modeline-env-command-args '("run" "python" "--version")))
|
||||
(setq doom-modeline-env--parser 'doom-modeline-env--python)
|
||||
(setq doom-modeline-env--command "pipenv")
|
||||
(setq doom-modeline-env--command-args '("run" "python" "--version")))
|
||||
((and doom-modeline-python-executable
|
||||
(executable-find doom-modeline-python-executable))
|
||||
(setq doom-modeline-env-parser 'doom-modeline-env--python)
|
||||
(setq doom-modeline-env-command doom-modeline-python-executable)
|
||||
(setq doom-modeline-env-command-args '("--version"))))))
|
||||
(setq doom-modeline-env--parser 'doom-modeline-env--python)
|
||||
(setq doom-modeline-env--command doom-modeline-python-executable)
|
||||
(setq doom-modeline-env--command-args '("--version"))))))
|
||||
(add-hook 'ruby-mode-hook
|
||||
(lambda ()
|
||||
(setq doom-modeline-env-command "ruby")
|
||||
(setq doom-modeline-env-command-args '("--version"))
|
||||
(setq doom-modeline-env-parser 'doom-modeline-env--ruby)))
|
||||
(setq doom-modeline-env--command "ruby")
|
||||
(setq doom-modeline-env--command-args '("--version"))
|
||||
(setq doom-modeline-env--parser 'doom-modeline-env--ruby)))
|
||||
(add-hook 'perl-mode-hook
|
||||
(lambda ()
|
||||
(setq doom-modeline-env-command "perl")
|
||||
(setq doom-modeline-env-command-args '("--version"))
|
||||
(setq doom-modeline-env-parser 'doom-modeline-env--perl)))
|
||||
(setq doom-modeline-env--command "perl")
|
||||
(setq doom-modeline-env--command-args '("--version"))
|
||||
(setq doom-modeline-env--parser 'doom-modeline-env--perl)))
|
||||
(add-hook 'go-mode-hook
|
||||
(lambda ()
|
||||
(setq doom-modeline-env-command "go")
|
||||
(setq doom-modeline-env-command-args '("version"))
|
||||
(setq doom-modeline-env-parser 'doom-modeline-env--go)))
|
||||
(setq doom-modeline-env--command "go")
|
||||
(setq doom-modeline-env--command-args '("version"))
|
||||
(setq doom-modeline-env--parser 'doom-modeline-env--go)))
|
||||
|
||||
(add-hook 'elixir-mode-hook
|
||||
(lambda ()
|
||||
(setq doom-modeline-env-command "iex")
|
||||
(setq doom-modeline-env-command-args '("--version"))
|
||||
(setq doom-modeline-env-parser 'doom-modeline-env--elixir)))
|
||||
(setq doom-modeline-env--command "iex")
|
||||
(setq doom-modeline-env--command-args '("--version"))
|
||||
(setq doom-modeline-env--parser 'doom-modeline-env--elixir)))
|
||||
(add-hook 'rust-mode-hook
|
||||
(lambda ()
|
||||
(setq doom-modeline-env-command "rustc")
|
||||
(setq doom-modeline-env-command-args '("--version"))
|
||||
(setq doom-modeline-env-parser 'doom-modeline-env--rustc)))
|
||||
(setq doom-modeline-env--command "rustc")
|
||||
(setq doom-modeline-env--command-args '("--version"))
|
||||
(setq doom-modeline-env--parser 'doom-modeline-env--rustc)))
|
||||
|
||||
(provide 'doom-modeline-env)
|
||||
|
||||
|
|
|
@ -392,8 +392,8 @@ mouse-2: Show help for major mode\n\
|
|||
mouse-3: Toggle minor modes"
|
||||
mouse-face mode-line-highlight
|
||||
local-map ,mode-line-major-mode-keymap))
|
||||
(when (and doom-modeline-version doom-modeline-env-version)
|
||||
(format " %s" doom-modeline-env-version))
|
||||
(when (and doom-modeline-env-version doom-modeline-env--version)
|
||||
(format " %s" doom-modeline-env--version))
|
||||
(and (boundp 'text-scale-mode-amount)
|
||||
(/= text-scale-mode-amount 0)
|
||||
(format
|
||||
|
|
Loading…
Reference in a new issue