aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorManuel Giraud2022-05-31 20:35:39 +0200
committerLars Ingebrigtsen2022-05-31 20:35:39 +0200
commitf461eb8fa770a6f6b048f13684bd697756f8790c (patch)
tree7ba450580e1781c14be8b1fc032090fa5e304432 /test
parent6a2cc870d23485a8f440a8b58768eefdf16c8912 (diff)
downloademacs-f461eb8fa770a6f6b048f13684bd697756f8790c.tar.gz
emacs-f461eb8fa770a6f6b048f13684bd697756f8790c.zip
Add a last-modified field when a bookmark is set
* test/lisp/bookmark-tests.el (bookmark-tests-make-record) (bookmark-tests-make-record-list, bookmark-tests-set): fix tests to not consider last-modified in bookmark equality. * lisp/bookmark.el (bookmark-make-record-default): add a last-modified field. (bookmark-sort-flag): add the 'last-modified choice. (bookmark-get-last-modified): new function to get last-modified bookmark field. (bookmark-maybe-sort-alist): sort in last-modified first order. (bookmark-completing-read): use `bookmark-maybe-sort-alist'.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/bookmark-tests.el30
1 files changed, 21 insertions, 9 deletions
diff --git a/test/lisp/bookmark-tests.el b/test/lisp/bookmark-tests.el
index ae7331fcc2b..a2d8f2d260b 100644
--- a/test/lisp/bookmark-tests.el
+++ b/test/lisp/bookmark-tests.el
@@ -197,6 +197,9 @@ the lexically-bound variable `buffer'."
197 (bookmark-maybe-historicize-string "foo") 197 (bookmark-maybe-historicize-string "foo")
198 (should (equal (car bookmark-history) "foo")))) 198 (should (equal (car bookmark-history) "foo"))))
199 199
200(defun bookmark-remove-last-modified (bmk)
201 (assoc-delete-all 'last-modified bmk))
202
200(ert-deftest bookmark-tests-make-record () 203(ert-deftest bookmark-tests-make-record ()
201 (with-bookmark-test-file 204 (with-bookmark-test-file
202 (let* ((record `("example.txt" (filename . ,bookmark-tests-example-file) 205 (let* ((record `("example.txt" (filename . ,bookmark-tests-example-file)
@@ -206,9 +209,11 @@ the lexically-bound variable `buffer'."
206 (defaults "example.txt")))) 209 (defaults "example.txt"))))
207 (with-current-buffer buffer 210 (with-current-buffer buffer
208 (goto-char 3) 211 (goto-char 3)
209 (should (equal (bookmark-make-record) record)) 212 (should (equal (bookmark-remove-last-modified (bookmark-make-record))
213 record))
210 ;; calling twice gives same record 214 ;; calling twice gives same record
211 (should (equal (bookmark-make-record) record)))))) 215 (should (equal (bookmark-remove-last-modified (bookmark-make-record))
216 record))))))
212 217
213(ert-deftest bookmark-tests-make-record-list () 218(ert-deftest bookmark-tests-make-record-list ()
214 (with-bookmark-test-file-list 219 (with-bookmark-test-file-list
@@ -219,9 +224,11 @@ the lexically-bound variable `buffer'."
219 (defaults "example.txt")))) 224 (defaults "example.txt"))))
220 (with-current-buffer buffer 225 (with-current-buffer buffer
221 (goto-char 3) 226 (goto-char 3)
222 (should (equal (bookmark-make-record) record)) 227 (should (equal (bookmark-remove-last-modified (bookmark-make-record))
228 record))
223 ;; calling twice gives same record 229 ;; calling twice gives same record
224 (should (equal (bookmark-make-record) record)))))) 230 (should (equal (bookmark-remove-last-modified (bookmark-make-record))
231 record))))))
225 232
226(ert-deftest bookmark-tests-make-record-function () 233(ert-deftest bookmark-tests-make-record-function ()
227 (with-bookmark-test 234 (with-bookmark-test
@@ -255,15 +262,18 @@ the lexically-bound variable `buffer'."
255 ;; Set first bookmark 262 ;; Set first bookmark
256 (goto-char (point-min)) 263 (goto-char (point-min))
257 (bookmark-set "foo") 264 (bookmark-set "foo")
258 (should (equal bookmark-alist (list bmk1))) 265 (should (equal (mapcar #'bookmark-remove-last-modified bookmark-alist)
266 (list bmk1)))
259 ;; Replace that bookmark 267 ;; Replace that bookmark
260 (goto-char (point-max)) 268 (goto-char (point-max))
261 (bookmark-set "foo") 269 (bookmark-set "foo")
262 (should (equal bookmark-alist (list bmk2))) 270 (should (equal (mapcar #'bookmark-remove-last-modified bookmark-alist)
271 (list bmk2)))
263 ;; Push another bookmark with the same name 272 ;; Push another bookmark with the same name
264 (goto-char (point-min)) 273 (goto-char (point-min))
265 (bookmark-set "foo" t) ; NO-OVERWRITE is t 274 (bookmark-set "foo" t) ; NO-OVERWRITE is t
266 (should (equal bookmark-alist (list bmk1 bmk2))) 275 (should (equal (mapcar #'bookmark-remove-last-modified bookmark-alist)
276 (list bmk1 bmk2)))
267 277
268 ;; 2. bookmark-set-no-overwrite 278 ;; 2. bookmark-set-no-overwrite
269 ;; Don't overwrite 279 ;; Don't overwrite
@@ -271,11 +281,13 @@ the lexically-bound variable `buffer'."
271 ;; Set new bookmark 281 ;; Set new bookmark
272 (setq bookmark-alist nil) 282 (setq bookmark-alist nil)
273 (bookmark-set-no-overwrite "foo") 283 (bookmark-set-no-overwrite "foo")
274 (should (equal bookmark-alist (list bmk1))) 284 (should (equal (mapcar #'bookmark-remove-last-modified bookmark-alist)
285 (list bmk1)))
275 ;; Push another bookmark with the same name 286 ;; Push another bookmark with the same name
276 (goto-char (point-max)) 287 (goto-char (point-max))
277 (bookmark-set-no-overwrite "foo" t) ; PUSH-BOOKMARK is t 288 (bookmark-set-no-overwrite "foo" t) ; PUSH-BOOKMARK is t
278 (should (equal bookmark-alist (list bmk2 bmk1))) 289 (should (equal (mapcar #'bookmark-remove-last-modified bookmark-alist)
290 (list bmk2 bmk1)))
279 291
280 ;; 3. bookmark-set-internal 292 ;; 3. bookmark-set-internal
281 (should-error (bookmark-set-internal "foo" "bar" t)))))) 293 (should-error (bookmark-set-internal "foo" "bar" t))))))