Skip to content

feat: add --mentions flag to print command#69

Merged
Yakitrak merged 3 commits into
Yakitrak:mainfrom
nb:feat/print-mentions
Jan 15, 2026
Merged

feat: add --mentions flag to print command#69
Yakitrak merged 3 commits into
Yakitrak:mainfrom
nb:feat/print-mentions

Conversation

@nb

@nb nb commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

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

I am a heavy backlink user from my time using RoamResearch and letting Claude use the backlinks makes a big difference.

Screenshot 2026-01-15 at 1 40 27

Checklist:

  • I have written unit tests for my changes.
  • All new and existing tests passed.

nb added 2 commits January 15, 2026 01:31
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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 FindBacklinks method 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 --mentions flag 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.

Comment thread pkg/obsidian/utils.go Outdated
Comment thread pkg/obsidian/note.go Outdated
Comment thread pkg/actions/print.go Outdated
- 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 Yakitrak assigned Yakitrak and unassigned Yakitrak Jan 15, 2026
@Yakitrak Yakitrak self-requested a review January 15, 2026 20:22

@Yakitrak Yakitrak left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! It looks good, It will be part of the next release (in the next week or so).

@Yakitrak Yakitrak merged commit 0f15280 into Yakitrak:main Jan 15, 2026
@nb nb deleted the feat/print-mentions branch January 16, 2026 05:25
@nb

nb commented Jan 16, 2026

Copy link
Copy Markdown
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants