lang/python: update modeline on version change

This commit is contained in:
Henrik Lissner 2018-07-31 23:21:13 +02:00
parent 991199ee78
commit 9cf5907c48
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -56,13 +56,16 @@ first to return non-nil will have its result appended to the python-mode
;; Python version in modeline
(defun +python|update-version (&rest _)
(setq +python-version (run-hook-with-args-until-success '+python-version-functions)))
(setq +python-version (run-hook-with-args-until-success '+python-version-functions))
(dolist (buffer (doom-buffers-in-mode 'python-mode (buffer-list)))
(with-current-buffer buffer
(+python|add-version-to-modeline +python-version))))
(defalias '+python*update-version #'+python|update-version)
(defun +python|add-version-to-modeline ()
(defun +python|add-version-to-modeline (&optional version)
"Add version string to the major mode in the modeline."
(setq mode-name
(if-let* ((result (+python|update-version)))
(if-let* ((result (or version (+python|update-version))))
(format "Python %s" result)
"Python")))
(add-hook 'python-mode-hook #'+python|add-version-to-modeline))