Eliminate bookmark-maybe-historicize-string duplicates

* lisp/bookmark.el (bookmark-maybe-historicize-string):
Use 'add-to-history' to respect history-delete-duplicates and the
'history-length property.  (Bug#76137)
This commit is contained in:
shipmints 2025-02-07 19:39:36 -05:00 committed by Stefan Kangas
parent 34d353cd72
commit 788380cf6a
3 changed files with 13 additions and 3 deletions

View file

@ -472,6 +472,13 @@ default), the 'whitespace-cleanup' function will now add the newline.
** Bookmark
---
*** Bookmark history now saves each bookmark only once.
Previously, the variable 'bookmark-history' accumulated duplicate
bookmark names when bookmark features were used interactively. This
made their history larger than necessary for frequent bookmark users.
Bookmark names are now saved uniquely.
---
*** New user option 'bookmark-bmenu-type-column-width'.
This user option controls the width of the type column on the bookmark

View file

@ -603,7 +603,7 @@ from other commands that pass in the bookmark name, so
`completing-read' never gets a chance to set `bookmark-history'."
`(or
(called-interactively-p 'interactive)
(setq bookmark-history (cons ,string bookmark-history))))
(add-to-history 'bookmark-history ,string)))
(defvar bookmark-make-record-function 'bookmark-make-record-default
"A function that should be called to create a bookmark record.

View file

@ -193,9 +193,12 @@ the lexically-bound variable `buffer'."
(should (equal (bookmark-prop-get bmk 'filename) "prop")))))
(ert-deftest bookmark-tests-maybe-historicize-string ()
(let ((bookmark-history))
(let ((bookmark-history)
(history-delete-duplicates t))
(bookmark-maybe-historicize-string "foo")
(should (equal (car bookmark-history) "foo"))))
(bookmark-maybe-historicize-string "foo")
(should (equal (car bookmark-history) "foo"))
(should (= 1 (length bookmark-history)))))
(defun bookmark-remove-last-modified (bmk)
(assoc-delete-all 'last-modified bmk))