diff options
Diffstat (limited to 'lisp/+modeline.el')
-rw-r--r-- | lisp/+modeline.el | 72 |
1 files changed, 47 insertions, 25 deletions
diff --git a/lisp/+modeline.el b/lisp/+modeline.el index 3f25a40..10bf6d2 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el | |||
@@ -183,32 +183,54 @@ The order of elements matters: whichever one matches first is applied." | |||
183 | "Toggle the percentage display in the mode line (File Percentage Mode)." | 183 | "Toggle the percentage display in the mode line (File Percentage Mode)." |
184 | :init-value t :global t :group 'mode-line) | 184 | :init-value t :global t :group 'mode-line) |
185 | 185 | ||
186 | (defun +modeline-position (&optional _) ; adapted from `simple-modeline' | 186 | (defun +modeline-file-percentage (&optional spacer) |
187 | "Display the current cursor position." | 187 | "Display the position in the current file." |
188 | `(,(or spacer +modeline-default-spacer) | ||
189 | (:propertize (file-percentage-mode | ||
190 | (" " (-3 "%p") "%%")) | ||
191 | font-lock-face font-lock-comment-face))) | ||
192 | |||
193 | (define-minor-mode region-indicator-mode | ||
194 | "Toggle the region indicator in the mode line." | ||
195 | :init-value t :global t :group 'mode-line) | ||
196 | |||
197 | (defun +modeline-region (&optional spacer) | ||
198 | "Display an indicator if the region is active." | ||
199 | (when (and region-indicator-mode | ||
200 | (region-active-p)) | ||
201 | (list | ||
202 | (format "%s%6s" | ||
203 | (or spacer +modeline-default-spacer) | ||
204 | (propertize (format "%s%d" | ||
205 | (if (and (< (point) (mark))) "-" "+") | ||
206 | (apply '+ (mapcar (lambda (pos) | ||
207 | (- (cdr pos) | ||
208 | (car pos))) | ||
209 | (region-bounds)))) | ||
210 | 'font-lock-face 'font-lock-variable-name-face))))) | ||
211 | |||
212 | (defun +modeline-line-column (&optional spacer) ; adapted from `simple-modeline' | ||
213 | "Display the current cursor line and column depending on modes." | ||
188 | (let ((sep "|") (before " [") (after "]")) | 214 | (let ((sep "|") (before " [") (after "]")) |
189 | (list `(:propertize (line-number-mode | 215 | `(,(or spacer +modeline-default-spacer) |
190 | ((column-number-mode | 216 | (:propertize (line-number-mode |
191 | (column-number-indicator-zero-based | 217 | ((column-number-mode |
192 | ,(concat before "%l" sep "%c" after) | 218 | (column-number-indicator-zero-based |
193 | ,(concat before "%l" sep "%C" after)) | 219 | ,(concat before "%l" sep "%c" after) |
194 | ,(concat before "%l" sep "" after))) | 220 | ,(concat before "%l" sep "%C" after)) |
195 | ((column-number-mode | 221 | ,(concat before "%l" sep "" after))) |
196 | (column-number-indicator-zero-based | 222 | ((column-number-mode |
197 | ,(concat before sep "%c" after) | 223 | (column-number-indicator-zero-based |
198 | ,(concat before sep "%C" after))))) | 224 | ,(concat before sep "%c" after) |
199 | font-lock-face font-lock-comment-face) | 225 | ,(concat before sep "%C" after))))) |
200 | (if (region-active-p) | 226 | font-lock-face font-lock-comment-face)))) |
201 | (propertize (format "%s%-5d" | 227 | |
202 | (if (and (mark) (< (point) (mark))) "-" "+") | 228 | (defun +modeline-position (&optional _) |
203 | (apply '+ (mapcar | 229 | "Display the current cursor position. |
204 | (lambda (pos) | 230 | See `line-number-mode', `column-number-mode', `file-percentage-mode'" |
205 | (- (cdr pos) | 231 | (append (+modeline-line-column) |
206 | (car pos))) | 232 | (+modeline-region) |
207 | (region-bounds)))) | 233 | (+modeline-file-percentage))) |
208 | 'font-lock-face 'font-lock-variable-name-face)) | ||
209 | '(:propertize (file-percentage-mode | ||
210 | (" " (-3 "%p") "%%")) | ||
211 | font-lock-face font-lock-comment-face)))) | ||
212 | 234 | ||
213 | (defun +modeline-vc (&optional spacer) | 235 | (defun +modeline-vc (&optional spacer) |
214 | "Display the version control branch of the current buffer in the modeline." | 236 | "Display the version control branch of the current buffer in the modeline." |