new powerline segment: selection information (bug #711)

This commit is contained in:
Emmanuel Touzery 2015-02-27 18:34:01 +01:00 committed by syl20bnr
parent 14970bc785
commit 0146175023

View file

@ -1996,6 +1996,18 @@ Put (global-hungry-delete-mode) in dotspacemacs/config to enable by default."
(funcall separator-right vc-face face2))
(list (funcall separator-right face1 face2))))))
(defun column-number-at-pos (pos)
"Analog to line-number-at-pos."
(save-excursion (goto-char pos) (current-column)))
(defun selection-info ()
"String holding the number of columns in the selection
if it covers only one line, else number of lines in the selection"
(let* ((lines (count-lines (region-beginning) (region-end)))
(chars (- (region-end) (region-beginning))))
(number-to-string (if (> lines 1) lines chars)))
)
(defun spacemacs/mode-line-prepare-right ()
(let* ((active (powerline-selected-window-active))
(line-face (if active 'mode-line 'mode-line-inactive))
@ -2020,6 +2032,15 @@ Put (global-hungry-delete-mode) in dotspacemacs/config to enable by default."
battery-face 'r)
(funcall separator-right battery-face face1))
(list (funcall separator-right face2 face1)))
(if (use-region-p)
;; selection info, if there is a selection.
(list
(powerline-raw " " face1)
(powerline-raw (selection-info) face1)
(powerline-raw " " face1)
(funcall separator-left face1 face2)
(powerline-raw " " face2)
(funcall separator-right face2 face1)))
(list
;; row:column
(powerline-raw " " face1)