* can I move back to the last edit position?
@ 2004-09-10 7:16 Rokia
2004-09-10 7:38 ` Miguel Frasson
` (4 more replies)
0 siblings, 5 replies; 25+ messages in thread
From: Rokia @ 2004-09-10 7:16 UTC (permalink / raw)
after I move to other position, how can I move back?
I believe this must have been realized. :D
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
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 7:46 ` Mathias Dahl
` (3 subsequent siblings)
4 siblings, 1 reply; 25+ messages in thread
From: Miguel Frasson @ 2004-09-10 7:38 UTC (permalink / raw)
Rokia <Rokia@yahoo.com.cn.discuss> writes:
> after I move to other position, how can I move back?
>
> I believe this must have been realized. :D
Try to use bookmarks. See the edit menu. I use them very often to keep
the eye in several parts of a document.
Miguel
--
Miguel Vinicius Santini Frasson
http://www.math.leidenuniv.nl/~frasson
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
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 7:46 ` Mathias Dahl
2004-09-10 8:29 ` Pascal Bourguignon
` (2 subsequent siblings)
4 siblings, 0 replies; 25+ messages in thread
From: Mathias Dahl @ 2004-09-10 7:46 UTC (permalink / raw)
Rokia <Rokia@yahoo.com.cn.discuss> writes:
> after I move to other position, how can I move back?
It depends. If you have made an edit, and the mark has been
set, you can navigate to the previous mark in the mark-ring
by using C-u C-SPC.
/Mathias
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
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 7:46 ` Mathias Dahl
@ 2004-09-10 8:29 ` Pascal Bourguignon
2004-09-10 8:49 ` Rokia
2004-09-10 11:49 ` zrr
2004-09-10 13:16 ` Peter Boettcher
4 siblings, 1 reply; 25+ messages in thread
From: Pascal Bourguignon @ 2004-09-10 8:29 UTC (permalink / raw)
Rokia <Rokia@yahoo.com.cn.discuss> writes:
> after I move to other position, how can I move back?
>
> I believe this must have been realized. :D
Good question. When I need that, I just undo the last edit with C-x u
So I guess the last edit position could be found in buffer-undo-list
--
__Pascal Bourguignon__ http://www.informatimago.com/
Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
2004-09-10 7:38 ` Miguel Frasson
@ 2004-09-10 8:46 ` Rokia
2004-09-10 9:07 ` Eli Zaretskii
0 siblings, 1 reply; 25+ messages in thread
From: Rokia @ 2004-09-10 8:46 UTC (permalink / raw)
:)
it seems that no one know how to do this. except some inconvenient
methods such as bookmark.
I want to one command to do this.
:( where is it?
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
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>
0 siblings, 2 replies; 25+ messages in thread
From: Rokia @ 2004-09-10 8:49 UTC (permalink / raw)
:)
I think this is a necessary and basic function. why cant I find it?
:(
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
2004-09-10 8:46 ` Rokia
@ 2004-09-10 9:07 ` Eli Zaretskii
0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2004-09-10 9:07 UTC (permalink / raw)
> From: Rokia <Rokia@yahoo.com.cn.discuss>
> Date: Fri, 10 Sep 2004 16:46:40 +0800
>
> it seems that no one know how to do this. except some inconvenient
> methods such as bookmark.
>
> I want to one command to do this.
>
> :( where is it?
There's more than one way to do that in Emacs, depending on the
situation. Please describe in more detail what do you mean by ``move
back to the last edit position''. How much did you move from that
last position, and how (using what command) did you do that?
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
2004-09-10 7:16 can I move back to the last edit position? Rokia
` (2 preceding siblings ...)
2004-09-10 8:29 ` Pascal Bourguignon
@ 2004-09-10 11:49 ` zrr
2004-09-10 13:16 ` Peter Boettcher
4 siblings, 0 replies; 25+ messages in thread
From: zrr @ 2004-09-10 11:49 UTC (permalink / raw)
Rokia <Rokia@yahoo.com.cn.discuss> writes:
C-h f point-to-register
Never doubt about emacs's ability.
> after I move to other position, how can I move back?
>
> I believe this must have been realized. :D
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
2004-09-10 8:49 ` Rokia
@ 2004-09-10 12:53 ` Micha Feigin
[not found] ` <mailman.2285.1094821218.1998.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 25+ messages in thread
From: Micha Feigin @ 2004-09-10 12:53 UTC (permalink / raw)
On Fri, Sep 10, 2004 at 04:49:03PM +0800, Rokia wrote:
> :)
>
> I think this is a necessary and basic function. why cant I find it?
>
What about saving position in register
`C-x r <SPC> R'
Save position of point in register R (`point-to-register').
`C-x r j R'
Jump to the position saved in register R (`jump-to-register').
Or jump to mark
C-u C-spc
Exchange point and mark
C-x C-x
And to truncate the mark ring
M-x marker-visit-truncate-mark-ring
> :(
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
>
> +++++++++++++++++++++++++++++++++++++++++++
> This Mail Was Scanned By Mail-seCure System
> at the Tel-Aviv University CC.
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
2004-09-10 7:16 can I move back to the last edit position? Rokia
` (3 preceding siblings ...)
2004-09-10 11:49 ` zrr
@ 2004-09-10 13:16 ` Peter Boettcher
2004-09-11 0:20 ` Bob Babcock
2004-09-11 3:58 ` rokia
4 siblings, 2 replies; 25+ messages in thread
From: Peter Boettcher @ 2004-09-10 13:16 UTC (permalink / raw)
Rokia <Rokia@yahoo.com.cn.discuss> writes:
> after I move to other position, how can I move back?
>
> I believe this must have been realized. :D
I use a function written by David Andersson called goto-chg. It steps
back through the undo list to find the last position of changed text.
Try that.
http://groups.google.com/groups?q=goto-chg.el&hl=en&lr=&ie=UTF-8&selm=wun0uyustv.fsf%40symsoft.se&rnum=1
-Peter
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
[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
2004-09-11 0:21 ` Oliver Scholz
2004-10-05 5:12 ` David Combs
1 sibling, 2 replies; 25+ messages in thread
From: Alan Mackenzie @ 2004-09-10 17:43 UTC (permalink / raw)
Micha Feigin <michf@post.tau.ac.il> wrote on Fri, 10 Sep 2004 15:53:43 +0300:
> On Fri, Sep 10, 2004 at 04:49:03PM +0800, Rokia wrote:
>> I think this [moving back to the position of the last edit] is a necessary
>> and basic function. why cant I find it?
I tend to agree, but I've managed to get along without it for some years.
You can't find it because it doesn't exist in Emacs.
> What about saving position in register
> `C-x r <SPC> R'
> Save position of point in register R (`point-to-register').
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.
--
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
2004-09-10 17:43 ` Alan Mackenzie
@ 2004-09-11 0:19 ` Miles Bader
2004-09-11 0:21 ` Oliver Scholz
1 sibling, 0 replies; 25+ messages in thread
From: Miles Bader @ 2004-09-11 0:19 UTC (permalink / raw)
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.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
2004-09-10 13:16 ` Peter Boettcher
@ 2004-09-11 0:20 ` Bob Babcock
2004-09-11 20:05 ` Harry Putnam
[not found] ` <mailman.2409.1094933538.1998.help-gnu-emacs@gnu.org>
2004-09-11 3:58 ` rokia
1 sibling, 2 replies; 25+ messages in thread
From: Bob Babcock @ 2004-09-11 0:20 UTC (permalink / raw)
Peter Boettcher <boettcher@ll.mit.edu> wrote in
news:m3isamxo11.fsf@coyote.llan.ll.mit.edu:
> I use a function written by David Andersson called goto-chg. It steps
> back through the undo list to find the last position of changed text.
> Try that.
>
> http://groups.google.com/groups?q=goto-chg.el&hl=en&lr=&ie=UTF-8&selm=w
> un0uyustv.fsf%40symsoft.se&rnum=1
Thanks. I wasn't the original poster, but I've wanted the same thing.
Goto-chg looks like it does exactly what was requested.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
2004-09-10 17:43 ` Alan Mackenzie
2004-09-11 0:19 ` Miles Bader
@ 2004-09-11 0:21 ` Oliver Scholz
2004-09-13 8:55 ` Mathias Dahl
1 sibling, 1 reply; 25+ messages in thread
From: Oliver Scholz @ 2004-09-11 0:21 UTC (permalink / raw)
Alan Mackenzie <acm@muc.de> writes:
> Micha Feigin <michf@post.tau.ac.il> wrote on Fri, 10 Sep 2004 15:53:43 +0300:
>> On Fri, Sep 10, 2004 at 04:49:03PM +0800, Rokia wrote:
>
>>> I think this [moving back to the position of the last edit] is a necessary
>>> and basic function. why cant I find it?
>
> I tend to agree, but I've managed to get along without it for some years.
> You can't find it because it doesn't exist in Emacs.
[...]
I think Eli was right to ask for more details here. For instance,
Emacs does store the current position of point to the global mark ring
in some circumstances. So you can jump back to the position of point
before you issued the command that moved it by hitting `C-u C-SPC' --
depending on the command. That doesn't work for C-n, C-p etc. (I
hardly see how that would be useful), but it does work for M-<,
M-C-a, C-s ...
Oliver
--
26 Fructidor an 212 de la Révolution
Liberté, Egalité, Fraternité!
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
2004-09-10 13:16 ` Peter Boettcher
2004-09-11 0:20 ` Bob Babcock
@ 2004-09-11 3:58 ` rokia
1 sibling, 0 replies; 25+ messages in thread
From: rokia @ 2004-09-11 3:58 UTC (permalink / raw)
Faint, I cant visit this page. perhaps it was banned by the goverment!
Faint again.
Would you please send it to me?
rokiadd@yahoo.com.cn
thanks a lot.
--
对一部分人来说,Emacs 是一种生活方式,就像宗教信仰和足球一样。
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
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>
[not found] ` <mailman.2409.1094933538.1998.help-gnu-emacs@gnu.org>
1 sibling, 2 replies; 25+ messages in thread
From: Harry Putnam @ 2004-09-11 20:05 UTC (permalink / raw)
Bob Babcock <wssddc@nospam.gis.net> writes:
> Peter Boettcher <boettcher@ll.mit.edu> wrote in
> news:m3isamxo11.fsf@coyote.llan.ll.mit.edu:
>
>> I use a function written by David Andersson called goto-chg. It steps
>> back through the undo list to find the last position of changed text.
>> Try that.
>>
>> http://groups.google.com/groups?q=goto-chg.el&hl=en&lr=&ie=UTF-8&selm=w
>> un0uyustv.fsf%40symsoft.se&rnum=1
>
> Thanks. I wasn't the original poster, but I've wanted the same thing.
> Goto-chg looks like it does exactly what was requested.
I wasn't either but it got my attention to.. However goto-chg.el doesn't
do much for me.
M-x load-library <goto-chg><RET>
Then open a file and make a series of three changes, move cursor
several lines past last change.
M-x goto-chg <RET> move me to last change
M-x goto-chg <RET> does nothing further.
Looking at the comments, it says its supposed to be able to go further
back with repeated usage of cmd.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
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>
1 sibling, 0 replies; 25+ messages in thread
From: Harry Putnam @ 2004-09-11 20:09 UTC (permalink / raw)
Harry Putnam <reader@newsguy.com> writes:
>
> M-x goto-chg <RET> move me to last change
> M-x goto-chg <RET> does nothing further.
Typo mania .... should be M-x goto-last-change
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
[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 21:46 ` Bob Babcock
0 siblings, 2 replies; 25+ messages in thread
From: rokia @ 2004-09-12 5:06 UTC (permalink / raw)
hi, can you send the goto-chg.el to me?
I cant find it. :) thanks!!
--
世界上有三种人,一种使用 Emacs,一种使用 vi, 另一种包括其他所有人。
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
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
1 sibling, 2 replies; 25+ messages in thread
From: Peter J. Acklam @ 2004-09-12 15:28 UTC (permalink / raw)
rokia <Rokia@batbug.org> wrote:
> hi, can you send the goto-chg.el to me?
> I cant find it. :) thanks!!
What did *you* find at the end of the link, if not goto-chg.el? :-)
Peter
--
Peter J. Acklam - pjacklam@online.no - http://home.online.no/~pjacklam
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
2004-09-12 15:28 ` Peter J. Acklam
@ 2004-09-12 16:45 ` Rokia
2004-09-13 16:13 ` Stefan Monnier
1 sibling, 0 replies; 25+ messages in thread
From: Rokia @ 2004-09-12 16:45 UTC (permalink / raw)
it is the page of "cannot show this page." :(
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
2004-09-12 5:06 ` rokia
2004-09-12 15:28 ` Peter J. Acklam
@ 2004-09-12 21:46 ` Bob Babcock
1 sibling, 0 replies; 25+ messages in thread
From: Bob Babcock @ 2004-09-12 21:46 UTC (permalink / raw)
rokia <Rokia@batbug.org> wrote in news:ufz5oaxes.fsf@batbug.org:
> hi, can you send the goto-chg.el to me?
> I cant find it. :) thanks!!
It's at
http://groups.google.com/groups?q=goto-chg.el&hl=en&lr=&ie=UTF-8&selm=wun0uyustv.fsf%40symsoft.se&rnum=1
I think it's short enough to post in a text group, so here it is.
I hope it doesn't get broken by any line wrapping:
;;; goto-chg.el --- goto last change
;;--------------------------------------------------------------------
;;
;; Copyright (C) 2002, David Andersson <david@symsoft.se>
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2 of
;; the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be
;; useful, but WITHOUT ANY WARRANTY; without even the implied
;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
;; PURPOSE. See the GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public
;; License along with this program; if not, write to the Free
;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
;; MA 02111-1307 USA
;;
;;-------------------------------------------------------------------
;;
;; Author: David Andersson <david@symsoft.se>
;; Created: 16 May 2002
;; Version: 1.0
;;
;;; Commentary:
;;
;; Goto Last Change
;;
;; Goto the point of the most recent edit in the buffer.
;; Goto the second next edit, etc, when repeated.
;; Works by looking into buffer-undo-list to find points of change.
;;
;; You would probably like to bind it to a key, for example:
;; (global-set-key [kp-decimal] 'goto-last-change)
;;
;; Works with emacs-19.29, 19.31, 20.7 and XEmacs-20.4.
;;
;;--------------------------------------------------------------------
;;
;;todo: rename file to "gotochange.el" or "goto-chgs" ?
;;todo: rename goto-last-change -> goto-last-edit ?
;;todo: rename adjective "-last-" -> "-latest-" or "-most-recent-" ?
;;todo: there are some new, maybe useful, funcs in simple.el in emacs 20,
;; for region undo. take a look.
;;todo: add functionality to visit changed point in text order, not only
;; in backward cronological order. (naa, highlight-changes-mode does that).
;;todo: invers indication that a change has been saved or not
;;todo: rename glc-wm-default to glc-wm or something
;;todo: merge glc-wm-default and glc-wm-current, 'let' can change it temporarly
;;todo: highlight the range of text involved in the last cange?
;;
;;--------------------------------------------------------------------
;;; Code:
(defvar glc-wm-default 8 "*goto-last-change don't visit the same point twice. glc-wm-default tells how far around a visited point not to visit again.")
(defvar glc-wm-current 8 "Internal for goto-last-change.\nA copy of glc-wm-default or the ARG passed to goto-last-change.")
(defvar glc-probe-depth 0 "Internal for goto-last-change.\nIt is non-zero between successive goto-last-change.")
;;todo: find begin and end of line, then use it somewhere
;(defun glc-get-surrounding (pos)
; (cons (- pos glc-wm-current) (+ pos glc-wm-current)))
(defun glc-adjust-pos (pos e)
"Given POS, a buffer position before the edit E, compute and return
the \"same\" buffer position after E happend.
Exception: return nil if POS is closer than `glc-wm-current' to the edit E.
\nInsertion edits before POS returns a larger value.
Deletion edits before POS returns a smaller value.
\nThe edit E is an entry from the `buffer-undo-list'. See for details."
(cond ((atom e) ; nil==cmd boundary, or, num==changed pos
pos)
((numberp (car e)) ; (beg . end)==insertion
(cond ((< pos (- (car e) glc-wm-current)) pos)
((> pos (+ (car e) glc-wm-current)) (+ pos (- (cdr e) (car e))))
(t nil)))
((stringp (car e)) ; (string . pos)==deletion
(cond ((< pos (- (abs (cdr e)) glc-wm-current)) pos)
((> pos (+ (abs (cdr e)) (length (car e)) glc-wm-current)) (- pos (length (car e))))
(t nil)))
((null (car e)) ; (nil prop val beg . end)==prop change
(cond ((< pos (- (nth 3 e) glc-wm-current)) pos)
((> pos (+ (nthcdr 4 e) glc-wm-current)) pos)
(t nil)))
(t ; (marker . dist)==marker moved
pos)))
;; If recursive in stead of while-loopive, it tends to fill the call stack.
;; Isn't it tail optimized?
(defun glc-adjust-list (r)
"R is list of edit entries in chronological order.
Pick the point of the first edit entry and update that point with
the second, third, etc, edit entries. Return the final updated point,
or nil if the point was closer than `glc-wm-current' to some edit in R.
\nR is basically a reversed slice from the buffer-undo-list."
(if r
;; Get pos
(let ((pos (glc-get-pos (car r))))
(setq r (cdr r))
;; Walk back in reverse list
(while (and r pos)
(setq pos (glc-adjust-pos pos (car r)))
(setq r (cdr r)))
pos)
;;else
nil))
(defun glc-get-pos (e)
"If E represents an edit, return a position value in E, the position
where the edit took place. Return nil if E repesents no real change.
\nE is a entry in the buffer-undo-list."
(cond ((numberp e) e) ; num==changed position
((atom e) nil) ; nil==command boundary
((numberp (car e)) (cdr e)) ; (beg . end)==insertion
((stringp (car e)) (abs (cdr e))) ; (string . pos)==deletion
((null (car e)) (nthcdr 4 e)) ; (nil ...)==text property change
((atom (car e)) nil) ; (t ...)==file modification time
(t nil))) ; (marker ...)==marker moved
(defun glc-is-positionable (e)
(and (not (numberp e)) (glc-get-pos e)))
(defun glc-is-filetime (e)
"Return t if E indicates a buffer became \"modified\",
that is, it was previously saved or unchanged. Nil otherwise."
(and (listp e) (eq (car e) t)))
(defun goto-last-change (arg)
"Go to the point where the last edit was made in the current buffer.
Repeat the command to go to the second last edit, etc.
\nIt does not go to the same point twice even if there has been many edits
in the same place.
You can set variable `glc-wm-default' to control how close is \"the same point\".
Default is 8. If ARG is non-nil it is used instead.
\nThis function uses undo information. If undo is disabled, so is this."
(interactive "P")
(cond ((not (eq this-command last-command))
(setq glc-probe-depth 0)
(setq glc-wm-current glc-wm-default)))
(cond ((null buffer-undo-list)
(error "Buffer has not been changed"))
((eq buffer-undo-list 't)
(error "No change info (undo is disabled)")))
(if (numberp arg)
(setq glc-wm-current arg))
(let (rev
pos
(n 0)
(l buffer-undo-list)
(passed-save-entry (not (buffer-modified-p))))
;; Walk back and forth in the buffer-undo-list, each time one step deeper,
;; until we can walk back the whole list with a 'pos' taht is not coming
;; close to another edit.
(while (null pos)
(setq glc-probe-depth (1+ glc-probe-depth))
(if (> n 150)
(message "working..."))
;; Walk forward in buffer-undo-list, glc-probe-depth steps.
;; Build reverse list along the way
(while (< n glc-probe-depth)
(cond ((null l)
(setq glc-probe-depth 0)
(error "No further change info"))
((glc-is-positionable (car l))
(setq n (1+ n))
(setq rev (cons (car l) rev)))
((or passed-save-entry (glc-is-filetime (car l)))
(setq passed-save-entry t)))
(setq l (cdr l)))
;; Walk back in reverse list, from older to newer edits.
;; Adjusting pos along the way.
(setq pos (glc-adjust-list rev)))
;; Found a place not previously visited, in 'pos'.
(if (> n 150)
(message "")) ; remove message "working..."
(if passed-save-entry
(message "(This change is saved)"))
(goto-char pos)))
(provide 'goto-chg)
;;; goto-chg.el ends here
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
2004-09-11 0:21 ` Oliver Scholz
@ 2004-09-13 8:55 ` Mathias Dahl
0 siblings, 0 replies; 25+ messages in thread
From: Mathias Dahl @ 2004-09-13 8:55 UTC (permalink / raw)
Oliver Scholz <alkibiades@gmx.de> writes:
> > Micha Feigin <michf@post.tau.ac.il> wrote on Fri, 10 Sep 2004 15:53:43 +0300:
> >> On Fri, Sep 10, 2004 at 04:49:03PM +0800, Rokia wrote:
> >
> >>> I think this [moving back to the position of the last edit] is a necessary
> >>> and basic function. why cant I find it?
> >
> > I tend to agree, but I've managed to get along without it for some years.
> > You can't find it because it doesn't exist in Emacs.
> [...]
>
> I think Eli was right to ask for more details here. For instance,
> Emacs does store the current position of point to the global mark ring
> in some circumstances. So you can jump back to the position of point
> before you issued the command that moved it by hitting `C-u C-SPC' --
> depending on the command. That doesn't work for C-n, C-p etc. (I
> hardly see how that would be useful), but it does work for M-<,
> M-C-a, C-s ...
For a newcomer in Emacs, it is very easy to press the
"wrong" keystrokes and end up in some place in a buffer you
did not intend to go to, I have been there myself but do not
have this problem much nowadays.
Anyway, in the book "Writing GNU Emacs Extensions" is a interesting
idea to solve the
I-navigated-ten-lightyears-by-mistake-and-don't-know-how-to-get-back
problem by using advices on all, or most, functions that move point.
If two or more functions adviced as a "move-point-function" was hit in
a row, we would store the position all the time, so that, when you
panic because you jumped somewhere you did not intend to, you could
call the "take-me-back-please" function.
The concept is fairly easy, the "only" way we need to do is to define
which these functions are. I think I have some code some place
regarding this. If I found it I will post it here.
/Mathias
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
2004-09-12 15:28 ` Peter J. Acklam
2004-09-12 16:45 ` Rokia
@ 2004-09-13 16:13 ` Stefan Monnier
1 sibling, 0 replies; 25+ messages in thread
From: Stefan Monnier @ 2004-09-13 16:13 UTC (permalink / raw)
>> hi, can you send the goto-chg.el to me?
>> I cant find it. :) thanks!!
BTW, a cheap way to get a similar effect is to call `undo' (via C-x u
or C-_ or ...). Additionally to bringing you to the last edit position, it
also undoes that last edit, but a C-f followed by another undo will
redo this undone change.
Stefan
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
[not found] ` <mailman.2285.1094821218.1998.help-gnu-emacs@gnu.org>
2004-09-10 17:43 ` Alan Mackenzie
@ 2004-10-05 5:12 ` David Combs
1 sibling, 0 replies; 25+ messages in thread
From: David Combs @ 2004-10-05 5:12 UTC (permalink / raw)
In article <mailman.2285.1094821218.1998.help-gnu-emacs@gnu.org>,
Micha Feigin <michf@post.tau.ac.il> wrote:
>On Fri, Sep 10, 2004 at 04:49:03PM +0800, Rokia wrote:
>> :)
>>
>> I think this is a necessary and basic function. why cant I find it?
SNIP
>
>And to truncate the mark ring
>M-x marker-visit-truncate-mark-ring
>
I try C-h f on that marker-visit-... thing,
and no can find. (emacs 21.2.1)
Spelled right?
Thanks,
David
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: can I move back to the last edit position?
[not found] ` <mailman.2411.1094934412.1998.help-gnu-emacs@gnu.org>
@ 2005-03-16 2:03 ` david.andersson
0 siblings, 0 replies; 25+ messages in thread
From: david.andersson @ 2005-03-16 2:03 UTC (permalink / raw)
Harry Putnam wrote:
> > M-x goto-chg <RET> move me to last change
> > M-x goto-chg <RET> does nothing further.
>
> Typo mania .... should be M-x goto-last-change
You must bind the command to a key for repetition to go further.
E.g. (global-set-key [kp-decimal] 'goto-last-change)
where kp-decimal may be (control ?.) or f8 or what you like.
(In "M-x goto-last-change <RET>" the <RET> counts as another command
that breaks the sequence. Just like "M-x undo <RET>". It can only
undo the last edit, but C-/ can undo many.)
A new version of goto-chg.el can be found in gnu.emacs.sources.
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2005-03-16 2:03 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).