From 81635fdf3632236f7a4aa99b686a336e34913427 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Mon, 18 Feb 2019 18:57:16 +0800 Subject: [PATCH] Rename doom-modeline-version to doom-modeline-env-version. --- README.md | 2 +- doom-modeline-core.el | 3 +- doom-modeline-env.el | 70 +++++++++++++++++++-------------------- doom-modeline-segments.el | 4 +-- 4 files changed, 40 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 8dabf48..3e3a3c1 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/doom-modeline-core.el b/doom-modeline-core.el index 8712984..62afb10 100644 --- a/doom-modeline-core.el +++ b/doom-modeline-core.el @@ -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.") diff --git a/doom-modeline-env.el b/doom-modeline-env.el index 86f8b61..468998e 100644 --- a/doom-modeline-env.el +++ b/doom-modeline-env.el @@ -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) diff --git a/doom-modeline-segments.el b/doom-modeline-segments.el index eaff014..faa54c3 100644 --- a/doom-modeline-segments.el +++ b/doom-modeline-segments.el @@ -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