help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Changing Color Of Column # In Modeline


From: Drew Adams
Subject: RE: Changing Color Of Column # In Modeline
Date: Wed, 23 Nov 2005 22:21:33 -0800

    I was having similar problems.  I'm using v21 as well.  But how do you
    use what you're proposing?  I added it to my init file, then evaluated,
    then toggled my major-mode (tcl-mode in this case).  Nothing happened.
    What am I missing?

The code I sent, like the code that MJF sent, requires Emacs 22, because it
uses variable `mode-line-position'. What I said wrt Emacs 21 was that you
could do something similar in Emacs 21, using variable `mode-line-format'
instead of `mode-line-position'.

The following works in Emacs 21. I just took the default value for
`mode-line-format' (defined in bindings.el), wrapped it in (:eval...), and
added the conditional face expression for `column-number-mode'.

(defcustom my-column-limit 70
  "When current column is > this, column is highlighted in mode-line."
  :type 'integer :group 'convenience)

(setq mode-line-format
      '(:eval
        (let* ((help-echo
                "mouse-1: select window, mouse-2: \
delete others, mouse-3: delete ...")
               (dashes (propertize "--" 'help-echo help-echo)))
          (list
           (propertize "-" 'help-echo help-echo)
           'mode-line-mule-info
           'mode-line-modified
           'mode-line-frame-identification
           'mode-line-buffer-identification
           (propertize "   " 'help-echo help-echo)
           'global-mode-string
           (propertize "   %[(" 'help-echo help-echo)
           '(:eval (mode-line-mode-name))
           'mode-line-process
           'minor-mode-alist
           (propertize "%n" 'help-echo "mouse-2: widen"
                       'local-map (make-mode-line-mouse-map
                                   'mouse-2 #'mode-line-widen))
           (propertize ")%]--" 'help-echo help-echo)
           `(which-func-mode ("" which-func-format ,dashes))
           `(line-number-mode
             (,(propertize "L%l" 'help-echo help-echo) ,dashes))
           `(column-number-mode
             (,(propertize
                "C%c"
                'face (and (> (current-column) 50) 'bold)
                'help-echo help-echo)
              ,dashes))
           `(-3 . ,(propertize "%p" 'help-echo help-echo))
           (propertize "-%-" 'help-echo help-echo)))))

Note: You could, alternatively, put the (:eval ...) around only the
column-number-mode stuff, but then you would also need to substitute the
values for `help-echo' and `dashes' (because they would be quoted inside the
'(:eval ...), so they wouldn't pick up the values from the `let'). IOW, you
could remove the (:eval ...) from around the `let' above, and do this in
place of the (column-number-mode...) stuff:

'(:eval `(column-number-mode
          (,(propertize
             "C%c"
             'face (and (> (current-column) 50) 'bold)
             'help-echo "mouse-1: select window,....")
           ,(propertize "--" 'help-echo "mouse-1: select window,..."))))

That's maybe (maybe not) a bit more understandable, if a bit redundant. If
you don't care about the `help-echo' strings, then that becomes much
simpler:

'(:eval `(column-number-mode
          (,(propertize "C%c" 'face (and (> (current-column) 50) 'bold))
           "--")))

And don't forget to turn on `column-number-mode': (column-number-mode 1)
;-).

HTH. - Drew





reply via email to

[Prev in Thread] Current Thread [Next in Thread]