* mood-line.el: Fixed multiple comments

In adherence with elisp convention, comments have been shortened
to fit within 80 columns. Some nitpicky grammar/spelling mistakes
were fixed. Some small inaccuracies were also corrected.
This commit is contained in:
Trevor Richards 2022-07-28 21:07:37 -07:00
parent ef1c752679
commit 935043455c
No known key found for this signature in database
GPG Key ID: 8546CF84A13DD5EF

View File

@ -73,53 +73,53 @@
:group 'mode-line) :group 'mode-line)
(defcustom mood-line-show-eol-style nil (defcustom mood-line-show-eol-style nil
"If t, the EOL style of the current buffer will be displayed in the mode-line." "When non-nil, show the EOL style of the current buffer."
:group 'mood-line :group 'mood-line
:type 'boolean) :type 'boolean)
(defcustom mood-line-show-encoding-information nil (defcustom mood-line-show-encoding-information nil
"If t, the encoding format of the current buffer will be displayed in the mode-line." "When non-nil, show the encoding format of the current buffer."
:group 'mood-line :group 'mood-line
:type 'boolean) :type 'boolean)
(defcustom mood-line-show-cursor-point nil (defcustom mood-line-show-cursor-point nil
"If t, the value of `point' will be displayed next to the cursor position in the mode-line." "When non-nil, show the `point' value as an integer."
:group 'mood-line :group 'mood-line
:type 'boolean) :type 'boolean)
(defface mood-line-buffer-name (defface mood-line-buffer-name
'((t (:inherit (mode-line-buffer-id)))) '((t (:inherit (mode-line-buffer-id))))
"Face used for major mode indicator in the mode-line." "Face used for the `buffer-name'."
:group 'mood-line) :group 'mood-line)
(defface mood-line-major-mode (defface mood-line-major-mode
'((t (:inherit (bold)))) '((t (:inherit (bold))))
"Face used for major mode indicator in the mode-line." "Face used for the major mode indicator."
:group 'mood-line) :group 'mood-line)
(defface mood-line-status-neutral (defface mood-line-status-neutral
'((t (:inherit (shadow)))) '((t (:inherit (shadow))))
"Face used for neutral or inactive status indicators in the mode-line." "Face used for neutral or inactive status indicators."
:group 'mood-line) :group 'mood-line)
(defface mood-line-status-info (defface mood-line-status-info
'((t (:inherit (font-lock-keyword-face)))) '((t (:inherit (font-lock-keyword-face))))
"Face used for generic status indicators in the mode-line." "Face used for generic status indicators."
:group 'mood-line) :group 'mood-line)
(defface mood-line-status-success (defface mood-line-status-success
'((t (:inherit (success)))) '((t (:inherit (success))))
"Face used for success status indicators in the mode-line." "Face used for success status indicators."
:group 'mood-line) :group 'mood-line)
(defface mood-line-status-warning (defface mood-line-status-warning
'((t (:inherit (warning)))) '((t (:inherit (warning))))
"Face for warning status indicators in the mode-line." "Face for warning status indicators."
:group 'mood-line) :group 'mood-line)
(defface mood-line-status-error (defface mood-line-status-error
'((t (:inherit (error)))) '((t (:inherit (error))))
"Face for error stauts indicators in the mode-line." "Face for error status indicators."
:group 'mood-line) :group 'mood-line)
(defface mood-line-unimportant (defface mood-line-unimportant
@ -129,7 +129,7 @@
(defface mood-line-modified (defface mood-line-modified
'((t (:inherit (error)))) '((t (:inherit (error))))
"Face used for the 'modified' indicator symbol in the mode-line." "Face used for the 'modified' indicator symbol."
:group 'mood-line) :group 'mood-line)
;; ;;
@ -153,14 +153,14 @@
(mood-line--string-trim-left (mood-line--string-trim-right string))) (mood-line--string-trim-left (mood-line--string-trim-right string)))
(defun mood-line--format (left right) (defun mood-line--format (left right)
"Return a string of `window-width' length containing LEFT and RIGHT, aligned respectively." "Format a mode-line with a `LEFT' and `RIGHT' justified list of elements.
The modeline should fit the `window-width' with space between the lists."
(let ((reserve (length right))) (let ((reserve (length right)))
(concat left (concat left
" " " "
(propertize " " (propertize " "
'display `((space :align-to (- right (- 0 right-margin) ,reserve)))) 'display `((space :align-to (- right (- 0 right-margin) ,reserve))))
right))) right)))
;; ;;
;; Update functions ;; Update functions
;; ;;
@ -218,7 +218,7 @@
;; ;;
(defun mood-line-segment-modified () (defun mood-line-segment-modified ()
"Displays a color-coded buffer modification/read-only indicator in the mode-line." "Display an indicator for buffer modification status."
(if (not (string-match-p "\\*.*\\*" (buffer-name))) (if (not (string-match-p "\\*.*\\*" (buffer-name)))
(if (buffer-modified-p) (if (buffer-modified-p)
(propertize "" 'face 'mood-line-modified) (propertize "" 'face 'mood-line-modified)
@ -228,11 +228,11 @@
" ")) " "))
(defun mood-line-segment-buffer-name () (defun mood-line-segment-buffer-name ()
"Displays the name of the current buffer in the mode-line." "Display the name of the current buffer."
(propertize "%b " 'face 'mood-line-buffer-name)) (propertize "%b " 'face 'mood-line-buffer-name))
(defun mood-line-segment-anzu () (defun mood-line-segment-anzu ()
"Displays color-coded anzu status information in the mode-line (if available)." "Display color-coded anzu status information."
(when (and (boundp 'anzu--state) anzu--state) (when (and (boundp 'anzu--state) anzu--state)
(cond ((eq anzu--state 'replace-query) (cond ((eq anzu--state 'replace-query)
(format #("Replace: %d " 0 11 (face mood-line-status-warning)) anzu--cached-count)) (format #("Replace: %d " 0 11 (face mood-line-status-warning)) anzu--cached-count))
@ -242,19 +242,19 @@
(format #("%d/%d " 0 5 (face mood-line-status-info)) anzu--current-position anzu--total-matched))))) (format #("%d/%d " 0 5 (face mood-line-status-info)) anzu--current-position anzu--total-matched)))))
(defun mood-line-segment-multiple-cursors () (defun mood-line-segment-multiple-cursors ()
"Displays the number of active multiple-cursors in the mode-line (if available)." "Display the number of active multiple-cursors."
(when (and (boundp 'multiple-cursors-mode) multiple-cursors-mode) (when (and (boundp 'multiple-cursors-mode) multiple-cursors-mode)
(concat "MC" (concat "MC"
(format #("×%d " 0 3 (face mood-line-status-warning)) (mc/num-cursors))))) (format #("×%d " 0 3 (face mood-line-status-warning)) (mc/num-cursors)))))
(defun mood-line-segment-position () (defun mood-line-segment-position ()
"Displays the current cursor position in the mode-line." "Display the current cursor position."
(concat "%l:%c" (concat "%l:%c"
(when mood-line-show-cursor-point (propertize (format ":%d" (point)) 'face 'mood-line-unimportant)) (when mood-line-show-cursor-point (propertize (format ":%d" (point)) 'face 'mood-line-unimportant))
(propertize " %p%% " 'face 'mood-line-unimportant))) (propertize " %p%% " 'face 'mood-line-unimportant)))
(defun mood-line-segment-eol () (defun mood-line-segment-eol ()
"Displays the EOL style of the current buffer in the mode-line." "Display the EOL style of the current buffer."
(when mood-line-show-eol-style (when mood-line-show-eol-style
(pcase (coding-system-eol-type buffer-file-coding-system) (pcase (coding-system-eol-type buffer-file-coding-system)
(0 "LF ") (0 "LF ")
@ -262,7 +262,7 @@
(2 "CR ")))) (2 "CR "))))
(defun mood-line-segment-encoding () (defun mood-line-segment-encoding ()
"Displays the encoding and EOL style of the buffer in the mode-line." "Display the encoding and EOL style of the buffer."
(when mood-line-show-encoding-information (when mood-line-show-encoding-information
(concat (let ((sys (coding-system-plist buffer-file-coding-system))) (concat (let ((sys (coding-system-plist buffer-file-coding-system)))
(cond ((memq (plist-get sys :category) '(coding-category-undecided coding-category-utf-8)) (cond ((memq (plist-get sys :category) '(coding-category-undecided coding-category-utf-8))
@ -271,34 +271,35 @@
" "))) " ")))
(defun mood-line-segment-vc () (defun mood-line-segment-vc ()
"Displays color-coded version control information in the mode-line." "Display color-coded version control information."
mood-line--vc-text) mood-line--vc-text)
(defun mood-line-segment-major-mode () (defun mood-line-segment-major-mode ()
"Displays the current major mode in the mode-line." "Display the current major mode."
(concat (format-mode-line mode-name 'mood-line-major-mode) " ")) (concat (format-mode-line mode-name 'mood-line-major-mode) " "))
(defun mood-line-segment-misc-info () (defun mood-line-segment-misc-info ()
"Displays the current value of `mode-line-misc-info' in the mode-line." "Display the current value of `mode-line-misc-info'."
(let ((misc-info (format-mode-line mode-line-misc-info 'mood-line-unimportant))) (let ((misc-info (format-mode-line mode-line-misc-info 'mood-line-unimportant)))
(unless (string= (mood-line--string-trim misc-info) "") (unless (string= (mood-line--string-trim misc-info) "")
(concat (mood-line--string-trim misc-info) " ")))) (concat (mood-line--string-trim misc-info) " "))))
(defun mood-line-segment-flycheck () (defun mood-line-segment-flycheck ()
"Displays color-coded flycheck information in the mode-line (if available)." "Display color-coded flycheck information."
mood-line--flycheck-text) mood-line--flycheck-text)
(defun mood-line-segment-flymake () (defun mood-line-segment-flymake ()
"Displays information about the current status of flymake in the mode-line (if available)." "Display information about the current status of flymake."
(when (and (boundp 'flymake-mode) flymake-mode) (when (and (boundp 'flymake-mode) flymake-mode)
;; Depending on Emacs version, flymake stores the mode-line segment using one of two variable names ;; Depending on Emacs version, flymake stores the mode-line segment
;; using one of two variable names
(let ((flymake-segment-format (if (boundp 'flymake-mode-line-format) (let ((flymake-segment-format (if (boundp 'flymake-mode-line-format)
flymake-mode-line-format flymake-mode-line-format
flymake--mode-line-format))) flymake--mode-line-format)))
(concat (mood-line--string-trim (format-mode-line flymake-segment-format)) " ")))) (concat (mood-line--string-trim (format-mode-line flymake-segment-format)) " "))))
(defun mood-line-segment-process () (defun mood-line-segment-process ()
"Displays the current value of `mode-line-process' in the mode-line." "Display the current value of `mode-line-process'."
(let ((process-info (format-mode-line mode-line-process))) (let ((process-info (format-mode-line mode-line-process)))
(unless (string= (mood-line--string-trim process-info) "") (unless (string= (mood-line--string-trim process-info) "")
(concat (mood-line--string-trim process-info) " ")))) (concat (mood-line--string-trim process-info) " "))))
@ -328,7 +329,8 @@
(add-hook 'after-save-hook #'mood-line--update-vc-segment) (add-hook 'after-save-hook #'mood-line--update-vc-segment)
(advice-add #'vc-refresh-state :after #'mood-line--update-vc-segment) (advice-add #'vc-refresh-state :after #'mood-line--update-vc-segment)
;; Disable anzu's mode-line segment setting, saving the previous setting to be restored later (if present) ;; Disable anzu's mode-line segment setting, saving the previous
;; setting to be restored later (if present)
(when (boundp 'anzu-cons-mode-line-p) (when (boundp 'anzu-cons-mode-line-p)
(setq mood-line--anzu-cons-mode-line-p anzu-cons-mode-line-p)) (setq mood-line--anzu-cons-mode-line-p anzu-cons-mode-line-p))
(setq-default anzu-cons-mode-line-p nil) (setq-default anzu-cons-mode-line-p nil)