Git Product home page Git Product logo

microfts's People

Contributors

stardiviner avatar zot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sje30 devexpert10

microfts's Issues

Searching just for org headings?

Hi,
thanks for this neat project.

Is there a way to restrict a search just for org mode headings rather than the entire file? I saw in #6 mention of searching by headlines?

Thanks.

does search -partial work?

I have a db setup so that this command

./microfts search ../cache/fts.db hashtag

yields this result
: /Users/jkitchin/Dropbox/emacs/microfts/examples/one.org:7:And #one hashtag.

But this command yields no result

./microfts search ../cache/fts.db -partial hash

I thought it would give me the same match. Is this expected for -partial?

Move Ivy support to its own package.

It's better to implement as much as possible using Emac's default completion interface.
Ivy (or any other) completion specific code should be it's own package. e.g. ivy-microfts or helm-microfts

multiple search terms only match when they are in the same line

This may not be a bug. I use the default microfts input with no flags to index the files. The file one.org has the words "example" and "hashtag" in them, but not on the same line. So the first two searches below work where both words are in a single line. But the last one returns nothing, which was a surprise to me.

./microfts search -u ../cache/fts.db one example

#+RESULTS:
: /Users/jkitchin/Dropbox/emacs/microfts/examples/one.org:3:This is the first example with a one in it.

./microfts search -u ../cache/fts.db one hashtag

#+RESULTS:
: /Users/jkitchin/Dropbox/emacs/microfts/examples/one.org:7:And #one hashtag.

./microfts search -u ../cache/fts.db example hashtag

DB never updated

I'm having the problem, that the DB is never automatically updated. I can create and update the DB from the command line, but the function never gets called when I open and/or save an org-file in emacs.

Non Latin scripts

Hi. Wanted to ask if this should work with non Latin scripts. I've installed and quickly tested and it seems it will not find anything searching for texts in Hebrew or Arabic. I only had spent a short time testing so sorry if I'm missing something here.

missing input files generate a panic

Hi,
If /tmp/tst is missing (I had created /tmp/test by mistake, following your README), I get a panic. The panic message explains the error, but then it is followed by a long
backtrace (truncated below).

./microfts input -file /tmp/bubba /tmp/tst
panic: Error: stat /tmp/tst: no such file or directory, args: [/tmp/bubba /tmp/tst]

goroutine 1 [running]:
main.check(0x59fe60, 0xc00007a720)
        /home/bill/work/microfts/fulltext.go:205 +0x150
main.(*lmdbConfigStruct).openInputFile(0x686980, 0x7fff9d4de550, 0x8, 0xc00013baa0, 0x4e740c, 0x7f9cec003ffb, 0x4)
        /home/bill/work/microfts/fts-lmdb.go:535 +0x79
main.(*lmdbConfigStruct).indexLines(0x686980, 0x7fff9d4de550, 0x8)
        /home/bill/work/microfts/fts-lmdb.go:579 +0x5d
main.(*lmdbConfigStruct).index(0x686980, 0x7fff9d4de550, 0x8)
        /home/bill/work/microfts/fts-lmdb.go:529 +0x6f
main.cmdInput.func1()

Run checkdoc/package-lint

Both of these tools will help bring your library in line with Elisp conventions.

checkdoc reports 20 errors:
 org-fts.el    25     info            White space found at end of line (emacs-lisp-checkdoc)
 org-fts.el    40     info            First sentence should end with punctuation (emacs-lisp-checkdoc)
 org-fts.el    45     info            First sentence should end with punctuation (emacs-lisp-checkdoc)
 org-fts.el    50     info            First sentence should end with punctuation (emacs-lisp-checkdoc)
 org-fts.el    60     info            First sentence should end with punctuation (emacs-lisp-checkdoc)
 org-fts.el    60     info            First line should be capitalized (emacs-lisp-checkdoc)
 org-fts.el    69     info            First sentence should end with punctuation (emacs-lisp-checkdoc)
 org-fts.el    69     info            First line should be capitalized (emacs-lisp-checkdoc)
 org-fts.el    69     info            Argument ‘item’ should appear (as ITEM) in the doc string (emacs-lisp-checkdoc)
 org-fts.el    76     info            First sentence should end with punctuation (emacs-lisp-checkdoc)
 org-fts.el    76     info            Lisp symbol ‘org-mode’ should appear in quotes (emacs-lisp-checkdoc)
 org-fts.el    86     info            First sentence should end with punctuation (emacs-lisp-checkdoc)
 org-fts.el    86     info            Lisp symbol ‘org-mode’ should appear in quotes (emacs-lisp-checkdoc)
 org-fts.el   103     info            First sentence should end with punctuation (emacs-lisp-checkdoc)
 org-fts.el   115     info            All variables and subroutines might as well have a documentation string (emacs-lisp-checkdoc)
 org-fts.el   136     info            All variables and subroutines might as well have a documentation string (emacs-lisp-checkdoc)
 org-fts.el   146     info            All variables and subroutines might as well have a documentation string (emacs-lisp-checkdoc)
 org-fts.el   163     info            First sentence should end with punctuation (emacs-lisp-checkdoc)
 org-fts.el   175     info            First sentence should end with punctuation (emacs-lisp-checkdoc)
 org-fts.el   192     info            First sentence should end with punctuation (emacs-lisp-checkdoc)
46 package-lint issues found:
46 issues found:

1:71: warning: You should depend on (emacs "24.1") if you need lexical-binding.
8:0: error: Expected (package-name "version-num"), but found cl-lib.
8:0: error: Expected (package-name "version-num"), but found executable.
8:0: error: Expected (package-name "version-num"), but found ivy.
8:0: error: Expected (package-name "version-num"), but found org.
8:0: error: Expected (package-name "version-num"), but found package.
11:0: error: Package should have a non-empty ;;; Commentary section.
15:10: error: You should depend on (emacs "24.3") or the cl-lib package if you need `cl-lib'.
18:10: error: You should depend on (emacs "24.1") if you need `package'.
25:0: error: `org-fts/microfts-url-alist' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
30:0: error: `org-fts/baseprogram-alist' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
35:0: error: `org-fts/baseprogram' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
39:0: error: `org-fts/program' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
44:0: error: `org-fts/db' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
49:0: error: `org-fts/search-args' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
54:0: error: `org-fts/hits' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
55:0: error: `org-fts/args' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
56:0: error: `org-fts/timer' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
57:0: error: `org-fts/actual-program' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
59:0: error: `org-fts/check-db' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
68:0: error: `org-fts/test' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
75:0: error: `org-fts/save-hook' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
85:0: error: `org-fts/open-hook' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
102:0: error: `org-fts/idle-task' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
114:0: error: `org-fts/microfts-search' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
131:47: error: You should depend on (emacs "24.3") if you need `file-name-base'.
133:14: warning: Closing parens should not be wrapped onto new lines.
135:0: error: `org-fts/found' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
139:38: error: You should depend on (emacs "27.1") if you need `org-show-all'.
142:0: error: `org-fts/history' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
143:0: error: `org-fts/file-history' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
145:0: error: `org-fts/display' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
146:18: error: You should depend on (emacs "24.3") or the cl-lib package if you need `cl-search'.
147:18: error: You should depend on (emacs "24.3") or the cl-lib package if you need `cl-search'.
152:5: error: You should depend on (emacs "24.3") or the cl-lib package if you need `cl-do'.
152:18: error: You should depend on (emacs "24.3") or the cl-lib package if you need `cl-incf'.
154:9: error: You should depend on (emacs "24.3") or the cl-lib package if you need `cl-do'.
154:20: error: You should depend on (emacs "24.3") or the cl-lib package if you need `cl-search'.
154:55: error: You should depend on (emacs "24.3") or the cl-lib package if you need `cl-search'.
162:0: error: `org-fts/search' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
174:0: error: `org-fts/find-org-file' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
184:20: error: You should depend on (emacs "25.1") or the seq package if you need `seq-filter'.
185:37: error: You should depend on (emacs "25.1") or the seq package if you need `seq-sort'.
186:49: error: You should depend on (emacs "25.1") if you need `string-collate-lessp'.
191:0: error: `org-fts/ensure-binary' contains a non-standard separator `/', use hyphens instead (see Elisp Coding Conventions).
217:20: error: You should depend on (emacs "24.4") if you need `zlib-decompress-region'.

automatic filter options

Make combinable options that set the filter:

  • -select-paragraph
  • -select-headline
  • ...
  • -invert-selection -- select everything you don't specify

Feature request - one line per search result for completion tools in Emacs

To use asynchronous search with completion tools like ivy/helm, we need the search command to output one complete line per result. I think you want something like:

(:filename path :line line-number :offset integer :text "matched chunk" :percent float)

I used a plist there, but other forms would work too, as long as you can "read" them in emacs.

for each match. Then you can use a transformer function in ivy to convert that to what you want to do completion on.

Note this is already supported in the vanilla search output which does output a line per result, but you have to parse that line to use it, and that isn't as reliable as using read in emacs. Also, it only outputs the line number so you can't jump to the match with offset.

microfts doesn't handle org source blocks

The org parser/chunker in microfts seems to get confused by source blocks. When searching for a term that appears in a file with source blocks, the search UI displays just one huge line with the first source block for the org file (and none of the other matches). The screen shot shows a situation, where many lines in the file match "sphinx". In this case, the source block doesn't even have a match for the search term (it looks like the org parser squeezed all text into the source block chunk).

Bildschirmfoto 2021-01-16 um 14 44 14

A simple workaround obviously is to remove -org from org-fts-input-args, which I did (and it's still very useful then, but not quite what you intended, I guess).

Here is a shell transcript of reproducing this from the command line:

$ THIS IS WRONG
$ rm org-fts.db
$ ./microfts create org-fts.db
$ ./microfts input -org org-fts.db ~/org/links.org
$ ./microfts search org-fts.db sphinx | cut -c -80
~/org/links.org:29:    #+begin_src python\n      import sys, 

$ WITHOUT ORG PARSING (same input file)
$ rm org-fts.db
$ ./microfts create org-fts.db
$ ./microfts input org-fts.db ~/org/links.org
$ ./microfts search org-fts.db sphinx | cut -c -80
~/org/links.org:682:** Sphinx
~/org/links.org:684:*** Requirements, Bugs, Test cases, … ins
~/org/links.org:688:*** Why use reStructuredText and Sphinx s
~/org/links.org:695:    documents, then Sphinx (or any of Mar
~/org/links.org:698:    sphinx-static-site-generator-for-main
...

I looked into the code, but my Go fu is moot, so no patch, sorry ...

runtime error on certain org files (minimal example included)

I get a runtime error on certain org files. A minimal org file that shows the error is the following:

#+STARTUP: hidestars

  • Reading
    ** Q
    • a

And here is the backtrace

$ ./microfts input -org /tmp/db.db /tmp/a.org
panic: runtime error: slice bounds out of range [1:0]

goroutine 1 [running]:
main.orgPart(0x24, 0xc000020180, 0x2b, 0x23, 0xc00002019f, 0x4)
/home/dicosmo/code/microfts/fulltext.go:144 +0x5cf
main.forParts(0xc000020180, 0x2b, 0xc000143bc0)
/home/dicosmo/code/microfts/fulltext.go:108 +0xf7
main.(*lmdbConfigStruct).indexOrg(0x665de0, 0x7ffceb819254, 0xa)
/home/dicosmo/code/microfts/fts-lmdb.go:554 +0x18f
main.(*lmdbConfigStruct).index(0x665de0, 0x7ffceb819254, 0xa)
/home/dicosmo/code/microfts/fts-lmdb.go:527 +0x48
main.cmdInput.func1()
/home/dicosmo/code/microfts/fts-lmdb.go:518 +0x4f
main.(*lmdbConfigStruct).update.func1.1()
/home/dicosmo/code/microfts/fts-lmdb.go:1682 +0x2f
main.(*lmdbConfigStruct).runTxn(0x665de0, 0xc00002cc40, 0x0, 0xc000143d08)
/home/dicosmo/code/microfts/fts-lmdb.go:1720 +0x1d0
main.(*lmdbConfigStruct).update.func1(0xc00002cc40, 0xc00002cc40, 0x0)
/home/dicosmo/code/microfts/fts-lmdb.go:1681 +0x72
github.com/AskAlexSharov/lmdb-go/lmdb.(*Txn).runOpTerm(0xc00002cc40, 0xc000143df0, 0x0, 0x0)
/home/dicosmo/go/pkg/mod/github.com/!ask!alex!sharov/[email protected]/lmdb/txn.go:158 +0x6e
github.com/AskAlexSharov/lmdb-go/lmdb.(*Env).run(0xc00007a6f0, 0x1, 0x0, 0xc000143df0, 0x0, 0x0)
/home/dicosmo/go/pkg/mod/github.com/!ask!alex!sharov/[email protected]/lmdb/env.go:515 +0xbb
github.com/AskAlexSharov/lmdb-go/lmdb.(*Env).Update(...)
/home/dicosmo/go/pkg/mod/github.com/!ask!alex!sharov/[email protected]/lmdb/env.go:482
main.(*lmdbConfigStruct).update(0x665de0, 0xc000143e70)
/home/dicosmo/code/microfts/fts-lmdb.go:1680 +0x77
main.cmdInput(0x665de0)
/home/dicosmo/code/microfts/fts-lmdb.go:516 +0x19e
main.runLmdb(0xc000070180)
/home/dicosmo/code/microfts/fts-lmdb.go:210 +0x3be
main.main()
/home/dicosmo/code/microfts/fulltext.go:357 +0xc6f

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.