unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#9205: 24.0.50; colored mark in vc mode-line
@ 2011-07-29 11:13 Peter Münster
  2012-04-10 23:56 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 20+ messages in thread
From: Peter Münster @ 2011-07-29 11:13 UTC (permalink / raw)
  To: 9205

Hello,

Here a little feature request for vc:

--8<---------------cut here---------------start------------->8---
;; Make it immediately obvious, if file is modified or not, by a red or
;; a green point in the modeline.
;; Code is from psvn.el by Stefan Reichoer (GNU GPL)

(defvar vc-state-mark-modeline t)

(defun vc-mark-modeline-dot (color)
  (propertize "    "
              'display
              `(image :type xpm
                      :data ,(format "/* XPM */
static char * data[] = {
\"18 13 3 1\",
\"  c None\",
\"+ c #000000\",
\". c %s\",
\"                  \",
\"       +++++      \",
\"      +.....+     \",
\"     +.......+    \",
\"    +.........+   \",
\"    +.........+   \",
\"    +.........+   \",
\"    +.........+   \",
\"    +.........+   \",
\"     +.......+    \",
\"      +.....+     \",
\"       +++++      \",
\"                  \"};"
                                     color)
                      :ascent center)))

(defsubst vc-state->color (stat)
  "Interpret vc-state symbol to mode line color"
  (case stat
    ('edited "tomato"      )
    ('up-to-date "GreenYellow" )
    ;; what is missing here??
    ;; ('unknown  "gray"        )
    ;; ('added    "blue"        )
    ;; ('deleted  "red"         )
    ;; ('unmerged "purple"      )
    (t "red")))

(defun vc-install-state-mark-modeline (color)
  (push `(vc-state-mark-modeline ,(vc-mark-modeline-dot color))
        mode-line-format))

(defun vc-uninstall-state-mark-modeline ()
  (setq mode-line-format
        (remove-if #'(lambda (mode) (eq (car-safe mode)
                                        'vc-state-mark-modeline))
                   mode-line-format)))

(defadvice vc-default-mode-line-string
  (before my-before-vc-mode-line-string activate)
  (let* ((backend-name (symbol-name backend))
   (state (vc-state file backend))
         (color (vc-state->color state)))
    (vc-uninstall-state-mark-modeline)
    (vc-install-state-mark-modeline color)))
--8<---------------cut here---------------end--------------->8---

Cheers,
-- 
           Peter





^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-06-27 16:27 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-29 11:13 bug#9205: 24.0.50; colored mark in vc mode-line Peter Münster
2012-04-10 23:56 ` Lars Magne Ingebrigtsen
2012-04-11  6:43   ` Chong Yidong
2012-04-11  7:39     ` Stefan Reichör
2012-04-12 13:39       ` Lars Magne Ingebrigtsen
2012-04-12 14:23         ` Peter Münster
2012-04-12 16:07           ` Stefan Monnier
2012-04-12 16:09             ` Lars Magne Ingebrigtsen
2012-04-12 18:22               ` Stefan Monnier
2012-04-12 18:24                 ` Lars Magne Ingebrigtsen
2012-04-12 18:51                   ` Peter Münster
2016-03-01  1:41                     ` Lars Ingebrigtsen
2016-03-01  1:47                       ` Lars Ingebrigtsen
2016-03-01  2:05                       ` Óscar Fuentes
2016-03-01  2:14                         ` Lars Ingebrigtsen
2016-03-01  2:24                           ` Óscar Fuentes
2016-03-01  3:05                             ` Lars Ingebrigtsen
2016-03-09 23:49                               ` Juri Linkov
2019-06-27 16:27                               ` Lars Ingebrigtsen
2012-04-12 14:36       ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).