unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "rgb" <rbielaws@i1.net>
Subject: Re: show registered positions
Date: 18 Oct 2005 14:08:55 -0700	[thread overview]
Message-ID: <1129669735.807199.104800@g47g2000cwa.googlegroups.com> (raw)
In-Reply-To: 1129662992.056038.316010@f14g2000cwb.googlegroups.com

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

      reply	other threads:[~2005-10-18 21:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-18 12:27 show registered positions Peter Tury
2005-10-18 19:16 ` rgb
2005-10-18 21:08   ` rgb [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1129669735.807199.104800@g47g2000cwa.googlegroups.com \
    --to=rbielaws@i1.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).