From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "rgb" Newsgroups: gmane.emacs.help Subject: Re: show registered positions Date: 18 Oct 2005 14:08:55 -0700 Organization: http://groups.google.com Message-ID: <1129669735.807199.104800@g47g2000cwa.googlegroups.com> References: <1129662992.056038.316010@f14g2000cwb.googlegroups.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1129669957 11683 80.91.229.2 (18 Oct 2005 21:12:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 18 Oct 2005 21:12:37 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 18 23:12:31 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1ERyj0-0004aJ-QX for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Oct 2005 23:10:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ERyj0-0003eV-82 for geh-help-gnu-emacs@m.gmane.org; Tue, 18 Oct 2005 17:10:22 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 61 Original-NNTP-Posting-Host: 198.74.20.73 Original-X-Trace: posting.google.com 1129669741 9508 127.0.0.1 (18 Oct 2005 21:09:01 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 18 Oct 2005 21:09:01 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g47g2000cwa.googlegroups.com; posting-host=198.74.20.73; posting-account=C7LM4w0AAAD23IRuMuUUJVCLQTuHhTK8 Original-Xref: shelby.stanford.edu gnu.emacs.help:134769 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:30351 Archived-At: 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 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))