unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: pmlists@free.fr (Peter Münster)
To: 9205@debbugs.gnu.org
Subject: bug#9205: 24.0.50; colored mark in vc mode-line
Date: Fri, 29 Jul 2011 13:13:36 +0200	[thread overview]
Message-ID: <874o25jq5b.fsf@micropit.couberia.bzh> (raw)

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





             reply	other threads:[~2011-07-29 11:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-29 11:13 Peter Münster [this message]
2012-04-10 23:56 ` bug#9205: 24.0.50; colored mark in vc mode-line 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874o25jq5b.fsf@micropit.couberia.bzh \
    --to=pmlists@free.fr \
    --cc=9205@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).