* Changing Color Of Column # In Modeline @ 2005-11-22 1:07 gamename 2005-11-22 6:26 ` M Jared Finder 2005-11-22 17:24 ` rgb 0 siblings, 2 replies; 17+ messages in thread From: gamename @ 2005-11-22 1:07 UTC (permalink / raw) Hi, How can I change the color of the column number displayed in the modeline when when its greater than a certain value? The coding standard where I work requires that all code be within 80 columns. So I would like to create an eye-catcher by changing the modeline column value to red after the point exceeds the 79th column. Is that possible? Does anyone have a code snippet which does that or something similar? TIA, -T ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Changing Color Of Column # In Modeline 2005-11-22 1:07 Changing Color Of Column # In Modeline gamename @ 2005-11-22 6:26 ` M Jared Finder 2005-11-22 17:24 ` rgb 1 sibling, 0 replies; 17+ messages in thread From: M Jared Finder @ 2005-11-22 6:26 UTC (permalink / raw) gamename wrote: > Hi, > > How can I change the color of the column number displayed in the > modeline when when its greater than a certain value? The coding > standard where I work requires that all code be within 80 columns. So > I would like to create an eye-catcher by changing the modeline column > value to red after the point exceeds the 79th column. > > Is that possible? Does anyone have a code snippet which does that or > something similar? Margin-mode <http://www.xanadb.com/archive/emacs/20040630> sounds like what you want. -- MJF ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Changing Color Of Column # In Modeline 2005-11-22 1:07 Changing Color Of Column # In Modeline gamename 2005-11-22 6:26 ` M Jared Finder @ 2005-11-22 17:24 ` rgb 2005-11-22 21:02 ` gamename 2005-11-22 23:09 ` Ilya Zakharevich 1 sibling, 2 replies; 17+ messages in thread From: rgb @ 2005-11-22 17:24 UTC (permalink / raw) > How can I change the color of the column number displayed in the > modeline when when its greater than a certain value? The coding > standard where I work requires that all code be within 80 columns. So > I would like to create an eye-catcher by changing the modeline column > value to red after the point exceeds the 79th column. > > Is that possible? Does anyone have a code snippet which does that or > something similar? http://www.emacswiki.org/cgi-bin/wiki/ColumnMarker Using it is as easy as: (require 'column-marker) (add-hook foo-mode-hook (lambda ()(interactive)(column-marker-1 80))) ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Changing Color Of Column # In Modeline 2005-11-22 17:24 ` rgb @ 2005-11-22 21:02 ` gamename 2005-11-23 1:21 ` M Jared Finder 2005-11-22 23:09 ` Ilya Zakharevich 1 sibling, 1 reply; 17+ messages in thread From: gamename @ 2005-11-22 21:02 UTC (permalink / raw) Thanks, but what I'm trying to figure out is how to change the color of the column display on the _modeline_ itself. So, if my point is at col 80 in the buffer, I'd like to update the modeline to show "C80" in some eye-catching way. Is that possible? -T ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Changing Color Of Column # In Modeline 2005-11-22 21:02 ` gamename @ 2005-11-23 1:21 ` M Jared Finder 2005-11-23 20:32 ` Kevin Rodgers 0 siblings, 1 reply; 17+ messages in thread From: M Jared Finder @ 2005-11-23 1:21 UTC (permalink / raw) gamename wrote: > Thanks, but what I'm trying to figure out is how to change the color of > the column display on the _modeline_ itself. So, if my point is at col > 80 in the buffer, I'd like to update the modeline to show "C80" in some > eye-catching way. > > Is that possible? How about putting this in your init file: (setf mode-line-position '(:eval (if (>= (current-column) 80) '(:propertize "(%l,%c)" face bold) "(%l,%c)"))) This code does not respect line-number-mode or column-number-mode; I've assumed you have them both on. -- MJF ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Changing Color Of Column # In Modeline 2005-11-23 1:21 ` M Jared Finder @ 2005-11-23 20:32 ` Kevin Rodgers 2005-11-23 21:08 ` Drew Adams [not found] ` <mailman.16497.1132780124.20277.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 17+ messages in thread From: Kevin Rodgers @ 2005-11-23 20:32 UTC (permalink / raw) M Jared Finder wrote: > How about putting this in your init file: > > (setf mode-line-position '(:eval (if (>= (current-column) 80) > '(:propertize "(%l,%c)" face bold) > "(%l,%c)"))) Does that really work for you? mode-line-position is not documented in Emacs 21 -- are you running 22.0 (CVS)? -- Kevin Rodgers ^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: Changing Color Of Column # In Modeline 2005-11-23 20:32 ` Kevin Rodgers @ 2005-11-23 21:08 ` Drew Adams [not found] ` <mailman.16497.1132780124.20277.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 17+ messages in thread From: Drew Adams @ 2005-11-23 21:08 UTC (permalink / raw) > How about putting this in your init file: > > (setf mode-line-position '(:eval (if (>= (current-column) 80) > '(:propertize "(%l,%c)" > face bold) > "(%l,%c)"))) Does that really work for you? mode-line-position is not documented in Emacs 21 -- are you running 22.0 (CVS)? It works fine in Emacs 22. Yes, `mode-line-position' is undefined in Emacs 21. I use this, BTW: (setq mode-line-position '(:eval (let ((help-echo "mouse-1: select (drag to resize), \ mouse-2: delete others, mouse-3: delete this")) `((-3 ,(propertize "%p" 'help-echo help-echo)) (size-indication-mode (8 ,(propertize " of %I" 'help-echo help-echo))) (line-number-mode ((column-number-mode (10 ,(propertize " (%l,%c)" 'face (and (> (current-column) 1on1-mode-line-column-limit) 'font-lock-function-name-face) 'help-echo help-echo)) (6 ,(propertize " L%l" 'help-echo help-echo)))) ((column-number-mode (5 ,(propertize " C%c" 'face (and (> (current-column) 1on1-mode-line-column-limit) 'font-lock-function-name-face) 'help-echo help-echo))))))))) The key thing here is :eval, which makes sure the column-number face gets updated - it is available in Emacs 21, as is `mode-line-format', which you can manipulate in a way similar to the above to change the `column-number-mode' face. In Emacs 20, you could use `put' to add the text properties (there is no `propertize'), but you cannot easily update the face, because there is no :eval. ^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <mailman.16497.1132780124.20277.help-gnu-emacs@gnu.org>]
* Re: Changing Color Of Column # In Modeline [not found] ` <mailman.16497.1132780124.20277.help-gnu-emacs@gnu.org> @ 2005-11-24 0:20 ` gamename 2005-11-24 6:21 ` Drew Adams [not found] ` <mailman.16559.1132813301.20277.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 17+ messages in thread From: gamename @ 2005-11-24 0:20 UTC (permalink / raw) Hi Drew, 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? TIA, -T ^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: Changing Color Of Column # In Modeline 2005-11-24 0:20 ` gamename @ 2005-11-24 6:21 ` Drew Adams [not found] ` <mailman.16559.1132813301.20277.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 17+ messages in thread From: Drew Adams @ 2005-11-24 6:21 UTC (permalink / raw) 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 ^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <mailman.16559.1132813301.20277.help-gnu-emacs@gnu.org>]
* Re: Changing Color Of Column # In Modeline [not found] ` <mailman.16559.1132813301.20277.help-gnu-emacs@gnu.org> @ 2005-11-25 23:03 ` gamename 2005-11-26 0:01 ` Drew Adams 2005-11-26 18:33 ` gamename 1 sibling, 1 reply; 17+ messages in thread From: gamename @ 2005-11-25 23:03 UTC (permalink / raw) Hi Drew, Thanks for your reply. Well, I tried using the first emacs 21 example above and then eventually all of them in the last post. After evaluating it, I would toggle "tcl-mode", "which-func-mode", and even "font-lock-mode" in various combinations as well as simply exiting emacs and restarting it. No luck. The column value still remains in the same font/weight no matter what column I have the cursor on. Any ideas what I may be doing incorrectly? TIA, -T ^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: Changing Color Of Column # In Modeline 2005-11-25 23:03 ` gamename @ 2005-11-26 0:01 ` Drew Adams 0 siblings, 0 replies; 17+ messages in thread From: Drew Adams @ 2005-11-26 0:01 UTC (permalink / raw) Well, I tried using the first emacs 21 example above and then eventually all of them in the last post. After evaluating it, I would toggle "tcl-mode", "which-func-mode", and even "font-lock-mode" in various combinations as well as simply exiting emacs and restarting it. No luck. The column value still remains in the same font/weight no matter what column I have the cursor on. Any ideas what I may be doing incorrectly? I tested it in GNU Emacs 21.3.1 (i386-mingw-nt5.1.2600) of 2004-03-10 on NYAUMO. Did you use emacs -q? Do that first (always), to be sure there is not something else in your environment that is interfering. If it works with emacs -q but it doesn't work when you load your init file, then email me off-list and we can try to figure out what the problem is. I suspect that the problem might be that I showed you `setq', not `setq-default'. The former only turns this on for the current buffer; the latter makes it the default behavior. Which one you use depends on how you want to use this (e.g. in a certain mode hook or systematically). If you just want this on all the time by default, then use `setq-default'. 1. emacs -q 2. Paste the code (from my email of 11/23 at 10:22) into buffer *scratch*. That is, the first assignment to mode-line-format (the long one from my email). 3. M-x eval-buffer 4. C-u M-x column-number-mode >From then on, whenever the cursor is in column 51 or greater, the column indicator in the mode line should be bold. (The hard-coded `50' should ultimately be changed to a user option such as the `my-column-limit' I provided.) HTH. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Changing Color Of Column # In Modeline [not found] ` <mailman.16559.1132813301.20277.help-gnu-emacs@gnu.org> 2005-11-25 23:03 ` gamename @ 2005-11-26 18:33 ` gamename 2005-11-26 18:53 ` Drew Adams [not found] ` <mailman.16824.1133031197.20277.help-gnu-emacs@gnu.org> 1 sibling, 2 replies; 17+ messages in thread From: gamename @ 2005-11-26 18:33 UTC (permalink / raw) Hi Drew, Thanks for all your help. Well, I tried the v21 suggestions in various combinations andstill the column #s aren't changing in font/size/weight/color. I've evaluated the above code (in various combinations), toggled tcl-mode, and also font-lock-mode as well. The specific version I'm using is: GNU Emacs 21.2.95.2 Got any idea what I'm doing incorrectly? ;-) -T ^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: Changing Color Of Column # In Modeline 2005-11-26 18:33 ` gamename @ 2005-11-26 18:53 ` Drew Adams [not found] ` <mailman.16824.1133031197.20277.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 17+ messages in thread From: Drew Adams @ 2005-11-26 18:53 UTC (permalink / raw) Well, I tried the v21 suggestions in various combinations andstill the column #s aren't changing in font/size/weight/color. I've evaluated the above code (in various combinations), toggled tcl-mode, and also font-lock-mode as well. The specific version I'm using is: GNU Emacs 21.2.95.2 Got any idea what I'm doing incorrectly? ;-) Sorry, beyond what I said earlier, I don't really know what to say that might help. It works for me in 21.3.1. I don't have 21.2.95.2 to test with. Check the doc for 21.2.95.2 - look in the Emacs-Lisp manual (`C-h i') to see if "(:eval...)" is supported (just search for ":eval" - if it's not there, then it's probably not supported). It is not supported in Emacs 20 (which I use most of the time); it may not be supported in 21.2.95.2 either - in that case, you're out of luck. I assume that you already tried without your .emacs file, using emacs -q, correct? ^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <mailman.16824.1133031197.20277.help-gnu-emacs@gnu.org>]
* Re: Changing Color Of Column # In Modeline [not found] ` <mailman.16824.1133031197.20277.help-gnu-emacs@gnu.org> @ 2005-11-27 0:25 ` gamename 0 siblings, 0 replies; 17+ messages in thread From: gamename @ 2005-11-27 0:25 UTC (permalink / raw) Hi Drew, The Nov 26, 10:33 am post is redundant. I posted it because I'm using the Google frontend for usenet and it didn't update for about 36 hours. Consequently, I double-posted thinking my first one was lost. Sorry for the confusion everyone. -T ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Changing Color Of Column # In Modeline 2005-11-22 17:24 ` rgb 2005-11-22 21:02 ` gamename @ 2005-11-22 23:09 ` Ilya Zakharevich 2005-11-25 17:55 ` rgb 1 sibling, 1 reply; 17+ messages in thread From: Ilya Zakharevich @ 2005-11-22 23:09 UTC (permalink / raw) [A complimentary Cc of this posting was sent to rgb <rbielaws@i1.net>], who wrote in article <1132680280.003922.155730@g47g2000cwa.googlegroups.com>: > > Is that possible? Does anyone have a code snippet which does that or > > something similar? > > http://www.emacswiki.org/cgi-bin/wiki/ColumnMarker This one looks too restrictive. Some time ago I wrote this: (defun match-at-column-79 (end) (let (done c res) (while (and (not done) (< (point) end)) ;;(message "At point=%s, end=%s, col=%s" (point) end (setq c (current-column))) (cond ; need to move forward >=1 char ((< 79 (current-column)) (forward-line 1)) ; will not move at eobp only ((< 79 (move-to-column 80)) ; will move >= 0 char; 0 chars at eolp (setq done t res t) (forward-char -1) (re-search-forward ".")) ((eobp) (setq done t)) (t (forward-line 1)))) res)) (add-hook 'font-lock-mode-hook (function (lambda () (font-lock-add-keywords nil '((match-at-column-79 0 secondary-selection t)) 'append)))) Hope this helps, Ilya ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Changing Color Of Column # In Modeline 2005-11-22 23:09 ` Ilya Zakharevich @ 2005-11-25 17:55 ` rgb 2005-11-25 18:54 ` Drew Adams 0 siblings, 1 reply; 17+ messages in thread From: rgb @ 2005-11-25 17:55 UTC (permalink / raw) > <rbielaws@i1.net>], who wrote in article <1132680280.003922.155730@g47g2000cwa.googlegroups.com>: > > > Is that possible? Does anyone have a code snippet which does that or > > > something similar? > > > > http://www.emacswiki.org/cgi-bin/wiki/ColumnMarker > > This one looks too restrictive. Some time ago I wrote this: > ... > > Hope this helps, > Ilya I always knew it should be done that way but I never use tabs or multi-column characters so it's been low on my to-do list. Perhaps now I can knock that item off my list. Thanks. ^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: Changing Color Of Column # In Modeline 2005-11-25 17:55 ` rgb @ 2005-11-25 18:54 ` Drew Adams 0 siblings, 0 replies; 17+ messages in thread From: Drew Adams @ 2005-11-25 18:54 UTC (permalink / raw) > > http://www.emacswiki.org/cgi-bin/wiki/ColumnMarker > > This one looks too restrictive. Some time ago I wrote this: > Ilya I always knew it should be done that way but I never use tabs or multi-column characters so it's been low on my to-do list. Perhaps now I can knock that item off my list. Well, "should be done that way" is not so clear, to me. I see different advantages with RGB's code and Ilya's code: - RGB's code lets you easily highlight multiple columns (with different faces), move those columns, and turn their highlighting on/off - Ilya's code treats multiple-column characters such as TAB correctly Of course, Ilya's code might be made more flexible, by wrapping it in commands that provide the advantages of RGB's code. For reference (for those who lost the thread), here is Ilya's code, with a variable substituted for `79', tabs untabified, and `secondary-selection' quoted (so it will also work in Emacs 20): (defvar limit-column 30) (defun match-at-column (end) (let (done c res) (while (and (not done) (< (point) end)) (cond ((< limit-column (current-column)) (forward-line 1)) ((< limit-column (move-to-column (1+ limit-column))) (setq done t res t) (forward-char -1) (re-search-forward ".")) ((eobp) (setq done t)) (t (forward-line 1)))) res)) (add-hook 'font-lock-mode-hook (lambda () (font-lock-add-keywords nil '((match-at-column 0 'secondary-selection t)) 'append))) ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2005-11-27 0:25 UTC | newest] Thread overview: 17+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2005-11-22 1:07 Changing Color Of Column # In Modeline gamename 2005-11-22 6:26 ` M Jared Finder 2005-11-22 17:24 ` rgb 2005-11-22 21:02 ` gamename 2005-11-23 1:21 ` M Jared Finder 2005-11-23 20:32 ` Kevin Rodgers 2005-11-23 21:08 ` Drew Adams [not found] ` <mailman.16497.1132780124.20277.help-gnu-emacs@gnu.org> 2005-11-24 0:20 ` gamename 2005-11-24 6:21 ` Drew Adams [not found] ` <mailman.16559.1132813301.20277.help-gnu-emacs@gnu.org> 2005-11-25 23:03 ` gamename 2005-11-26 0:01 ` Drew Adams 2005-11-26 18:33 ` gamename 2005-11-26 18:53 ` Drew Adams [not found] ` <mailman.16824.1133031197.20277.help-gnu-emacs@gnu.org> 2005-11-27 0:25 ` gamename 2005-11-22 23:09 ` Ilya Zakharevich 2005-11-25 17:55 ` rgb 2005-11-25 18:54 ` Drew Adams
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).