* Can header-line track a row in my file?
@ 2002-10-25 19:44 Lee
2002-10-25 21:04 ` Stefan Monnier <foo@acm.com>
0 siblings, 1 reply; 4+ messages in thread
From: Lee @ 2002-10-25 19:44 UTC (permalink / raw)
I have a file in a large table that I have to scroll around in. It
would be nice to hang the first row of the table, which tells me what
is in what column, at the top of the buffer and have it update as I
scroll horizontally through the table.
Seems like the header line (analogous to the mode line) would be
perfect, but I am at a loss as how to set header-line-format to
accomplish this. Any suggestions?
Thanks,
Lee
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can header-line track a row in my file?
2002-10-25 19:44 Can header-line track a row in my file? Lee
@ 2002-10-25 21:04 ` Stefan Monnier <foo@acm.com>
2002-10-27 14:13 ` Lee
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier <foo@acm.com> @ 2002-10-25 21:04 UTC (permalink / raw)
>>>>> "Lee" == Lee <mus5mk2ly001@sneakemail.com> writes:
> I have a file in a large table that I have to scroll around in. It
> would be nice to hang the first row of the table, which tells me what
> is in what column, at the top of the buffer and have it update as I
> scroll horizontally through the table.
Try something like
(set (make-local-variable 'header-line-format)
'(:eval (save-excursion
(goto-char (point))
(move-to-column (window-hscroll))
(buffer-substring (point) (line-end-position)))))
-- Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can header-line track a row in my file?
2002-10-25 21:04 ` Stefan Monnier <foo@acm.com>
@ 2002-10-27 14:13 ` Lee
2002-10-28 20:11 ` Lee
0 siblings, 1 reply; 4+ messages in thread
From: Lee @ 2002-10-27 14:13 UTC (permalink / raw)
"Stefan Monnier <foo@acm.com>" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu> wrote in message news:<5lpttyz0ux.fsf@rum.cs.yale.edu>...
> >>>>> "Lee" == Lee <mus5mk2ly001@sneakemail.com> writes:
> > I have a file in a large table that I have to scroll around in. It
> > would be nice to hang the first row of the table, which tells me what
> > is in what column, at the top of the buffer and have it update as I
> > scroll horizontally through the table.
>
> Try something like
>
> (set (make-local-variable 'header-line-format)
> '(:eval (save-excursion
> (goto-char (point))
> (move-to-column (window-hscroll))
> (buffer-substring (point) (line-end-position)))))
Awesome, thanks! In my case I want to track a particular line, so it would be
(set (make-local-variable 'header-line-format)
'(:eval (save-excursion
(goto-line 18)
(move-to-column (window-hscroll))
(buffer-substring (point) (line-end-position)))))
Thanks again,
Lee
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Can header-line track a row in my file?
2002-10-27 14:13 ` Lee
@ 2002-10-28 20:11 ` Lee
0 siblings, 0 replies; 4+ messages in thread
From: Lee @ 2002-10-28 20:11 UTC (permalink / raw)
And at last, here is the final version (I hope). I found that having
tabs would sometimes offset the header and I have also unhardcoded the
line number. You can just put the cursor on the line you want
displayed in the header and then do M-x my-set-header-line-format:
(defun my-set-header-line-format ()
(interactive)
(set (make-local-variable 'my-line-number)
(save-restriction
(widen)
(save-excursion
(beginning-of-line)
(1+ (count-lines 1 (point))))))
(set (make-local-variable 'header-line-format)
'(" " (:eval
(save-excursion
(goto-line my-line-number)
(move-to-column (window-hscroll))
(untabify (point) (line-end-position))
(buffer-substring (point) (line-end-position)))))))
Lee
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-10-28 20:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-25 19:44 Can header-line track a row in my file? Lee
2002-10-25 21:04 ` Stefan Monnier <foo@acm.com>
2002-10-27 14:13 ` Lee
2002-10-28 20:11 ` Lee
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).