re-integrate with the plumber

This commit is contained in:
Levi Neely 2025-11-17 20:44:34 +01:00
parent c1fa0e6406
commit add9f93500
1 changed files with 19 additions and 1 deletions

18
main.go
View File

@ -8,6 +8,8 @@ import (
"fmt"
"log"
"os"
"os/exec"
"regexp"
"strings"
"unicode"
@ -182,7 +184,17 @@ func main() {
w.WriteEvent(e)
}
case 'l', 'L':
// Check if text matches identifier pattern
text := string(e.Text)
if isIdentifier(text) {
// Plumb with denote: prefix
cmd := fmt.Sprintf("plumb 'denote:%s'", text)
if err := exec.Command("rc", "-c", cmd).Run(); err != nil {
log.Printf("failed to plumb identifier: %v", err)
}
} else {
w.WriteEvent(e)
}
default:
w.WriteEvent(e)
}
@ -336,3 +348,9 @@ func applyIndexChanges(f *client.Fsys, current, updated fs.Results) error {
return nil
}
var identifierPattern = regexp.MustCompile(`^\d{8}T\d{6}$`)
func isIdentifier(s string) bool {
return identifierPattern.MatchString(s)
}