unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Mark current column
@ 2005-10-18 12:37 Peter Tury
  2005-10-18 18:59 ` rgb
  2005-10-18 19:45 ` Johan Bockgård
  0 siblings, 2 replies; 8+ messages in thread
From: Peter Tury @ 2005-10-18 12:37 UTC (permalink / raw)


Hi,

I use GNU Emacs 21.3.1 on Win XP (I may switch to using CVS).
I've seen vvb-mode.

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 should work in a "toggle-manner": when I press the same keys on an
already highlighted column, it should be unhighlightied.

vvb-mode can highlight the column of a given number; I would like to add a
little more "intelligence": determine the number of the current column
(from current pos), then highlight it. -- I don't stick to vvb-mode...

Thanks in advance,
P

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

* Re: Mark current column
  2005-10-18 12:37 Mark current column Peter Tury
@ 2005-10-18 18:59 ` rgb
  2005-11-02 11:21   ` Peter Tury
  2005-10-18 19:45 ` Johan Bockgård
  1 sibling, 1 reply; 8+ messages in thread
From: rgb @ 2005-10-18 18:59 UTC (permalink / raw)


> 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)

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

* Re: Mark current column
  2005-10-18 12:37 Mark current column Peter Tury
  2005-10-18 18:59 ` rgb
@ 2005-10-18 19:45 ` Johan Bockgård
  2005-11-02 11:27   ` Peter Tury
  1 sibling, 1 reply; 8+ messages in thread
From: Johan Bockgård @ 2005-10-18 19:45 UTC (permalink / raw)


Peter Tury <tury.peter@gmail.com> writes:

> vvb-mode can highlight the column of a given number; I would like to
> add a little more "intelligence": determine the number of the
> current column (from current pos), then highlight it.

`vvb-sticky-p':

  non-nil makes the vertical bar sticky to, ie, following the `point',
  in which case `vvb-column' & `vvb-right-on-eol-p' have no effect.

-- 
Johan Bockgård

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

* Re: Mark current column
  2005-10-18 18:59 ` rgb
@ 2005-11-02 11:21   ` Peter Tury
  2005-11-02 17:07     ` rgb
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Tury @ 2005-11-02 11:21 UTC (permalink / raw)


On 18 Oct 2005 11:59:53 -0700, rgb wrote:

>> 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.

Thanks! I can't see these things on your wiki, but I started to use your
column-marker posted here. It makes almost exactly what I wanted. (Though I
can't mark several lines at the same time (what would be good) + I can't
see the marker in shorter lines, however it would also be good.)

Anyway: thanks a lot!

P

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

* Re: Mark current column
  2005-10-18 19:45 ` Johan Bockgård
@ 2005-11-02 11:27   ` Peter Tury
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Tury @ 2005-11-02 11:27 UTC (permalink / raw)


On Tue, 18 Oct 2005 21:45:24 +0200, Johan Bockgård wrote:

> Peter Tury <tury.peter@gmail.com> writes:
> 
>> vvb-mode can highlight the column of a given number; I would like to
>> add a little more "intelligence": determine the number of the
>> current column (from current pos), then highlight it.
> 
> `vvb-sticky-p':
> 
>   non-nil makes the vertical bar sticky to, ie, following the `point',
>   in which case `vvb-column' & `vvb-right-on-eol-p' have no effect.

Hi,

thanks!

In fact vvb-sticky-p doesn't do what I wanted: it moves the marker with the
point, while I need a permanent marker "sticked" at the fixed position
where the point was when I pressed C-c ...

However vvb-mode can be good, but I think I should add a new function to
it. Someting like "add the pos of the point to vvb-columns + set
vvb-permanent-p to t"... 

Br,
P

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

* Re: Mark current column
  2005-11-02 11:21   ` Peter Tury
@ 2005-11-02 17:07     ` rgb
  2005-11-02 19:57       ` Peter Tury
  0 siblings, 1 reply; 8+ messages in thread
From: rgb @ 2005-11-02 17:07 UTC (permalink / raw)


> >> 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.
>
> Thanks! I can't see these things on your wiki, but I started to use your
> column-marker posted here. It makes almost exactly what I wanted. (Though I
> can't mark several lines at the same time (what would be good)

The version on the wiki lets you define as many markers as you want.
For example:

(require 'column-marker)
(column-marker-create-dynamic my-other-marker)

The new marker is named my-other-marker and works the same as
column-marker-here.

> + I can't
> see the marker in shorter lines, however it would also be good.)

I think lots of people would like that, including me.
If you pad all the shorter lines with blanks it makes the marker
visible.  Maybe not a great solution but sometimes its viable.

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

* Re: Mark current column
  2005-11-02 17:07     ` rgb
@ 2005-11-02 19:57       ` Peter Tury
  2005-11-03  8:48         ` Peter Tury
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Tury @ 2005-11-02 19:57 UTC (permalink / raw)


On 2 Nov 2005 09:07:46 -0800, rgb wrote:

>>>> 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.
>>
>> Thanks! I can't see these things on your wiki, but I started to use your
>> column-marker posted here. It makes almost exactly what I wanted. (Though I
>> can't mark several lines at the same time (what would be good)
> 
> The version on the wiki lets you define as many markers as you want.
> For example:
> 
> (require 'column-marker)
> (column-marker-create-dynamic my-other-marker)
> 
> The new marker is named my-other-marker and works the same as
> column-marker-here.

Finally I find it in the wiki ;-) Thanks for it!

However, as I would like to learn elisp, I tried to understand it and
compare to my original needs. It seemed to be a little cryptic for me (as I
am a beginner in elisp), and I think it is not exactly what I imagined. So
I tried to create another solution. Here it is (as in my .emacs):

(defun vvb-toggle-curr-in-columns ()
   "Toggles the current column inside vvb-columns."
   (interactive)
   (if (member (current-column) vvb-columns)
       (setq vvb-columns (remove (current-column) vvb-columns))
     (setq vvb-columns (append vvb-columns (list (current-column))))))
(global-set-key [?\C-c ?l] 'vvb-toggle-curr-in-columns)

And this is what I wanted. However, unfortunately, it needs vvb-mode :-(

> 
>> + I can't
>> see the marker in shorter lines, however it would also be good.)
> 
> I think lots of people would like that, including me.
> If you pad all the shorter lines with blanks it makes the marker
> visible.  Maybe not a great solution but sometimes its viable.

Isn't it possible to highlight the "columns" somehow differently: not using
background colors for existing chars, but ... ?? E.g. put a "layer" (as in
some picture editor programs?) "onto" the original text, and highlight the
positions in this "layer"...?

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

* Re: Mark current column
  2005-11-02 19:57       ` Peter Tury
@ 2005-11-03  8:48         ` Peter Tury
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Tury @ 2005-11-03  8:48 UTC (permalink / raw)


On Wed, 02 Nov 2005 19:57:34 GMT, Peter Tury wrote:

> I tried to create another solution. Here it is (as in my .emacs):
> 
> (defun vvb-toggle-curr-in-columns ()
>    "Toggles the current column inside vvb-columns."
>    (interactive)
>    (if (member (current-column) vvb-columns)
>        (setq vvb-columns (remove (current-column) vvb-columns))
>      (setq vvb-columns (append vvb-columns (list (current-column))))))
> (global-set-key [?\C-c ?l] 'vvb-toggle-curr-in-columns)
> 
> And this is what I wanted. However, unfortunately, it needs vvb-mode :-(

Finally I found (almost) the same functionality in vvb-mode as
vvb-set-column =:-o

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

end of thread, other threads:[~2005-11-03  8:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-18 12:37 Mark current column Peter Tury
2005-10-18 18:59 ` rgb
2005-11-02 11:21   ` Peter Tury
2005-11-02 17:07     ` rgb
2005-11-02 19:57       ` Peter Tury
2005-11-03  8:48         ` Peter Tury
2005-10-18 19:45 ` Johan Bockgård
2005-11-02 11:27   ` Peter Tury

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).