Commits

Anonymous committed ae7a587

Add dynamic position/wc display

  • Participants
  • Parent commits 77e17a6

Comments (0)

Files changed (1)

files/mode-line.el

             "Narrow "))
    (-3 "%p")
    " "
-   (17 ("(%l,%c," (:eval (format "%s" (point))) ")"))
+   (17 (:eval (if (use-region-p)
+                  (format "(wc:%d,%d,%d)"
+                          (abs (- (point) (mark)))
+                          (count-words-region (point) (mark))
+                          (abs (- (line-number-at-pos (point))
+                                  (line-number-at-pos (mark)))))
+                (format "(%%l,%%c,%d)" (point)))))
 
    ;; Path to the file in buffer. If it doesn't have associated file,
    ;; display nothing.
    ;; see ~/.emacs.d/vendor/wc-mode/wc-mode.el
    (wc-mode
     (6 (" (wc:" (:eval (if (use-region-p)
-                  (format "%d,%d,%d"
-                          (abs (- (point) (mark)))
-                          (count-words-region (point) (mark))
-                          (abs (- (line-number-at-pos (point))
-                                  (line-number-at-pos (mark)))))
-                (format "%d,%d,%d"
-                        (point-max)
-                        (count-words-region (point-min) (point-max))
-                        (line-number-at-pos (point-max)))))
+                           (format "%d,%d,%d"
+                                   (abs (- (point) (mark)))
+                                   (count-words-region (point) (mark))
+                                   (abs (- (line-number-at-pos (point))
+                                           (line-number-at-pos (mark)))))
+                         (format "%d,%d,%d"
+                                 (point-max)
+                                 (count-words-region (point-min) (point-max))
+                                 (line-number-at-pos (point-max)))))
         ")")
        ))
 
    " (" mode-line-mule-info ")"
    " " global-mode-string
+
+   ;; hack to make the modeline refresh after each change in buffer
+   (:propertize "%l" face (:foreground "black"))
    ))
 
 (setq-default 2C-mode-line-format mode-line-format)