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: Yuri Khan
Subject: Re: emacs does not record the position at which it opened a file
Date: Mon, 20 Apr 2015 22:21:30 +0600

On Mon, Apr 20, 2015 at 9:48 PM, gnu ist <gnuist006@gmail.com> wrote:
> yes, but you and others have not answered the question asked in the thread.
>
> what to put in .emacs so that when the file is opened, the position of the
> cursor is pushed onto the stack as if it was C-@

I may sound harsh but I do it for your own good: Please go and read
“How To Ask Questions The Smart Way” by Eric S. Raymond. Return here
after you have read and understood that document.

http://www.catb.org/esr/faqs/smart-questions.html

* * *

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



reply via email to

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