Refactor modeline

This commit is contained in:
Henrik Lissner 2015-10-28 17:27:37 -04:00
parent a364cf2695
commit f134c6f267

View file

@ -202,21 +202,19 @@
(spaceline-define-segment narf-buffer-modified (spaceline-define-segment narf-buffer-modified
(concat (concat
(if (and buffer-file-name (buffer-modified-p)) "[+]") (when buffer-file-name
(if buffer-read-only "[RO]") (concat
(if (and buffer-file-name (not (file-exists-p buffer-file-name))) "[!]")) (when (buffer-modified-p) "[+]")
(unless (file-exists-p buffer-file-name) "[!]")))
(if buffer-read-only "[RO]"))
:face mode-line-is-modified :face mode-line-is-modified
:when (not (string-match-p "^\\s*\\*" (buffer-name))) :when (not (string-prefix-p "*" (buffer-name)))
:tight t) :tight t)
(spaceline-define-segment narf-buffer-encoding-abbrev (spaceline-define-segment narf-buffer-encoding-abbrev
"The line ending convention used in the buffer." "The line ending convention used in the buffer."
(let ((buf-coding (symbol-name buffer-file-coding-system))) (symbol-name buffer-file-coding-system)
(if (string-match "\\(dos\\|unix\\|mac\\)" buf-coding) :when (not (string-prefix-p "utf-8" (symbol-name buffer-file-coding-system))))
(match-string 1 buf-coding)
buf-coding))
:when (and buffer-file-name
(not (string-match-p "unix" (symbol-name buffer-file-coding-system)))))
(spaceline-define-segment narf-buffer-position (spaceline-define-segment narf-buffer-position
"A more vim-like buffer position." "A more vim-like buffer position."
@ -260,17 +258,14 @@ to be enabled."
(let ((here anzu--current-position) (let ((here anzu--current-position)
(total anzu--total-matched)) (total anzu--total-matched))
(when anzu--state (when anzu--state
(concat
(propertize
(cl-case anzu--state (cl-case anzu--state
(search (format " %s/%d%s " (search (format " %s/%d%s "
(anzu--format-here-position here total) (anzu--format-here-position here total)
total (if anzu--overflow-p "+" ""))) total (if anzu--overflow-p "+" "")))
(replace-query (format " %d replace " total)) (replace-query (format " %d replace " total))
(replace (format " %d/%d " here total))) (replace (format " %d/%d " here total)))))
'face highlight-face)
" ")))
:when (and active (bound-and-true-p anzu--state)) :when (and active (bound-and-true-p anzu--state))
:face highlight-face
:tight t) :tight t)
;; Initialize modeline ;; Initialize modeline