From 375c041c9ebad8f749fe404d87685d61eb9d207b Mon Sep 17 00:00:00 2001 From: Sina Siadat Date: Sat, 9 May 2015 12:53:59 +0430 Subject: [PATCH] if EDITOR exists with status other than 0, print edited filepath --- README.md | 4 ++-- attr.go | 7 ++++--- commands.go | 5 +++-- options.go | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 97e144a..e020e0f 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ eton is a note-taking cli tool. * sqlite database storage * fast search - * quick access using unique aliases - * marking important notes + * quick and direct access to a note using a unique alias + * mark important notes ## Install or upgrade diff --git a/attr.go b/attr.go index d2df071..f5f5c1b 100644 --- a/attr.go +++ b/attr.go @@ -228,7 +228,7 @@ func (attr Attr) Print(w *tabwriter.Writer, verbose bool, indent int, highlighte if attr.GetMark() == 0 { fmt.Fprintf(out, "[%s] %s\n", Color(attr.GetIdentifier(), "yellow+b"), attr.Title()) } else { - fmt.Fprintf(out, "%s %s\n", Color("["+attr.GetIdentifier()+"]", "black+b:white"), Color(attr.Title(), "default")) + fmt.Fprintf(out, "%s %s\n", Color("("+attr.GetIdentifier()+")", "black+b:white"), Color(attr.Title(), "default")) } if len(highlighteds) > 0 { fmt.Fprintln(out, attr.PrettyMatches(highlighteds, after)) @@ -254,12 +254,13 @@ func (attr Attr) PrettyMatches(highlighteds []string, after int) string { line, matched := highlightLine(line, highlighteds) if matched { lastMatchingLine = linenumber - if true { // !isCoveredByLastMatch { + if true || !isCoveredByLastMatch { matchCounter += 1 } } if matched || isCoveredByLastMatch { - prefix := fmt.Sprintf("%s L%s:", strings.Repeat(" ", len(attr.GetIdentifier())), strconv.Itoa(linenumber+1)) + //prefix := fmt.Sprintf("%s L%s:", strings.Repeat(" ", len(attr.GetIdentifier())), strconv.Itoa(linenumber+1)) + prefix := fmt.Sprintf("%s", strings.Repeat(" ", 3+len(attr.GetIdentifier()))) matchinglines = append(matchinglines, Color(prefix, "black")+line) if maximumShownMatches != -1 && matchCounter >= maximumShownMatches { break diff --git a/commands.go b/commands.go index 5442a89..7b7fdaa 100644 --- a/commands.go +++ b/commands.go @@ -20,7 +20,7 @@ var globalDB *sql.DB var globalOpts Options // const orderby = "-frequency, -mark, CASE WHEN updated_at IS NULL THEN created_at ELSE updated_at END DESC" -const orderby = "CASE WHEN updated_at IS NULL THEN created_at ELSE updated_at END DESC" +const orderby = "-mark, CASE WHEN updated_at IS NULL THEN created_at ELSE updated_at END DESC" const defaultEditor = "vi" func cmdShow(db *sql.DB, opts Options) bool { @@ -394,7 +394,8 @@ func openEditor(filepath string) bool { cmd.Stdout = os.Stdout err := cmd.Run() if err != nil { - log.Println(err) + log.Println("Error:", err) + log.Println("File not saved:", filepath) return false } return true diff --git a/options.go b/options.go index a403ece..dd3e797 100644 --- a/options.go +++ b/options.go @@ -9,7 +9,7 @@ import ( const novalue string = "nil" const datelayout string = "06/01/02 03:04pm" const ellipsis = "…" -const maximumShownMatches = -1 // -1 +const maximumShownMatches = -1 type Options struct { ID int64