C-xrSPC runs point-to-register
C-xrj runs jump-to-register
Type any character to specify a register when prompted.1
C-xrm runs bookmark-set
C-xrb runs bookmark-jump
C-SPCC-SPC pushes the current position to the mark ring (without leaving it active).
C-uC-SPC pops the mark ring, jumping to the previous position. You can ...
C-x 2 will open another window (=split the frame) below the current one, attached to the same buffer. You can move point in either window without affecting the other.
You can move from one window to the other using C-x o. The built-in windmove library provides some function that makes navigating between windows easier.
If this method suits ...
In addition to phils's answer, there are some more options:
helm-all-mark-rings: It allows you to view the content of the both the local and global mark rings in a friendly interface, so you can always jump back to where you were. You can push mark with C-SPC C-SPC. Demo:
helm-semantic-or-imenu: List all available definitions in the current file. If ...
Besides registers and markers (see @phils's answer about both and my other, Icicles answer about markers), bookmarks, particularly either autonamed or temporary bookmarks, can be helpful for this. You need library Bookmark+ for these special bookmark types.
An autonamed bookmark is one that you do not need to name. It is quick to create and delete: just hit ...
With regard to indirect buffers mentioned in the accepted answer...
M-x clone-indirect-buffer will create an indirect buffer for the current buffer. The name of the new buffer will have '<2>' added to it (or a greater number if you've already got duplicate buffer names). The new buffer is opened in a new window. You can switch back to a single window ...
Simply use the kill ring. In evil, your simplest option is to use evil-paste-pop, bound by default to C-p. Here's the docstring:
Replace the just-yanked stretch of killed text with a different stretch.
This command is allowed only immediatly after a yank,
evil-paste-before, evil-paste-after or evil-paste-pop.
This command uses the same paste ...
Just by looking at source code of the first function I found via apropos that has anything to do with registers, I found register-read-with-preview. It might be what you're looking for.
You can prompt for registers only when calling a function interactively by passing code that returns a list of arguments to interactive as it's argument.
Here's the ...
One certainly could write alternative commands which use named registers (internally registers can be anything comparable with eq), but as of Emacs 24.4 I feel like Emacs already solves your main problems?
Quoting from the NEWS file:
*** All interactive commands that read a register (`copy-to-register', etc.)
now display a temporary window after `register-...
OK, I have updated my answer to save the file being visited by the current buffer.
Try this slight variation on your original function:
(defun tmp-register ()
""" put the current buffer in the temporary register """
(set-register ?q (cons 'file buffer-file-name)))
After calling this function (with M-x tmp-register RET (or by key ...
For the past 20 years or so, I've been using these two gems:
(defun ska-point-to-register ()
"Store cursorposition _fast_ in a register. Use ska-jump-to-register
to jump back to the stored position."
(defun ska-jump-to-register ()
"Switches between current cursorposition and position
that was stored with ska-...
if you use evil-mode, the vim layer, then C-o and C-i will work the same.
They run the commands evil-jump-backward / forward. C-o jumps to the older position in the jump list, which is set automatically (marks are set on motion commands). C-i goes in reverse. We can also use TAB after a C-o instead of C-i. So using both functions will take you back and ...
If you use Icicles then you can quickly navigate among the markers in the mark-ring of each buffer or the global-mark-ring (which has a single marker in each buffer).
You do this using multi-command C-- C-SPC (for a buffer's mark-ring) or C-- C-x C-SPC (for the global-mark-ring). After hitting the key once, you use the usual Icicles cycling keys etc., to ...
A minimimal but often helpful possibility - when you just want to peek the other function - is setting
(setq scroll-preserve-screen-position t)
which brings you back to your exact starting cursor position when switching between C-v and M-v.
I found a solution, which sticks to using the vim registers:
Just use the 0 register. In my example above, I can paste the FIRST line by running "0p.
Dan's kill-ring answer is also very helpful, and may be preferable for some. I prefer using the 0 register above because it keeps consistent with pure vim keybindings, which allows me to use it across other ...
You are describing a use case of bookmarks. For example, have a look at the visual bookmark package at https://github.com/joodland/bm. You get functions to toggle bookmarks at point and move back and forth between them. Bind them to keys that are convenient for you.
The simplest option, although it does not keep positions in a ring, is to
save positions to registers.
The docstring for the command point-to-register:
It is bound to C-x r SPC, C-x r C-SPC, C-x r C-@.
(point-to-register REGISTER &optional ARG)
Store current location of point in register REGISTER.
With prefix argument, store current frame ...
I tried bookmarks and they survive buffer closing and Emacs reloading:
(info "Bookmarks (emacs)")
“Bookmarks” are somewhat like registers in that they record positions
you can jump to. Unlike registers, they have long names, and they
persist automatically from one Emacs session to the next. The
prototypical use of bookmarks is to record where you ...
I wouldn't use registers for that, you could just write to words.org during the day. Something like this will do that either for the region you have highlighted, or the word at point, and you could bind it to a key if you want.
(defun my-append-word ()
(let ((word (if (not (region-active-p))
[Posting this again here, but really think we ought to consider a policy of being able to close a question that duplicates one on StackOverflow.]
As it says here:
If you want to repeatedly yank the same text, use the secondary selection instead of the region or killed text.
What's missing from vanilla Emacs is a key binding to yank the secondary selection....
Function set-register (C-h f):
set-register is a compiled Lisp function in register.el.
(set-register REGISTER VALUE)
Set contents of Emacs register named REGISTER to VALUE. Returns VALUE.
See the documentation of the variable register-alist for possible VALUEs.
And (elisp) Registers:
-- Function: set-register reg value
C-h v register-separator says this:
register-separator is a variable defined in register.el.
Its value is nil
Register containing the text to put between collected texts, or nil if none.
When collecting text with C-M-S-delete (or M-x prepend-to-register),
contents of this register is added to the beginning (or end, ...
Latest version of counsel (version 20190522.2133 on MELPA) has counsel-register.
From the documentation:
counsel-register is an interactive, autoloaded function defined in
Interactively choose a register.
This command is not in any keymaps.
counsel-register is unused in ...
To answer my own question and having tried many ways to achieve the above, I've only found one method that at least so far has proved stable/reliable even when using the daemon.
Or the slightly improved rewrite:
The mark-ring is supposed to do just that: use C-u C-SPC to go back one step; repeat as needed. You'll need to increase mark-ring-max if you want to go "up to 100 of them", of course. And it might be the case that some operations fail to "push a mark". If so, please report that as a bug.
I was going to suggest helm-all-mark-rings in the Helm package. It has been mentioned here previously, along with some other tips. To me it otherwise sounds like you might be interested in bm, which is a way to manually add locations to a file (by mouse or keyboard), which you can then jump between.
"I want to access any current file quickly. Therefore I want to build a function that put a file the register."
I hope you realize that Emacs-Lisp "registers" are not computer registers. There is nothing inherently super-quick about them. A Lisp register is essentially a pointer to an object in memory, like a variable.
Of course there is nothing wrong ...
use imenu and below code
(defvar rimenu-position-pair nil "positions before and after imenu jump")
(let ((start-point (marker-position (car mark-ring)))
(setq rimenu-position-pair (list start-point end-point)))))
(defun rimenu-jump ()
evil-mode implements Vim-style markers. You can set markers with (m, that is, evil-set-marker) and jump to the mark with the backtick ` (evil-goto-mark) or to the mark's line ' (evil-goto-mark-line).
Hence, you could create mark "a" at the first location with ma, create mark "b" at the second location with ma, and then 'a to jump to mark "a" and 'b to jump ...