From 80caa923c2b4706947e32739fe05c779e56fe465 Mon Sep 17 00:00:00 2001 From: NicolasGB Date: Thu, 12 Mar 2026 16:50:25 +0100 Subject: [PATCH] feat(cmd): Implement the `bookmark forget` as a native function --- README.md | 11 +++++++++-- lua/jj/cmd/init.lua | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 56d3cd9..a169596 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ - `squash` - Squash the current diff to its parent or interactive squash mode from the log buffer - `split` - Split a change interactively in a floating terminal - `rebase` - Rebase changes to a destination - - `bookmark create/delete` - Create and delete bookmarks + - `bookmark create/delete/forget` - Create, delete, and forget bookmarks - `tag set/delete/push` - Create, delete, and push tags (push requires colocated repos) - `undo` - Undo the last operation - `redo` - Redo the last undone operation @@ -355,7 +355,7 @@ The plugin provides a `:J` command that accepts jj subcommands: :J split " Split a change interactively :J diff_history " Prompt for a `left..right` range and open a history-aware diff :J diff_history main..@ " Open a history-aware diff between main and the working copy -:J bookmark create/move/delete +:J bookmark create/move/delete/forget :J tag set " Set a tag (prompts for revision and tag name) :J tag set abc123 " Set a tag on a specific revision :J tag delete " Delete a tag via picker @@ -671,6 +671,13 @@ local cmd = require("jj.cmd") cmd.bookmark_delete() -- Select bookmark to delete ``` +The `bookmark_forget` function forgets a bookmark: + +```lua +local cmd = require("jj.cmd") +cmd.bookmark_forget() -- Select bookmark to forget +``` + ### Tag Management Command Options The `tag_set` function creates a tag on a revision: diff --git a/lua/jj/cmd/init.lua b/lua/jj/cmd/init.lua index 648d8cd..2ab1b85 100644 --- a/lua/jj/cmd/init.lua +++ b/lua/jj/cmd/init.lua @@ -607,6 +607,36 @@ function M.bookmark_track() end) end +-- Jujutsu forget bookmark +function M.bookmark_forget() + if not utils.ensure_jj() then + return + end + + local bookmarks = utils.get_all_bookmarks() + if #bookmarks == 0 then + utils.notify("No bookmarks to forget", vim.log.levels.ERROR) + return + end + + local log_open = terminal.is_log_buffer_open() + + vim.ui.select(bookmarks, { prompt = "Which bookmark do you want to forget?" }, function(choice) + if choice then + runner.execute_command_async( + string.format("jj bookmark forget %s --quiet", vim.fn.shellescape(choice)), + function() + utils.notify(string.format("Bookmark `%s` is now untracked.", choice)) + if log_open then + M.log() + end + end, + "Could not forget bookmark" + ) + end + end) +end + -- Jujutsu undo function M.undo() if not utils.ensure_jj() then @@ -1269,6 +1299,8 @@ function M.j(args) M.bookmark_move() elseif remaining_args[1] == "delete" or remaining_args[1] == "d" then M.bookmark_delete() + elseif remaining_args[1] == "forget" or remaining_args[1] == "f" then + M.bookmark_forget() elseif remaining_args[1] == "track" or remaining_args[1] == "t" then M.bookmark_track() else