From 0903dfa0c872729316b1d1b02752964810bca7d6 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 5 Oct 2016 09:23:39 +0200 Subject: [PATCH] Add *media-info modeline segment for image buffers --- core/core-modeline.el | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/core/core-modeline.el b/core/core-modeline.el index 1484a1d46..f936a9497 100644 --- a/core/core-modeline.el +++ b/core/core-modeline.el @@ -376,6 +376,11 @@ lines are selected, or the NxM dimensions of a block selection." length)) 'face (if active 'doom-modeline-panel 'mode-line-inactive)))) +(defun *media-info () + (cond ((eq major-mode 'image-mode) + (let ((size (image-size (image-get-display-property) :pixels))) + (format " %dx%d " (car size) (cdr size)))))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun doom-modeline (&optional id) @@ -394,17 +399,24 @@ lines are selected, or the NxM dimensions of a block selection." ,(if (eq id 'scratch) '(*buffer-project) '(*buffer-info)) - (*selection-info) - (*flycheck))) - (rhs (list (*buffer-encoding) - (*vc) + ,(if (eq id 'media) + '(*media-info) + '(list " %l:%c %p " + (*selection-info) + (*flycheck))))) + (rhs (list ,(unless (eq id 'media) + '(list (*buffer-encoding) + (*vc))) (*major-mode))) (mid (propertize " " 'display `((space :align-to (- (+ right right-fringe right-margin) ,(+ 1 (string-width (format-mode-line rhs))))))))) (list lhs mid rhs)))) -(setq-default mode-line-format (doom-modeline)) +(setq mode-line-format (doom-modeline)) + +(add-hook! image-mode + (setq mode-line-format (doom-modeline 'media))) ;;