;; Author: Nikolaj Schumacher
;; Maintainer: Dmitry Gutov <dgutov@yandex.ru>
-;; Version: 0.6.7
+;; Version: 0.6.8
;; Keywords: abbrev, convenience, matching
;; URL: http://company-mode.github.com/
;; Compatibility: GNU Emacs 22.x, GNU Emacs 23.x, GNU Emacs 24.x
(:background "cornsilk"))
(((class color) (min-colors 88) (background dark))
(:background "yellow")))
- "Face used for the tool tip."
- :group 'company)
+ "Face used for the tooltip.")
(defface company-tooltip-selection
'((default :inherit company-tooltip)
(((class color) (min-colors 88) (background dark))
(:background "orange1"))
(t (:background "green")))
- "Face used for the selection in the tool tip."
- :group 'company)
+ "Face used for the selection in the tooltip.")
(defface company-tooltip-mouse
'((default :inherit highlight))
- "Face used for the tool tip item under the mouse."
- :group 'company)
+ "Face used for the tooltip item under the mouse.")
(defface company-tooltip-common
'((default :inherit company-tooltip)
:foreground "darkred")
(((background dark))
:foreground "red"))
- "Face used for the common completion in the tool tip."
- :group 'company)
+ "Face used for the common completion in the tooltip.")
(defface company-tooltip-common-selection
'((default :inherit company-tooltip-selection)
:foreground "darkred")
(((background dark))
:foreground "red"))
- "Face used for the selected common completion in the tool tip."
- :group 'company)
+ "Face used for the selected common completion in the tooltip.")
(defface company-preview
'((t :background "blue4"
:foreground "wheat"))
- "Face used for the completion preview."
- :group 'company)
+ "Face used for the completion preview.")
(defface company-preview-common
'((t :inherit company-preview
:foreground "red"))
- "Face used for the common part of the completion preview."
- :group 'company)
+ "Face used for the common part of the completion preview.")
(defface company-preview-search
'((t :inherit company-preview
:background "blue1"))
- "Face used for the search string in the completion preview."
- :group 'company)
+ "Face used for the search string in the completion preview.")
(defface company-echo nil
- "Face used for completions in the echo area."
- :group 'company)
+ "Face used for completions in the echo area.")
(defface company-echo-common
'((((background dark)) (:foreground "firebrick1"))
(((background light)) (:background "firebrick4")))
- "Face used for the common part of completions in the echo area."
- :group 'company)
+ "Face used for the common part of completions in the echo area.")
(defun company-frontends-set (variable value)
;; uniquify
`company-common', `company-selection', `company-point' and
`company-search-string'."
:set 'company-frontends-set
- :group 'company
:type '(repeat (choice (const :tag "echo" company-echo-frontend)
(const :tag "echo, strip common"
company-echo-strip-common-frontend)
(function :tag "custom function" nil))))
(defcustom company-tooltip-limit 10
- "The maximum number of candidates in the tool tip"
- :group 'company
+ "The maximum number of candidates in the tooltip"
:type 'integer)
(defcustom company-tooltip-minimum 6
- "The minimum height of the tool tip.
+ "The minimum height of the tooltip.
If this many lines are not available, prefer to display the tooltip above."
- :group 'company
:type 'integer)
(defvar company-safe-backends
'((company-abbrev . "Abbrev")
- (company-clang . "clang")
+ (company-clang . "Clang")
(company-css . "CSS")
(company-dabbrev . "dabbrev for plain text")
(company-dabbrev-code . "dabbrev for code")
- (company-eclim . "eclim (an Eclipse interace)")
+ (company-eclim . "Eclim (an Eclipse interface)")
(company-elisp . "Emacs Lisp")
(company-etags . "etags")
(company-files . "Files")
(company-gtags . "GNU Global")
- (company-ispell . "ispell")
+ (company-ispell . "Ispell")
(company-keywords . "Programming language keywords")
(company-nxml . "nxml")
(company-oddmuse . "Oddmuse")
(company-pysmell . "PySmell")
(company-ropemacs . "ropemacs")
- (company-semantic . "CEDET Semantic")
+ (company-semantic . "Semantic")
(company-tempo . "Tempo templates")
(company-xcode . "Xcode")))
(put 'company-safe-backends 'risky-local-variable t)
(plist-get (nthcdr 4 res) :predicate)))))))
(defcustom company-backends '(company-elisp company-nxml company-css
- company-clang company-semantic company-eclim
+ company-semantic company-clang company-eclim
company-xcode company-ropemacs
(company-gtags company-etags company-dabbrev-code
company-keywords)
The back-end should return nil for all commands it does not support or
does not know about. It should also be callable interactively and use
`company-begin-backend' to start itself in that case."
- :group 'company
:type `(repeat
(choice
:tag "Back-end"
"Hook run when company starts completing.
The hook is called with one argument that is non-nil if the completion was
started manually."
- :group 'company
:type 'hook)
(defcustom company-completion-cancelled-hook nil
"Hook run when company cancels completing.
The hook is called with one argument that is non-nil if the completion was
aborted manually."
- :group 'company
:type 'hook)
(defcustom company-completion-finished-hook nil
If you indend to use it to post-process candidates from a specific back-end,
consider using the `post-completion' command instead."
- :group 'company
:type 'hook)
(defcustom company-minimum-prefix-length 3
"The minimum prefix length for automatic completion."
- :group 'company
:type '(integer :tag "prefix length"))
(defcustom company-require-match 'company-explicit-action-p
This can be overridden by the back-end, if it returns t or 'never to
'require-match. `company-auto-complete' also takes precedence over this."
- :group 'company
:type '(choice (const :tag "Off" nil)
(function :tag "Predicate function")
(const :tag "On, if user interaction took place"
'company-explicit-action-p)
(const :tag "On" t)))
-(defcustom company-auto-complete 'company-explicit-action-p
+(defcustom company-auto-complete nil
"Determines when to auto-complete.
If this is enabled, all characters from `company-auto-complete-chars' complete
the selected completion. This can also be a function."
- :group 'company
:type '(choice (const :tag "Off" nil)
(function :tag "Predicate function")
(const :tag "On, if user interaction took place"
'company-explicit-action-p)
(const :tag "On" t)))
-(defcustom company-auto-complete-chars '(?\ ?\( ?\) ?. ?\" ?$ ?\' ?< ?| ?!)
+(defcustom company-auto-complete-chars '(?\ ?\) ?.)
"Determines which characters trigger an automatic completion.
See `company-auto-complete'. If this is a string, each string character causes
completion. If it is a list of syntax description characters (see
return non-nil if company should auto-complete.
A character that is part of a valid candidate never triggers auto-completion."
- :group 'company
:type '(choice (string :tag "Characters")
(set :tag "Syntax"
(const :tag "Whitespace" ?\ )
"The idle delay in seconds until automatic completions starts.
A value of nil means never complete automatically, t means complete
immediately when a prefix of `company-minimum-prefix-length' is reached."
- :group 'company
:type '(choice (const :tag "never (nil)" nil)
(const :tag "immediate (t)" t)
(number :tag "seconds")))
Alternatively any command with a non-nil 'company-begin property is treated as
if it was on this list."
- :group 'company
:type '(choice (const :tag "Any command" t)
(const :tag "Self insert command" '(self-insert-command))
(repeat :tag "Commands" function)))
(defcustom company-show-numbers nil
"If enabled, show quick-access numbers for the first ten candidates."
- :group 'company
:type '(choice (const :tag "off" nil)
(const :tag "on" t)))
(eq company-require-match t))
(not (eq backend-value 'never))))))
-(defun company-punctuation-p (input)
- "Return non-nil, if input starts with punctuation or parentheses."
- (memq (char-syntax (string-to-char input)) '(?. ?\( ?\))))
-
(defun company-auto-complete-p (input)
"Return non-nil, if input starts with punctuation or parentheses."
(and (if (functionp company-auto-complete)
(company-abort)
(company--unread-last-input)))
+(defun company--inside-tooltip-p (event-col-row ovl-row)
+ (when company-pseudo-tooltip-overlay
+ (let* ((ovl company-pseudo-tooltip-overlay)
+ (column (overlay-get ovl 'company-column))
+ (width (overlay-get ovl 'company-width))
+ (height (overlay-get ovl 'company-height))
+ (evt-col (car event-col-row))
+ (evt-row (cdr event-col-row)))
+ (and (>= evt-col column)
+ (< evt-col (+ column width))
+ (> evt-row ovl-row)
+ (<= evt-row (+ ovl-row height) )))))
+
(defun company-select-mouse (event)
"Select the candidate picked by the mouse."
(interactive "e")
- (when (nth 4 (event-start event))
- (company-set-selection (- (cdr (posn-actual-col-row (event-start event)))
- (company--row)
- 1))
- t))
+ (let ((event-col-row (posn-actual-col-row (event-start event)))
+ (ovl-row (company--row)))
+ (if (company--inside-tooltip-p event-col-row ovl-row)
+ (progn
+ (company-set-selection (- (cdr event-col-row)
+ (if (zerop company-tooltip-offset)
+ 1
+ (- 2 company-tooltip-offset))
+ ovl-row))
+ t)
+ (company-abort)
+ (company--unread-last-input)
+ nil)))
(defun company-complete-mouse (event)
"Complete the candidate picked by the mouse."
(defun company-buffer-lines (beg end)
(goto-char beg)
(let (lines)
- (while (and (= 1 (vertical-motion 1))
- (<= (point) end))
- (push (buffer-substring beg (min end (1- (point)))) lines)
- (setq beg (point)))
- (unless (eq beg end)
- (push (buffer-substring beg end) lines))
+ (while (< (point) end)
+ (let ((bol (point)))
+ ;; A visual line can contain several physical lines (e.g. with outline's
+ ;; folding overlay). Take only the first one.
+ (re-search-forward "$")
+ (push (buffer-substring bol (min end (point))) lines))
+ (vertical-motion 1))
(nreverse lines)))
(defsubst company-modify-line (old new offset)
(setq company-pseudo-tooltip-overlay ov)
(overlay-put ov 'company-replacement-args args)
- (overlay-put ov 'company-before
- (apply 'company--replacement-string
- (company--create-lines selection (abs height))
- args))
+
+ (let ((lines (company--create-lines selection (abs height))))
+ (overlay-put ov 'company-before
+ (apply 'company--replacement-string lines args))
+ (overlay-put ov 'company-width (string-width (car lines))))
(overlay-put ov 'company-column column)
(overlay-put ov 'company-height height)))))
company-selection))))
(defun company-pseudo-tooltip-edit (lines selection)
- (let ((column (overlay-get company-pseudo-tooltip-overlay 'company-column))
- (height (overlay-get company-pseudo-tooltip-overlay 'company-height)))
+ (let ((height (overlay-get company-pseudo-tooltip-overlay 'company-height)))
(overlay-put company-pseudo-tooltip-overlay 'company-before
(apply 'company--replacement-string
(company--create-lines selection (abs height))
(defun company-pseudo-tooltip-unhide ()
(when company-pseudo-tooltip-overlay
(overlay-put company-pseudo-tooltip-overlay 'invisible t)
+ ;; Beat outline's folding overlays, at least.
+ (overlay-put company-pseudo-tooltip-overlay 'priority 1)
(overlay-put company-pseudo-tooltip-overlay 'before-string
(overlay-get company-pseudo-tooltip-overlay 'company-before))
(overlay-put company-pseudo-tooltip-overlay 'window (selected-window))))
(point) (overlay-start company-pseudo-tooltip-overlay)))
(defun company-pseudo-tooltip-frontend (command)
- "`company-mode' front-end similar to a tool-tip but based on overlays."
+ "`company-mode' front-end similar to a tooltip but based on overlays."
(case command
(pre-command (company-pseudo-tooltip-hide-temporarily))
(post-command