* show registered positions
@ 2005-10-18 12:27 Peter Tury
2005-10-18 19:16 ` rgb
0 siblings, 1 reply; 3+ messages in thread
From: Peter Tury @ 2005-10-18 12:27 UTC (permalink / raw)
Hi,
I see in the manual (GNU Emacs 21.3.1 on Win XP; I may switch to using CVS)
that C-x r <SPC> R saves position of point in register R.
Is it possible somehow easily (=using at most a few elisp lines in .emacs?)
to mark those lines (may be: highlight?) what contain saved positions, e.g.
at the left edge of the buffer? Or at least list all registers what contain
a position?
I mean that in the case I have several saved positions, it would be nice to
see them in (pick them from?) a list; or see them when I am around a
"saved" line...
Thanks in advance,
Peter Tury
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: show registered positions
2005-10-18 12:27 show registered positions Peter Tury
@ 2005-10-18 19:16 ` rgb
2005-10-18 21:08 ` rgb
0 siblings, 1 reply; 3+ messages in thread
From: rgb @ 2005-10-18 19:16 UTC (permalink / raw)
Peter Tury wrote:
> Hi,
>
> I see in the manual (GNU Emacs 21.3.1 on Win XP; I may switch to using CVS)
> that C-x r <SPC> R saves position of point in register R.
>
> Is it possible somehow easily (=using at most a few elisp lines in .emacs?)
> to mark those lines (may be: highlight?) what contain saved positions, e.g.
> at the left edge of the buffer? Or at least list all registers what contain
> a position?
>
> I mean that in the case I have several saved positions, it would be nice to
> see them in (pick them from?) a list; or see them when I am around a
> "saved" line...
There is list-registers and view-registers and the contents of
register-alist are fairly well documented if you use C-h v.
I'm not sure if that helps but I can't remember seeing a package
that acutally marks the locations. You could probably redefine
set-register to add an overlay whenever a point is put into
a register and remove the overlay when the register's value is
changed. It doesn't look like it would be too hard.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: show registered positions
2005-10-18 19:16 ` rgb
@ 2005-10-18 21:08 ` rgb
0 siblings, 0 replies; 3+ messages in thread
From: rgb @ 2005-10-18 21:08 UTC (permalink / raw)
rgb wrote:
> Peter Tury wrote:
> > Hi,
> >
> > I see in the manual (GNU Emacs 21.3.1 on Win XP; I may switch to using CVS)
> > that C-x r <SPC> R saves position of point in register R.
> >
> > Is it possible somehow easily (=using at most a few elisp lines in .emacs?)
> > to mark those lines (may be: highlight?) what contain saved positions, e.g.
> > at the left edge of the buffer? Or at least list all registers what contain
> > a position?
> >
> > I mean that in the case I have several saved positions, it would be nice to
> > see them in (pick them from?) a list; or see them when I am around a
> > "saved" line...
>
> There is list-registers and view-registers and the contents of
> register-alist are fairly well documented if you use C-h v.
>
> I'm not sure if that helps but I can't remember seeing a package
> that acutally marks the locations. You could probably redefine
> set-register to add an overlay whenever a point is put into
> a register and remove the overlay when the register's value is
> changed. It doesn't look like it would be too hard.
I got to thinking how nice it would be to have what you described.
This is a total hack but it seems to do ok. Floating your mouse
over the highlighted character should tell you which register.
I noticed just before posting that markers in files don't
restore the overlay when the file is re-visited. But I never
really re-visit files that way anyhow....
Maybe somebody would like to run with this some more?
(defface register-marker-face '((t (:background "grey")))
"Used to mark register positions in a buffer."
:group 'faces)
;; this redefines (and therefore overrides) the standard function
;; of the same name. Yea, maybe advice would have been better but
;; I was lazy.
(defun set-register (register value)
"Set Emacs register named REGISTER to VALUE. Returns VALUE.
See the documentation of `register-alist' for possible VALUE."
(let ((aelt (assq register register-alist))
(sovl (intern (concat "point-register-overlay-"
(char-to-string register))))
)
(when (not (boundp sovl))
(set sovl (make-overlay (point)(point)))
(overlay-put (symbol-value sovl) 'face 'register-marker-face)
(overlay-put (symbol-value sovl) 'help-echo
(concat "Register: `"
(char-to-string register) "'")))
(delete-overlay (symbol-value sovl))
(if (markerp value)
(move-overlay (symbol-value sovl) value (1+ value)))
(if aelt
(setcdr aelt value)
(push (cons register value) register-alist))
value))
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-10-18 21:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-18 12:27 show registered positions Peter Tury
2005-10-18 19:16 ` rgb
2005-10-18 21:08 ` rgb
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).