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

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

Re: Mark current column


From: rgb
Subject: Re: Mark current column
Date: 18 Oct 2005 11:59:53 -0700
User-agent: G2/0.2

> Is it possible somehow easily (=using at most a few elisp lines in .emacs?)
> to highlight the current column (in all the (visible) lines of the current
> buffer) by a (custom)key sequence?

This is a piece of a bigger package I've been putting together.
Maybe I'll get this part polished up and posted to the wiki
sometime later this week.  Meanwhile you can either dump all
the code into your .emacs or put it in a file named
column-marker.el somewhere on your search path and then
add something like this to your .emacs.

(require 'column-marker)
(global-set-key [?\C-c ?m] 'column-marker-here)

You may want to change the color.
I use something close to the gnome2 color theme.

;; Author: Rick Bielawski <rbielaws@i1.net> (c) 2005

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published
;; by the Free Software Foundation; either version 2.

;; This file is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.

(defvar column-marker-face 'column-marker-face)
(defface column-marker-face '((t (:background "sea green")))
  "Face used to create a column marker"
  :group 'faces)

(defvar column-marker nil
  "Holds font-lock-keyword spec for column marker")
(make-variable-buffer-local 'column-marker)

(defun column-marker-here ()
  (interactive)
  (if column-marker
      (progn (font-lock-remove-keywords nil column-marker)
             (setq column-marker nil))
    (setq column-marker
          (list (list (concat "^.\\{" (number-to-string
                                       (current-column))
                              "\\}\\(.\\)")
                      '(1 column-marker-face prepend t))))
    (font-lock-add-keywords nil column-marker t))
  (font-lock-fontify-buffer))

(provide 'column-marker)



reply via email to

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