Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs: How to use the mark-ring?

When I do a C-u C-SPC, emacs takes me to "where I was before". Subsequent C-u C-SPC presses go back up previous places. That is damn great, and I use it a lot.

But something always bugged me : The only mark missing from the mark-ring is where-I-invoked-this-in-the-1st-place! It's like leaving bread crumbs behind you, and then go "whoops, I may be lost, imma go back and check", then going back without leaving a bread crumb where you are right now!

I tried advising the function, but I can't for the life of me programmatically simulate a C-SPC C-SPC.

  • how can I "see" (echo, message, trace, etc) what a key combination does, like "C-h k" but for repeated key sequences, like C-SPC C-SPC ? Here is what the manual says of the latter (emphasis mine)

C-SPC runs the command set-mark-command, which is an interactive compiled Lisp function in `simple.el'.

It is bound to C-@, C-SPC.

(set-mark-command ARG)

Set the mark where point is, or jump to the mark. Setting the mark also alters the region, which is the text between point and mark; this is the closest equivalent in Emacs to what some editors call the "selection".

With no prefix argument, set the mark at point, and push the old mark position on local mark ring. Also push the old mark on global mark ring, if the previous mark was set in another buffer.

But when I try to use it (non-interactively) "With no prefix argument" in order to "set the mark at point" I get a debugger error "wrong-number-of-arguments"..? (I realize the difference between an argument and a prefix argument).

I would be okay even with a philosophical, non-practical answer. I just want to understand what the idea is here.

like image 885
yPhil Avatar asked Jul 27 '12 13:07

yPhil


1 Answers

(push-mark) seems to be doing what you want.

like image 193
Nicolas Dudebout Avatar answered Oct 04 '22 21:10

Nicolas Dudebout