* emacs does not record the position at which it opened a file @ 2015-04-20 0:19 gnuist006 2015-04-20 1:18 ` Alexis ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: gnuist006 @ 2015-04-20 0:19 UTC (permalink / raw) To: help-gnu-emacs Hi all, emacs does not record the position at which it opened a file. If I move the cursor and then I say C-u SPC, there is "no mark set in this buffer" I am sick of C-@ as I tend to forget. Is there any remedy like this but it does not work, I tried (set-mark-command nil) (set-mark-command (point)) Bolega ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs does not record the position at which it opened a file 2015-04-20 0:19 emacs does not record the position at which it opened a file gnuist006 @ 2015-04-20 1:18 ` Alexis 2015-04-20 1:46 ` Dale Snell [not found] ` <mailman.1141.1429492704.904.help-gnu-emacs@gnu.org> 2 siblings, 0 replies; 10+ messages in thread From: Alexis @ 2015-04-20 1:18 UTC (permalink / raw) To: help-gnu-emacs gnuist006@gmail.com writes: > emacs does not record the position at which it opened a file. If > I move the cursor and then I say > > C-u SPC, there is "no mark set in this buffer" > > I am sick of C-@ as I tend to forget. > > Is there any remedy like this but it does not work, I tried > > (set-mark-command nil) (set-mark-command (point)) Perhaps you want `saveplace'? See the save-place-* variables for setup. Alexis. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs does not record the position at which it opened a file 2015-04-20 0:19 emacs does not record the position at which it opened a file gnuist006 2015-04-20 1:18 ` Alexis @ 2015-04-20 1:46 ` Dale Snell [not found] ` <mailman.1141.1429492704.904.help-gnu-emacs@gnu.org> 2 siblings, 0 replies; 10+ messages in thread From: Dale Snell @ 2015-04-20 1:46 UTC (permalink / raw) To: help-gnu-emacs [-- Attachment #1: Type: text/plain, Size: 1508 bytes --] On Sun, 19 Apr 2015 17:19:36 -0700 (PDT), in message d339042b-1cb8-4ca5-ba9d-3c70a8314cbd@googlegroups.com, gnuist006@gmail.com wrote: > emacs does not record the position at which it opened a file. Indeed, by default it does not. However, you can set it to do so. See the EmacsWiki page: <http://www.emacswiki.org/emacs/SavePlace> > If I > move the cursor and then I say > > C-u SPC, there is "no mark set in this buffer" C-u SPC should give you four spaces. If it doesn't, you've got something mis-configured somewhere. C-x SPC sets the mark for rectangle mode; C-SPC sets the mark. > I am sick of C-@ as I tend to forget. Use C-SPC instead. > Is there any remedy like this but it does not work, I tried > > (set-mark-command nil) > (set-mark-command (point)) "set-mark-command" is a function that is bound to a keystroke. By default, C-@ and C-SPC. Either will work. Have you gone through the Emacs tutorial? If not, you should; it's got lots of very useful information. It's the first entry in the "Help" menu, or available through "C-h t" if you don't use the menus. The Info manual is also very useful, especially the Concept Index. Hope this helps. --Dale -- +----------+ +----------+ +-----------+ +---------+ +-------+ | Space is | | Space is | | It's Hard | | A Place | | Burma | | Big | | Dark | | to Find | | to Park | | Shave | +----------+ +----------+ +-----------+ +---------+ +-------+ [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <mailman.1141.1429492704.904.help-gnu-emacs@gnu.org>]
* Re: emacs does not record the position at which it opened a file [not found] ` <mailman.1141.1429492704.904.help-gnu-emacs@gnu.org> @ 2015-04-20 6:52 ` gnuist006 2015-04-20 11:52 ` Yuri Khan 0 siblings, 1 reply; 10+ messages in thread From: gnuist006 @ 2015-04-20 6:52 UTC (permalink / raw) To: help-gnu-emacs On Sunday, April 19, 2015 at 6:18:25 PM UTC-7, Alexis wrote: > gnuist006@gmail.com writes: > > > emacs does not record the position at which it opened a file. If > > I move the cursor and then I say > > > > C-u SPC, there is "no mark set in this buffer" > > > > I am sick of C-@ as I tend to forget. > > > > Is there any remedy like this but it does not work, I tried > > > > (set-mark-command nil) (set-mark-command (point)) > > Perhaps you want `saveplace'? See the save-place-* variables for > setup. > Thanks to both of you ... however, ~/.emacs-places or saveplace is not what I am looking for. This saves a place in between sessions. My old emacs has this feature that when I open a file, it goes to a place from the saveplace and then after it, if I move the cursor and type C-u SPC, it will remember the old place in that same session and possibly other locations it pushed into some kind of stack and go back in the reverse order based on C-u SPC. The new latest emacs does not do that, unless before the first move of the cursor, I use C-@ to memorize it. Suppose I forget the first C-@, then I have lost the original place unless I open the same file in a 2nd emacs before closing the first one in which case it gets it from saveplace. > Alexis. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs does not record the position at which it opened a file 2015-04-20 6:52 ` gnuist006 @ 2015-04-20 11:52 ` Yuri Khan 2015-04-20 15:48 ` gnu ist [not found] ` <mailman.1189.1429544936.904.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 10+ messages in thread From: Yuri Khan @ 2015-04-20 11:52 UTC (permalink / raw) To: gnuist006; +Cc: help-gnu-emacs@gnu.org On Mon, Apr 20, 2015 at 12:52 PM, <gnuist006@gmail.com> wrote: > My old emacs has this feature that when I open a file, it goes to a place from the saveplace and then after it, if I move the cursor and type C-u SPC, it will remember the old place in that same session and possibly other locations it pushed into some kind of stack and go back in the reverse order based on C-u SPC. The default key binding for this is C-u C-SPC, not C-u SPC. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs does not record the position at which it opened a file 2015-04-20 11:52 ` Yuri Khan @ 2015-04-20 15:48 ` gnu ist 2015-04-20 16:21 ` Yuri Khan [not found] ` <mailman.1189.1429544936.904.help-gnu-emacs@gnu.org> 1 sibling, 1 reply; 10+ messages in thread From: gnu ist @ 2015-04-20 15:48 UTC (permalink / raw) To: Yuri Khan; +Cc: help-gnu-emacs@gnu.org 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-@ On Mon, Apr 20, 2015 at 4:52 AM, Yuri Khan <yuri.v.khan@gmail.com> wrote: > On Mon, Apr 20, 2015 at 12:52 PM, <gnuist006@gmail.com> wrote: > > My old emacs has this feature that when I open a file, it goes to a > place from the saveplace and then after it, if I move the cursor and type > C-u SPC, it will remember the old place in that same session and possibly > other locations it pushed into some kind of stack and go back in the > reverse order based on C-u SPC. > > The default key binding for this is C-u C-SPC, not C-u SPC. > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs does not record the position at which it opened a file 2015-04-20 15:48 ` gnu ist @ 2015-04-20 16:21 ` Yuri Khan 2015-04-21 2:41 ` gnu ist 0 siblings, 1 reply; 10+ messages in thread From: Yuri Khan @ 2015-04-20 16:21 UTC (permalink / raw) To: gnu ist; +Cc: help-gnu-emacs@gnu.org 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) ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs does not record the position at which it opened a file 2015-04-20 16:21 ` Yuri Khan @ 2015-04-21 2:41 ` gnu ist 2015-04-21 12:53 ` Stefan Monnier 0 siblings, 1 reply; 10+ messages in thread From: gnu ist @ 2015-04-21 2:41 UTC (permalink / raw) To: Yuri Khan; +Cc: help-gnu-emacs@gnu.org 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. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: emacs does not record the position at which it opened a file 2015-04-21 2:41 ` gnu ist @ 2015-04-21 12:53 ` Stefan Monnier 0 siblings, 0 replies; 10+ messages in thread From: Stefan Monnier @ 2015-04-21 12:53 UTC (permalink / raw) To: help-gnu-emacs > In the old emacs version where it works the way I am trying to emulate, If it worked in some previous Emacs version, then it sounds like it's a bug in the new version. Please M-x report-emacs-bug giving a recipe that worked (and indicating which Emacs version that was) but that doesn't work any more. Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <mailman.1189.1429544936.904.help-gnu-emacs@gnu.org>]
* Re: emacs does not record the position at which it opened a file [not found] ` <mailman.1189.1429544936.904.help-gnu-emacs@gnu.org> @ 2015-04-20 22:34 ` Barry Margolin 0 siblings, 0 replies; 10+ messages in thread From: Barry Margolin @ 2015-04-20 22:34 UTC (permalink / raw) To: help-gnu-emacs In article <mailman.1189.1429544936.904.help-gnu-emacs@gnu.org>, 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-@ When a file is opened, the cursor is positioned at the beginning. Why would you need this saved? You can always get there with M-<. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-04-21 12:53 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-04-20 0:19 emacs does not record the position at which it opened a file gnuist006 2015-04-20 1:18 ` Alexis 2015-04-20 1:46 ` Dale Snell [not found] ` <mailman.1141.1429492704.904.help-gnu-emacs@gnu.org> 2015-04-20 6:52 ` gnuist006 2015-04-20 11:52 ` Yuri Khan 2015-04-20 15:48 ` gnu ist 2015-04-20 16:21 ` Yuri Khan 2015-04-21 2:41 ` gnu ist 2015-04-21 12:53 ` Stefan Monnier [not found] ` <mailman.1189.1429544936.904.help-gnu-emacs@gnu.org> 2015-04-20 22:34 ` Barry Margolin
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).