emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/better-jumper ca6edffe62 30/48: Add new jump behavior conf


From: ELPA Syncer
Subject: [nongnu] elpa/better-jumper ca6edffe62 30/48: Add new jump behavior config option
Date: Sun, 9 Jan 2022 22:58:10 -0500 (EST)

branch: elpa/better-jumper
commit ca6edffe6240a39a46c22701e849e052e07fd22a
Author: Bryan Gilbert <gilbertw1@gmail.com>
Commit: Bryan Gilbert <gilbertw1@gmail.com>

    Add new jump behavior config option
---
 Readme.md        | 13 +++++++++++--
 better-jumper.el | 11 +++++++++--
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/Readme.md b/Readme.md
index 41eadb9675..1e5e3622e9 100644
--- a/Readme.md
+++ b/Readme.md
@@ -35,7 +35,7 @@ You can either a) enable one or both globally:
 Or b) enable one or both locally, where you need it:
 
 ```elisp
-(add-hook 'python-mode-hook 'turn-on-better-jumper-mode
+(add-hook 'python-mode-hook #'turn-on-better-jumper-mode)
 ```
 
 ## Getting started
@@ -89,7 +89,7 @@ using something like `desktop` or `persp-mode`. This is the 
default context.
 While in the `'buffer` context, jump lists are maintained using buffer-local
 variables and can optionally by saved using `savehist`.
 
-#### New Window Behavior  (`better-jumper-new-window-behavior`)
+#### New Window Behavior (`better-jumper-new-window-behavior`)
 
 This setting specifies the behavior that will take place when a new window is
 created AND the current context is set to `'window`. This can be either set to
@@ -97,6 +97,15 @@ created AND the current context is set to `'window`. This 
can be either set to
 jump list will be copied to the new window. If the value is `'empty` then the
 new window's jump list will start empty.
 
+#### Add Jump Behavior (`better-jumper-add-jump-behavior`)
+
+This setting specifies how the jump list is affected when a new jump is added.
+If the value is set to `'append` then new items are always added to the end
+of the jump list regardless of the current position. If the value is set to
+`replace`, then if the any jumps newer than the current position in the jump
+list will be replaced. I.e. If a user jumps back three times then adds a new
+jump, those three jumps will be replaced by the new jump in the list.
+
 #### Max Length  (`better-jumper-max-length`)
 
 This is a numeric value that dictate the maximum length that a jump list can
diff --git a/better-jumper.el b/better-jumper.el
index 977791aa9d..3aa7f7401c 100644
--- a/better-jumper.el
+++ b/better-jumper.el
@@ -62,6 +62,12 @@
                  (other :tag "Copy last window" copy))
   :group 'better-jumper)
 
+(defcustom better-jumper-add-jump-behavior 'append
+  "Determines the behavior when adding a new jump."
+  :type '(choice (const :tag "Replace remaining items in jump list" replace)
+                 (other :tag "Append to end of jump list" append))
+  :group 'better-jumper)
+
 (defcustom better-jumper-max-length 100
   "The maximum number of jumps to keep track of."
   :type 'integer
@@ -339,8 +345,9 @@ POS defaults to point."
     (let* ((struct (better-jumper--get-struct))
            (jump-list (better-jumper--get-struct-jump-list struct))
            (idx (better-jumper-jump-list-struct-idx struct)))
-      (cl-loop repeat idx
-               do (ring-remove jump-list))
+      (when (eq better-jumper-add-jump-behavior 'replace)
+        (cl-loop repeat idx
+                 do (ring-remove jump-list 0)))
       (setf (better-jumper-jump-list-struct-idx struct) -1))
     (save-excursion
       (when pos



reply via email to

[Prev in Thread] Current Thread [Next in Thread]