all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Miles Bader <miles@gnu.org>
Subject: Re: can I move back to the last edit position?
Date: Sat, 11 Sep 2004 09:19:12 +0900	[thread overview]
Message-ID: <87d60tpshr.fsf@tc-1-100.kawasaki.gol.ne.jp> (raw)
In-Reply-To: r3pshc.66.ln@acm.acm

Alan Mackenzie <acm@muc.de> writes:
> Because Rokia doesn't know until he's already left this position that he
> wants to jump back.  And having to type `C-x r <SPC> R' after every editing
> action is a little irritating, to put it mildly.
>
> It is essential here for the position to be saved automatically.

I'll note that one method I often use to do this is something like:

   C-/ C-e C-/

That is, `undo' (which moves point to the location of the undo edit), a
random movement command to interrupt the undo, and then `undo' again to
reverse the effect of my first undo.

This works pretty well, but of course is a bit weird, and potentially
dangerous (if something happens to interrupt you before you redo the
change).

However, it does suggest a possible implementation for a
`goto-last-edit' command:  just look at the buffer-undo-list variable,
and jump to the first insert/deletion position you find.

Maybe something like this:

   (defun goto-last-edit ()
     "Set point to the location of the last insert or delete in the buffer.
   Uses buffer undo information, so won't work if undo is disabled."
     (interactive)
     (let ((undo-records buffer-undo-list)
           (pos nil))
       (while (and (consp undo-records) (not pos))
         (let ((undo (pop undo-records)))
           (when (and (consp undo) 
                 (or (stringp (car undo)) (integerp (car undo))))
             (setq pos (cdr undo)))))
       (if pos
           (goto-char pos)
         (error "No edits in undo list"))))

-Miles
-- 
(\(\
(^.^)
(")")
*This is the cute bunny virus, please copy this into your sig so it can spread.

  reply	other threads:[~2004-09-11  0:19 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-10  7:16 can I move back to the last edit position? Rokia
2004-09-10  7:38 ` Miguel Frasson
2004-09-10  8:46   ` Rokia
2004-09-10  9:07     ` Eli Zaretskii
2004-09-10  7:46 ` Mathias Dahl
2004-09-10  8:29 ` Pascal Bourguignon
2004-09-10  8:49   ` Rokia
2004-09-10 12:53     ` Micha Feigin
     [not found]     ` <mailman.2285.1094821218.1998.help-gnu-emacs@gnu.org>
2004-09-10 17:43       ` Alan Mackenzie
2004-09-11  0:19         ` Miles Bader [this message]
2004-09-11  0:21         ` Oliver Scholz
2004-09-13  8:55           ` Mathias Dahl
2004-10-05  5:12       ` David Combs
2004-09-10 11:49 ` zrr
2004-09-10 13:16 ` Peter Boettcher
2004-09-11  0:20   ` Bob Babcock
2004-09-11 20:05     ` Harry Putnam
2004-09-11 20:09       ` Harry Putnam
     [not found]       ` <mailman.2411.1094934412.1998.help-gnu-emacs@gnu.org>
2005-03-16  2:03         ` david.andersson
     [not found]     ` <mailman.2409.1094933538.1998.help-gnu-emacs@gnu.org>
2004-09-12  5:06       ` rokia
2004-09-12 15:28         ` Peter J. Acklam
2004-09-12 16:45           ` Rokia
2004-09-13 16:13           ` Stefan Monnier
2004-09-12 21:46         ` Bob Babcock
2004-09-11  3:58   ` rokia

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

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

  git send-email \
    --in-reply-to=87d60tpshr.fsf@tc-1-100.kawasaki.gol.ne.jp \
    --to=miles@gnu.org \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.