help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs does not record the position at which it opened a file


From: gnu ist
Subject: Re: emacs does not record the position at which it opened a file
Date: Mon, 20 Apr 2015 19:41:34 -0700

On Mon, Apr 20, 2015 at 9:21 AM, Yuri Khan <yuri.v.khan@gmail.com> wrote:

> The C-@ key is by default bound to “set-mark-command”, and it sets
> mark at the current point position when invoked without a prefix
> argument — i.e. (set-mark-command nil). It looks like you already
> found that out, and tried adding that to your init file.
>
> But it did not work, because you want to invoke that after you visit a
> file, not when you start Emacs.

In the old emacs version where it works the way I am trying to
emulate, I see that if I roam around in the *scratch* buffer and try
to return to the original location by C-u C-SPC, it does not return,
so you are correct that it must work only when I visit a file, not for
*scratch*. I did not anticipate this fine distinction.

> Opening the Elisp manual, you find a
> node promisingly named “Standard Hooks”. You browse the list and
> notice a hook called “find-file-hook”, with a cross-reference to
> “Visiting Functions”. There, you read that the find-file-hook is
> invoked whenever you visit a file.

> Also, following the “See Hooks” link, you read that the primary way to
> set a hook is by using the “add-hook” function.
>
> So, the following incantations will do what you ask (but not
> necessarily what you want or need).
>
> (defun my-find-file-hook () (set-mark-command nil))
> (add-hook 'find-file-hook 'my-find-file-hook)

I have tried this and it seems to work in that it remembers the
position where the .emacs_places puts the cursor if I move it around.
There are still two problems. It has both the beginning of the file
and the current place on the stack and the region between them as
highlighted. I have to press C-g to get rid of it. Also, the mark ring
is not consistent. It appears that sometimes, if I open the file
twice, it has the mark at the beginning of the file and has
highlighted the traverse from there to the position in .emacs_places.

What I may need is a method to examine the mark ring for which I could
not locate a command. This would help me debug the problem.

thanks for any guidance.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]