Code Monkey home page Code Monkey logo

company-statistics's Introduction

company-statistics's People

Contributors

dgutov avatar ilohmar avatar stardiviner avatar syohex 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  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  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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

company-statistics's Issues

company statistics in all buffer

Here I have some troubles when i using the company-statistics,

I can only using the company-statistics in the text-mode, but the other program mode or org-mode.

can u give some advice about this , thank you

Don't store buffer-file-name?

It seems to me it fattens the database unnecessarily. Do you really consider having different statistics between different files in the same major mode, in the same project, important?

If the database has space to spare, I'd try to store more context instead. Such as "previous word", or "last preceding keyword".

Make score calc features customizable

Would you consider making the features (e.g., :keyword, :symbol and :file) used by the scoring functions customizable?

I created my own context/calc/change functions that duplicate a lot of stuff from the default versions but primarily introduces an additional customizable variable where I tweak the features used to score candidates. It looks something like this:

;; :total, :mode, :lookup-prefix and :file are the features I use (in place of :keyword,
;; :symbol and :file).
;; The keywords following each of them define how they are captured, incremented and
;; summed to calculate the score.
(setq dg-company-statistics-default-features
      `(
        (total
         (:get-context . t)
         (:incr . 1))

        (mode
         (:get-context . (dg-company-statistics-get-effective-major-mode))
         (:incr . 1))

        (lookup-prefix
         (:get-context . (dg-company-statistics-lookup-prefix))
         (:weight . 5)
         (:incr . 1))

        (file
         (:get-context . buffer-file-name)
         (:incr . 1))
        ))

I think the statistics could be much smarter but requires making use of more features, many of which would be specific to certain major modes. In order to make it worthwhile developing a statistically robust candidate scoring function utilising this, it needs to be general enough to share among multiple modes. Therefore, the context/change/score function implementations ought to be decoupled from the features.

If you would consider this, I could look at adapting my configuration so that company-statistics would still work the same way by default but the :keyword, :file and :symbol features would be pulled out of the default functions and placed into a new customizable alist similar to the one above.

MELPA

Are there any objections to putting company-statistics on MELPA?

Select instead of sort.

Do you think you can implement this feature? Just select the top most possible candidate instead of sort the completion? I think this is base on the personal habit and some editor do have this kind of feature. :D

Instead of changing this list.

+-------+
| var2  |    <-- Candidate sorted!
+-------+
| var1  |
+-------+

Just make the current selection to that candidate!

+-------+
| var1  |
+-------+
| var2  |    <-- Highlight/Select this one!
+-------+

Errors in message-mode

Whenever I'm composing a mail message in message-mode, company keeps giving me errors about args out of range. After turning on debug-on-error, it seems that these are coming from company-statistics:

Debugger entered--Lisp error: (args-out-of-range 1156 1156)
  get-text-property(1156 face)
  company-statistics--last-keyword()
  company-statistics-capture-context-heavy(nil)
  company-statistics--start(nil)
  run-hook-with-args(company-statistics--start nil)
  company--begin-new()
  company--perform()
  company-auto-begin()
  company-idle-begin(#<buffer *unsent wide reply to John Wiegley*> #<window 505 on *unsent wide reply to John Wiegley*> 489 1914)
  apply(company-idle-begin (#<buffer *unsent wide reply to John Wiegley*> #<window 505 on *unsent wide reply to John Wiegley*> 489 1914))
  timer-event-handler([t 22083 3170 583720 nil company-idle-begin (#<buffer *unsent wide reply to John Wiegley*> #<window 505 on *unsent wide reply to John Wiegley*> 489 1914) nil 230000])

Update statistics even if completion not accepted

I've noticed that company-statistics's statistics are only updated when I explicitly accept a suggestion from company-mode, and not when I implicitly accept the suggestion by typing in the entire match.

For example, let's say I type in agg and get lots of matches from company because I have aggressive-indent-mode installed. Now, what I really want is aggressive-indent-mode, so I type that in and press SPC. But then the next time I type in agg, aggressive-indent-mode is not at the top of the list, since I did not explicitly accept the suggestion from company for aggressive-indent-mode and therefore company-statistics did not update.

My workaround is to force myself to explicitly accept suggestions from company-mode when I think that I might want them to be at the top of the list next time. But I can't think of any downsides to also updating the statistics database if the user happens to type in something that matches one of the company-mode suggestions and then dismisses the company-mode menu—at the very least the data would be much more rich, and company-statistics would appear to be smarter.

Produces (wrong-type-argument hash-table-p nil)

I tested this on in an emacs24.4 -Q typing ema in *scratch* gives me the following error:

Debugger entered--Lisp error: (wrong-type-argument hash-table-p nil)
  gethash(#("emacs-build-system" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) nil)
  company-statistics-score-calc-default(#("emacs-build-system" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))))
  #[(cand1 cand2) "�    !�\n!V\207" [company-statistics-score-calc cand1 cand2] 3](#("emacs-build-system" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-basic-display" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))))
  sort((#("emacs" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference)))) #[(cand1 cand2) "�   !�\n!V\207" [company-statistics-score-calc cand1 cand2] 3])
  company-sort-by-statistics((#("emacs" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference)))))
  company--transform-candidates((#("emacs" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference)))))
  company--postprocess-candidates((#("emacs" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-basic-display" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-build-system" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-build-time" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-byte-compile-and-load" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-bzr-get-version" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-bzr-version" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-bzr-version-bzr" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-bzr-version-dirstate" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-copyright" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-faq" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-index-search" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-init-time" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-known-problems" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-byte-code-comment" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-byte-code-mode" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-byte-code-mode-abbrev-table" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-byte-code-mode-hook" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-byte-code-mode-map" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-byte-code-mode-syntax-table" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-byte-code-syntax-propertize" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-byte-compile" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-byte-compile-and-load" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-docstring-fill-column" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-intro" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-mode" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-mode-abbrev-table" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-mode-hook" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-mode-map" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-mode-syntax-table" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lisp-reference" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-list-byte-code-comment-re" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lock" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-lock-mode" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-major-version" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-manual" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-manual-bug" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-minor-version" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-mule-charset-table" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-news" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-pid" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-psychotherapist" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-repository-get-version" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-repository-version" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-save-session-functions" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-session-filename" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-session-restore" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-session-save" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) #("emacs-startup-hook" 0 3 (face (completions-common-part)) 3 4 (face (completions-first-difference))) ...))
  company-calculate-candidates("ema")
  #[0 "\n\203   �\nC\202\n��\211\205\245�\211@\300�9\204��\306�!\203<��9\2036��\307N\310=\2046��\307N?\205@�\311�!\205@��\312!\202@�\313�\312\"\240\210\300\242\203\236�\314\300\242!\203\230�\315\300\242!�\211�\301\316\f!\240\210\301\242:\204l�
\203\230�\317\320!\210\202\230�
\203t�\300\242��\2119\203\203�\321\322�!P��\202\211�\323\301\242@!\210\324\301\242!\210\325\326\327 \"\210\330\331!\210\332\333\301\242\"\210�A\266\202\202\n\207" [("ema") (nil) company-backend company-backends company-prefix company--manual-action functionp company-init t company-init-backend prefix company--multi-backend-adapter company--good-prefix-p company--prefix-str company-calculate-candidates message "No completion found" " " symbol-name company--update-group-lighter company-update-candidates run-hook-with-args company-completion-started-hook company-explicit-action-p company-call-frontends show throw --cl-block-nil-- company--manual-prefix company-lighter] 6 "\n\n(fn)"]()
  funcall(#[0 "\n\203   �\nC\202\n��\211\205\245�\211@\300�9\204��\306�!\203<��9\2036��\307N\310=\2046��\307N?\205@�\311�!\205@��\312!\202@�\313�\312\"\240\210\300\242\203\236�\314\300\242!\203\230�\315\300\242!�\211�\301\316\f!\240\210\301\242:\204l�
\203\230�\317\320!\210\202\230�
\203t�\300\242��\2119\203\203�\321\322�!P��\202\211�\323\301\242@!\210\324\301\242!\210\325\326\327 \"\210\330\331!\210\332\333\301\242\"\210�A\266\202\202\n\207" [("ema") (nil) company-backend company-backends company-prefix company--manual-action functionp company-init t company-init-backend prefix company--multi-backend-adapter company--good-prefix-p company--prefix-str company-calculate-candidates message "No completion found" " " symbol-name company--update-group-lighter company-update-candidates run-hook-with-args company-completion-started-hook company-explicit-action-p company-call-frontends show throw --cl-block-nil-- company--manual-prefix company-lighter] 6 "\n\n(fn)"])
  company--begin-new()
  company--perform()
  #[0 "\301 \210�\207" [company-candidates company--perform] 1 "\n\n(fn)"]()
  funcall(#[0 "\301 \210�\207" [company-candidates company--perform] 1 "\n\n(fn)"])
  company-auto-begin()
  company-idle-begin(#<buffer *scratch*> #<window 3 on *scratch*> 17 195)
  apply(company-idle-begin (#<buffer *scratch*> #<window 3 on *scratch*> 17 195))
  byte-code("r\301�\302H�\303H\"\210)\301\207" [timer apply 5 6] 4)
  timer-event-handler([t 21706 50670 561573 nil company-idle-begin (#<buffer *scratch*> #<window 3 on *scratch*> 17 195) nil 279000])

Disables the completion popup list

Enabling this minor mode seems to disable the completion popup list, disabling the minor mode reenables the popup.

I am not sure whether this is by design or an issue. Keeping the popup dialog unaffected seems to be the preferred choice.

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.