diff options
| author | Laurence Warne <laurencewarne@gmail.com> | 2024-01-21 17:04:37 +0000 |
|---|---|---|
| committer | Bozhidar Batsov <bozhidar@batsov.dev> | 2024-01-23 16:24:48 +0200 |
| commit | f7e60843bfada2eee89595580786a4468fd3f881 (patch) | |
| tree | fe7bc511aed0e826cc2e02f53d93e09e46f1675c /projectile.el | |
| parent | 55e9026881538c126293b7e682d0d147984254f1 (diff) | |
Add new custom variable 'projectile-cmd-hist-ignoredups'
Add new custom variable 'projectile-cmd-hist-ignoredups', which can be
used to tweak how duplicates are dealt with in projectile's command
history. The custom variable is identical in behaviour to
'eshell-hist-ignoredups'.
Specifically, the existing default behavior is maintained with the
value of t, which means consecutive duplicates are ignored. A value
of 'erase means only the last duplicate is kept, whilst a value of nil
means all duplicates are kept.
Diffstat (limited to 'projectile.el')
| -rw-r--r-- | projectile.el | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/projectile.el b/projectile.el index 5d030dc..e5a78c7 100644 --- a/projectile.el +++ b/projectile.el @@ -874,6 +874,17 @@ If the value is nil, there is no limit to the opend buffers count." :type 'integer :package-version '(projectile . "2.2.0")) +(defcustom projectile-cmd-hist-ignoredups t + "Controls when inputs are added to projectile's command history. + +A value of t means consecutive duplicates are ignored. +A value of `erase' means only the last duplicate is kept. +A value of nil means nothing is ignored." + :type '(choice (const :tag "Don't ignore anything" nil) + (const :tag "Ignore consecutive duplicates" t) + (const :tag "Only keep last duplicate" erase)) + :package-version '(projectile . "2.9.0")) + (defvar projectile-project-test-suffix nil "Use this variable to override the current project's test-suffix property. It takes precedence over the test-suffix for the project type when set. @@ -5227,8 +5238,17 @@ The command actually run is returned." (when command-map (puthash default-directory command command-map) (let ((hist (projectile--get-command-history project-root))) - (unless (string= (car-safe (ring-elements hist)) command) - (ring-insert hist command)))) + (cond + ((eq projectile-cmd-hist-ignoredups t) + (unless (string= (car-safe (ring-elements hist)) command) + (ring-insert hist command))) + ((eq projectile-cmd-hist-ignoredups 'erase) + (let ((idx (ring-member hist command))) + (while idx + (ring-remove hist idx) + (setq idx (ring-member hist command)))) + (ring-insert hist command)) + (t (ring-insert hist command))))) (when save-buffers (save-some-buffers (not compilation-ask-about-save) (lambda () |
