feat: add --mentions flag to print command#69
Merged
Conversation
Adds linked mentions (backlinks) to the end of note contents when using the print command with --mentions/-m flag. Output format matches Obsidian's UI with wikilinks to linking notes and surrounding context. - Add FindBacklinks method to find notes linking to a given note - Support wikilinks and markdown link formats - Sort mentions by file modification time (most recent first) - Group multiple mentions from same file together
There was a problem hiding this comment.
Pull request overview
This PR adds backlink (mentions) support to the print command, allowing users to view notes that link to the target note. This feature is enabled via the --mentions/-m flag and appends a "Linked Mentions" section to note contents.
Changes:
- Added
FindBacklinksmethod to find notes linking to a given note with support for wikilinks and markdown links - Implemented backlink search pattern generation supporting basename and path-based wikilinks plus multiple markdown link formats
- Extended print command with
--mentionsflag to optionally include backlinks formatted as wikilinks with surrounding context
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/obsidian/utils.go | Extracted wikiLinkPatterns helper and added GenerateBacklinkSearchPatterns to generate search patterns for finding backlinks |
| pkg/obsidian/note.go | Implemented FindBacklinks method with case-insensitive pattern matching and modification time sorting |
| pkg/obsidian/note_test.go | Added comprehensive test coverage for FindBacklinks including wikilinks, markdown links, self-exclusion, and edge cases |
| pkg/actions/print.go | Updated PrintNote to conditionally append formatted backlinks section and added formatMentions helper |
| pkg/actions/print_test.go | Added tests for print functionality with and without mentions |
| mocks/note.go | Extended mock to support FindBacklinks method |
| pkg/actions/search_content_test.go | Added FindBacklinks stub to existing mock |
| cmd/print.go | Added --mentions/-m flag to print command |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use spread operator for array append in utils.go - Add stderr logging when skipping large files in backlink search - Use obsidian.RemoveMdSuffix instead of strings.TrimSuffix in print.go
Yakitrak
approved these changes
Jan 15, 2026
Yakitrak
left a comment
Owner
There was a problem hiding this comment.
Thanks for the PR! It looks good, It will be part of the next release (in the next week or so).
Contributor
Author
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds linked mentions (backlinks) to the end of note contents when using the print command with
--mentions/-mflag. Output format matches Obsidian's UI with wikilinks to linking notes and surrounding context.I am a heavy backlink user from my time using RoamResearch and letting Claude use the backlinks makes a big difference.
Checklist: