0

I am switching to emacs and in the process of configuring my emacs environment, I am stuck with implementing a functionality which I used to have in eclipse and IntelliJ. Move back and forth in code with alt left/right keys.

I want it to be able to work across all major modes and across all buffers(not just for java or any specific language). For example, say I'm at beginning of file1.txt(say p1). I search for some text and go to line 10(p2) in file1.txt. Then I open another file, file2.txt and repeat the same , start at line 1(p3) and then go to line 10(p4). Upon Alt + Left and Alt + right (or any other similar keybinding), I should be able to cycle between positions p1 <-> p2 <-> p3 <-> p4

I am aware of the following.

  1. ctags/etags specific approach of generating tags, jumping to functions and then back. But I want it to be applicable to text files and a lot of files for which ctags cant be generated or not worth generating as I use them rarely e.g Makefiles generated from cmake builds etc.
  2. Questions, answers and comments in https://superuser.com/questions/241939/how-to-jump-back-to-the-last-position-of-the-cursor-in-emacs , In Emacs, how to go back to previous line position after using semantic Jump to Symbol? where answers are mentioned about using mark ring and registers for storing mark. But after trying such approach initially, I found that once if I go forward, then backward, I pop stuff from the register. I need it to be there forever(:D )
  3. I read really bad things about icicles and bit hesitant to try it.

Any other approach that I have missed ? Any plugin or anything ? Implementing this is a bit complex. I hoping this is a common problem and hoping some piece of elisp code exists for solving this problem.

Community
  • 1
  • 1
Anoop
  • 5,540
  • 7
  • 35
  • 52
  • Sounds like something useful. If such package doesn't exist yes, it should be relatively easy to implement using a `pre-command-hook` that saves the point position before relevant commands. – Lindydancer Oct 30 '15 at 10:24

1 Answers1

0

maybe this is useful .maybe not https://github.com/joodland/bm

(setq-default
bm-recenter nil
bm-highlight-style 'bm-highlight-line-and-fringe
bm-cycle-all-buffers t
bm-in-lifo-order t)
;; (global-set-key (kbd "M-.") 'bm-toggle); you need set mark before you jump 
;; (global-set-key (kbd "M-/")   'bm-next)
;; (global-set-key (kbd "M-,") 'bm-previous)

and I know evil-mode C-o evil-jump-backward C-i evil-jump-forward whenever you use gg G / it can remember last position

jixiuf
  • 11
  • 2
  • I do not know whether the answer is correct, but the last four lines should be moved out of the code box, or semicolon delimiters should be added to the left of each line. Lines 2 to 5 should be slightly indented. – lawlist Nov 05 '15 at 03:29