Trying to get "better-jumper" work. reddit / emacs ---------------------------------------------------------------------- Zeta611 · 2022-08-12 17:14 I transitioned to (vanilla) Emacs two months ago, after using Vim for the last 8 years or so---I'm loving it! I also forced myself out of the comfort zone and practiced plain Emacs keybinding, and I'm quite comfortable with it. However, the only thing I miss from (Neo)vim as an ex-vimmer is `C-o` and `C-i` to jump back and forth. I found this [better-jumper](https://github.com/gilbertw1/better- jumper) package and tried to use it: ```emacs-lisp (use-package better-jumper :ensure t :init (better-jumper-mode 1) :config (define-key input-decode-map "\\C-i" \[C-i\]) :bind (("C-o" . 'better-jumper-jump-backward) ("C-i" . 'better-jumper-jump-forward))) ``` But it doesn't seem to automatically record positions. For instance, I want to move back to where I was after I `C-M-.` via `C-o`. Is there a way to automatically do this without full-fledged Doom emacs or evil-mode? I'm fine with cherry-picking only this feature from evil-mode, btw. Thanks! ---------------------------------------------------------------------- n9lla · 2022-08-12 20:46 Indeed you have to tell better-jumper to record positions by calling `better-jump-set-jump` in hooks or advices. Doom does something like this: `(advice-add #'imenu :around #'doom-set-jump-a)`. To cherry-pick, I would first go steal Doom's config for better-jumper (just 2 or 3 functions is enough) and then advise more functions, using evil (or maybe just vi) as reference. See the "Similar Packages" section of this package, [https://github.co m/Overdr0ne/gumshoe](https://github.com/Overdr0ne/gumshoe), for a list of alternatives. Gumshoe automatically records positions after idling for a few seconds if I'm not mistaken, so if you want something closer to Vim then you'd have to start by disabling some features. ---------------------------------------------------------------------- themathiasdahl · 2022-08-12 20:46 Have you tried out using Emacs mark ring for navigating? From the little I know of the Vim feature you refer to, it's probably quite different, but I often jump using the mark ring and I think it works well. Many Emacs commands that move point also at mark. Not all do, but enough do, in my view. Read more here: https://www.gnu.org/software/emacs/manual/html_node/emacs/Mark- Ring.html I'm sure there are also articles written but the manual seems to cover a lot. Good luck! ---------------------------------------------------------------------- HM0880 · 2022-08-12 21:17 Mark ring may be what you want. If you want to jump around a code base, Dumb Jump is great: https://github.com/jacktasia/dumb-jump ---------------------------------------------------------------------- Zeta611 · 2022-08-13 00:40 Thank you! The gumshoe package looks promising. ---------------------------------------------------------------------- Zeta611 · 2022-08-13 00:50 To be honest, I didn’t try hard to use the mark ring. I think I should learn how to use the mark ring to navigate around the Emacs way! Thanks for the reference. +)Is there a way for automating c-spc c-spc to set a mark and push it onto the ring? ---------------------------------------------------------------------- Zeta611 · 2022-08-13 00:50 I’ll take a look at it, thank you! ---------------------------------------------------------------------- 00-11 · 2022-08-13 02:18 * (Others have mentioned the *mark ring*. Yes, this, of course.) * Beyond what that offers, [***autonamed bookmarks***](https://www.ema cswiki.org/emacs/BookmarkPlus#AutonamedBookmarks). (You need [Bookmark+](https://www.emacswiki.org/emacs/BookmarkPlus) for this.) By default, autonamed bookmarks are ***temporary*** - not saved to your bookmark file. You can control this with option `bmkp-autotemp- bookmark-predicates`. See [Temporary Bookmarks](https://www.emacswiki. org/emacs/BookmarkPlus#TemporaryBookmarks). You can even [highlight](https://www.emacswiki.org/emacs/BookmarkPl us#HighlightingBookmarkLocations) the locations of bookmarks, in case that helps. You can do that by bookmark type -- e.g., highlight only autonamed bookmarks. ---------------------------------------------------------------------- mickeyp · 2022-08-13 10:18 Yes. I've written how to do this here: https://www.masteringemacs.org/article/fixing-mark-commands-transient- mark-mode ---------------------------------------------------------------------- deaddyfreddy · 2022-08-13 10:19 `:bind` works with non-global keymaps too, so there's no need to use `define0key`. As for jumping, I use `counsel-mark-ring` ---------------------------------------------------------------------- DefiantAverage1 · 2022-08-13 12:21 Do you use evil? ---------------------------------------------------------------------- Zeta611 · 2022-08-14 01:44 About the define-key, the purpose was to differentiate the physical tab key and the c-i combo. Is there a better way to do this / can it be done with :bind? ---------------------------------------------------------------------- Zeta611 · 2022-08-14 01:44 Thank you, that’s super useful :) ---------------------------------------------------------------------- Zeta611 · 2022-08-14 01:45 No, I don’t! ---------------------------------------------------------------------- deaddyfreddy · 2022-08-14 10:36 > can it be done with :bind? that's what I was talking about https://github.com/jwiegley/use-package#binding-within-local-keymaps ---------------------------------------------------------------------- jimehgeek · 2022-08-15 08:15 As others have mentioned, better-jumper doesn’t automatically record points to jump back to. For that’s there’s both [dogears](https://github.com/alphapapa/dogears.el) and [gumshoe](https://github.com/Overdr0ne/gumshoe). In case it’s of any help to you, I recently setup better-jumper in my own config [here](https://github.com/jimeh/.emacs.d/blob/de722509f5dd4 008d5ed7b2c47aea64c9c4fb8c7/modules/navigation/siren-better- jumper.el). I specifically use it to record a jump point before and after triggering various jump to definition/reference functions, and nothing else so far.