Fix potential bugs in coding system segments

This commit is contained in:
Jessie Hildebrandt 2022-12-29 00:39:02 -05:00
parent 1943158fc9
commit 410e54f9ba

View File

@ -741,8 +741,9 @@ Checkers checked, in order: `flycheck', `flymake'."
;; ---------------------------------- ;; ;; ---------------------------------- ;;
(defun mood-line-segment-eol () (defun mood-line-segment-eol ()
"Display the EOL style of the current buffer." "Display the EOL type for the coding system of the current buffer."
(when mood-line-show-eol-style (when (and mood-line-show-eol-style
buffer-file-coding-system)
(pcase (coding-system-eol-type buffer-file-coding-system) (pcase (coding-system-eol-type buffer-file-coding-system)
(0 "LF ") (0 "LF ")
(1 "CRLF ") (1 "CRLF ")
@ -753,15 +754,16 @@ Checkers checked, in order: `flycheck', `flymake'."
;; ---------------------------------- ;; ;; ---------------------------------- ;;
(defun mood-line-segment-encoding () (defun mood-line-segment-encoding ()
"Display the encoding and EOL style of the buffer." "Display the name of the coding system of the current buffer."
(when mood-line-show-encoding-information (when (and mood-line-show-encoding-information
(concat (let ((sys (coding-system-plist buffer-file-coding-system))) buffer-file-coding-system)
(concat (let ((coding-system (coding-system-plist buffer-file-coding-system)))
(cond (cond
((memq (plist-get sys :category) ((memq (plist-get coding-system :category)
'(coding-category-undecided coding-category-utf-8)) '(coding-category-undecided coding-category-utf-8))
"UTF-8") "UTF-8")
(t (t
(upcase (symbol-name (plist-get sys :name)))))) (upcase (symbol-name (plist-get coding-system :name))))))
" "))) " ")))
;; ---------------------------------- ;; ;; ---------------------------------- ;;