Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Change Log for neuron

## 1.0.1.0
## Unreleased

- Revert #429 for neuron-search regression

## 1.0.1.0

- Fix broken `neuron search` in static binary (#429)

- Fix broken `neuron search` in static binary (#429)

## 1.0.0.0

- Updates
Expand Down
6 changes: 3 additions & 3 deletions neuron/neuron.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 2.4
name: neuron
-- This version must be in sync with what's in Default.dhall
version: 1.0.1.0
version: 1.0.2.0
license: AGPL-3.0-only
copyright: 2020 Sridhar Ratnakumar
maintainer: srid@srid.ca
Expand Down Expand Up @@ -135,6 +135,7 @@ common app-common
foldl,
filepath,
dhall >= 1.30,
which,
unix,
megaparsec >= 8.0,
dependent-sum >= 0.7,
Expand All @@ -145,8 +146,7 @@ common app-common
with-utf8,
shower,
either,
uri-encode,
temporary
uri-encode

-- Everything below will have to be stripped away, if whoever uses this repo
-- will want to avoid non-core dependencies. Cabal doesn't seem to provide a way
Expand Down
22 changes: 5 additions & 17 deletions neuron/src/app/Neuron/CLI/Search.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ module Neuron.CLI.Search
)
where

import Data.FileEmbed (embedOneStringFileOf)
import qualified Data.Text as Text
import Data.Text.IO (hPutStr)
import Development.Shake (Action)
import Neuron.CLI.Rib
( SearchBy (SearchByContent, SearchByTitle),
Expand All @@ -22,13 +20,11 @@ import Neuron.CLI.Rib
import Neuron.Config.Type (Config, getZettelFormats)
import Neuron.Reader.Type (ZettelFormat (ZettelFormat_Org), zettelFormatToExtension)
import Relude
import System.IO (hClose)
import System.IO.Temp (withSystemTempFile)
import System.Posix.Files (setFileMode)
import System.Posix.Process (executeFile)
import System.Posix.Process
import System.Which

searchScript :: Text
searchScript = $(embedOneStringFileOf ["./src-bash/neuron-search", "./neuron/src-bash/neuron-search"])
neuronSearchScript :: FilePath
neuronSearchScript = $(staticWhich "neuron-search")

searchScriptArgs :: (NonEmpty ZettelFormat) -> SearchCommand -> [String]
searchScriptArgs formats SearchCommand {..} =
Expand All @@ -47,16 +43,8 @@ interactiveSearch notesDir searchCmd config =
zettelFormats <- getZettelFormats config
if searchBy searchCmd == SearchByTitle && ZettelFormat_Org `elem` toList zettelFormats
then fail "search is not supported for .org files"
else liftIO $ do
asExecutableScript "neuron-search" searchScript $ \scriptFile -> do
execScript scriptFile $ notesDir : searchScriptArgs zettelFormats searchCmd
else liftIO $ execScript neuronSearchScript $ notesDir : searchScriptArgs zettelFormats searchCmd
where
asExecutableScript k s f =
withSystemTempFile k $ \fp hdl -> do
hPutStr hdl s
hClose hdl
setFileMode fp 0o700
f fp
execScript scriptPath args =
-- We must use the low-level execvp (via the unix package's `executeFile`)
-- here, such that the new process replaces the current one. fzf won't work
Expand Down