1

I am wondering why it is so difficult to go back when you mix local and global jumps in Emacs. Maybe I am missing something. For example, if I am in buffer 1 and jump to position 100 (for example using a search command or a bookmark jump), then jump to position 1000, then I jump to buffer 2 position 500 (using for example a bookmark jump).

If I now want to backtrace this history of jumps, I first need to know that I should be using the global mark ring (not the local) to jump to buffer 1, then I will end up at position 100 in buffer 1 (not position 1000 as I wanted), so I need to access the local mark ring for buffer 1, to get to my desired position. This is far from ideal, I would like to avoid having to think about local vs global mark ring when I go back, and I would like to go back to the previous location, whether it is in the current buffer or in some other buffer.

By the way, I am using helm-all-mark-rings for this kind of movement.

The solution provided by backbutton involves "abusing" the global mark ring to also record local jumps. Is this safe to do, and will it work with helm-global-mark-ring? Are there built-in methods that I have missed?

See also kozikow/back.el

Håkon Hægland
  • 3,608
  • 1
  • 20
  • 51

1 Answers1

1

If you can choose among markers in all buffers then you need to be able to choose one, and that means identifying the buffer and the marker in it that you want. That is, I believe, the answer to your question of why it is so difficult to navigate among all such markers.

If you use Icicles then you can use command icicle-goto-any-marker, bound by default to C-0 C-SPC, to do what you want. It provides, as completion candidates, the markers in all buffers.

More precisely, if option icicle-show-multi-completion-flag is non-nil, which it is by default, then a completion candidate is a multi-completion with two parts:

  • The name of the marker's buffer
  • Text from the beginning of the marker's line

icicle-goto-any-marker is an interactive compiled Lisp function in icicles-cmd2.el.

(icicle-goto-any-marker)

Like icicle-goto-marker, but lets you visit markers in all buffers.

If user option icicle-show-multi-completion-flag is non-nil, then each completion candidate is has two parts, the first of which is the name of the marker's buffer, and the second of which is the text from the marker's line.

By default, candidates are sorted in buffer order and then marker order, that is, buffer positions. Use C-M-, or C-, to change the sort order. Remember too that you can use C-A to toggle case-sensitivity (e.g., for buffer names).

See also command icicle-goto-global-marker.

The default order of the completion candidates is buffer followed by marker position. That means that you can easily navigate among them (e.g. cycle) in marker-position order. But you can use C-, to change the sort order to, for example, the order of last use as input. (You can also define whatever other sort order you find most convenient.)

That says that the command is like command icicle-goto-marker (which is bound by default to C-SPC with a negative prefix arg). It's doc string tells you about cycling among completion candidates, i.e., moving among the marked positions in order.

icicle-goto-marker is an interactive compiled Lisp function in icicles-cmd2.el.

(icicle-goto-marker)

Go to a marker in this buffer, choosing it by the line that includes it.

If crosshairs.el is loaded, then the target position is highlighted.

By default, candidates are sorted in marker order, that is, with respect to their buffer positions. Use C-M-, or C-, to change the sort order.

During completion you can use these keys:

C-RET - Goto marker named by current completion candidate

C-down - Goto marker named by next completion candidate

C-up - Goto marker named by previous completion candidate

C-next - Goto marker named by next apropos-completion candidate

C-prior - Goto marker named by previous apropos-completion candidate

C-end - Goto marker named by next prefix-completion candidate

C-home - Goto marker named by previous prefix-completion candidate

S-delete - Delete marker named by current completion candidate

When candidate action and cycling are combined (e.g. C-next), option icicle-act-before-cycle-flag determines which occurs first.

With prefix C-M- instead of C-, the same keys (C-M-mouse-2, C-M-f1, C-M-down, and so on) provide help about candidates.

Use mouse-2, RET, or S-RET to choose a candidate as the final destination, or C-g to quit. This is an Icicles command - see command icicle-mode.

See also commands icicle-goto-any-marker and icicle-goto-global-marker.

Drew
  • 75,699
  • 9
  • 109
  • 225