]> code.delx.au - gnu-emacs-elpa/blob - company.el
Protect against errors.
[gnu-emacs-elpa] / company.el
1 (eval-when-compile (require 'cl))
2
3 (add-to-list 'debug-ignored-errors
4 "^Pseudo tooltip frontend cannot be used twice$")
5 (add-to-list 'debug-ignored-errors "^Preview frontend cannot be used twice$")
6 (add-to-list 'debug-ignored-errors "^Echo area cannot be used twice$")
7 (add-to-list 'debug-ignored-errors "^No documentation available$")
8
9 (defgroup company nil
10 ""
11 :group 'abbrev
12 :group 'convenience
13 :group 'maching)
14
15 (defface company-tooltip
16 '((t :background "yellow"
17 :foreground "black"))
18 "*"
19 :group 'company)
20
21 (defface company-tooltip-selection
22 '((t :background "orange1"
23 :foreground "black"))
24 "*"
25 :group 'company)
26
27 (defface company-tooltip-common
28 '((t :inherit company-tooltip
29 :foreground "red"))
30 "*"
31 :group 'company)
32
33 (defface company-tooltip-common-selection
34 '((t :inherit company-tooltip-selection
35 :foreground "red"))
36 "*"
37 :group 'company)
38
39 (defcustom company-tooltip-limit 10
40 "*"
41 :group 'company
42 :type 'integer)
43
44 (defface company-preview
45 '((t :background "blue4"
46 :foreground "wheat"))
47 "*"
48 :group 'company)
49
50 (defface company-preview-common
51 '((t :inherit company-preview
52 :foreground "red"))
53 "*"
54 :group 'company)
55
56 (defface company-echo nil
57 "*"
58 :group 'company)
59
60 (defface company-echo-common
61 '((((background dark)) (:foreground "firebrick1"))
62 (((background light)) (:background "firebrick4")))
63 "*"
64 :group 'company)
65
66 (defun company-frontends-set (variable value)
67 ;; uniquify
68 (let ((remainder value))
69 (setcdr remainder (delq (car remainder) (cdr remainder))))
70 (and (memq 'company-pseudo-tooltip-unless-just-one-frontend value)
71 (memq 'company-pseudo-tooltip-frontend value)
72 (error "Pseudo tooltip frontend cannot be used twice"))
73 (and (memq 'company-preview-if-just-one-frontend value)
74 (memq 'company-preview-frontend value)
75 (error "Preview frontend cannot be used twice"))
76 (and (memq 'company-echo value)
77 (memq 'company-echo-metadata-frontend value)
78 (error "Echo area cannot be used twice"))
79 ;; preview must come last
80 (dolist (f '(company-preview-if-just-one-frontend company-preview-frontend))
81 (when (memq f value)
82 (setq value (append (delq f value) (list f)))))
83 (set variable value))
84
85 (defcustom company-frontends '(company-pseudo-tooltip-unless-just-one-frontend
86 company-preview-if-just-one-frontend
87 company-echo-metadata-frontend)
88 "*"
89 :set 'company-frontends-set
90 :group 'company
91 :type '(repeat (choice (const :tag "echo" company-echo-frontend)
92 (const :tag "pseudo tooltip"
93 company-pseudo-tooltip-frontend)
94 (const :tag "pseudo tooltip, multiple only"
95 company-pseudo-tooltip-unless-just-one-frontend)
96 (const :tag "preview" company-preview-frontend)
97 (const :tag "preview, unique only"
98 company-preview-if-just-one-frontend)
99 (function :tag "custom function" nil))))
100
101 (defcustom company-backends '(company-elisp company-nxml company-css
102 company-semantic company-oddmuse company-ispell)
103 "*"
104 :group 'company
105 :type '(repeat (function :tag "function" nil)))
106
107 (defcustom company-minimum-prefix-length 3
108 "*"
109 :group 'company
110 :type '(integer :tag "prefix length"))
111
112 (defvar company-timer nil)
113
114 (defun company-timer-set (variable value)
115 (set variable value)
116 (when company-timer (cancel-timer company-timer))
117 (when (numberp value)
118 (setq company-timer (run-with-idle-timer value t 'company-idle-begin))))
119
120 (defcustom company-idle-delay .7
121 "*"
122 :set 'company-timer-set
123 :group 'company
124 :type '(choice (const :tag "never (nil)" nil)
125 (const :tag "immediate (t)" t)
126 (number :tag "seconds")))
127
128 ;;; mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
129
130 (defvar company-mode-map
131 (let ((keymap (make-sparse-keymap)))
132 (define-key keymap (kbd "M-n") 'company-select-next)
133 (define-key keymap (kbd "M-p") 'company-select-previous)
134 (define-key keymap (kbd "M-<return>") 'company-complete-selection)
135 (define-key keymap "\t" 'company-complete)
136 (define-key keymap (kbd "<f1>") 'company-show-doc-buffer)
137 keymap))
138
139 ;;;###autoload
140 (define-minor-mode company-mode
141 ""
142 nil " comp" company-mode-map
143 (if company-mode
144 (progn
145 (add-hook 'pre-command-hook 'company-pre-command nil t)
146 (add-hook 'post-command-hook 'company-post-command nil t)
147 (company-timer-set 'company-idle-delay
148 company-idle-delay))
149 (remove-hook 'pre-command-hook 'company-pre-command t)
150 (remove-hook 'post-command-hook 'company-post-command t)
151 (company-cancel)
152 (kill-local-variable 'company-point)))
153
154 ;;; backends ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
155
156 (defun company-grab (regexp &optional expression)
157 (when (looking-back regexp)
158 (or (match-string-no-properties (or expression 0)) "")))
159
160 (defun company-in-string-or-comment (&optional point)
161 (let ((pos (syntax-ppss)))
162 (or (nth 3 pos) (nth 4 pos) (nth 7 pos))))
163
164 ;;; completion mechanism ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
165
166 (defvar company-backend nil)
167 (make-variable-buffer-local 'company-backend)
168
169 (defvar company-prefix nil)
170 (make-variable-buffer-local 'company-prefix)
171
172 (defvar company-candidates nil)
173 (make-variable-buffer-local 'company-candidates)
174
175 (defvar company-candidates-cache nil)
176 (make-variable-buffer-local 'company-candidates-cache)
177
178 (defvar company-common nil)
179 (make-variable-buffer-local 'company-common)
180
181 (defvar company-selection 0)
182 (make-variable-buffer-local 'company-selection)
183
184 (defvar company-selection-changed nil)
185 (make-variable-buffer-local 'company-selection-changed)
186
187 (defvar company-point nil)
188 (make-variable-buffer-local 'company-point)
189
190 (defvar company-disabled-backends nil)
191
192 (defsubst company-strip-prefix (str)
193 (substring str (length company-prefix)))
194
195 (defsubst company-reformat (candidate)
196 ;; company-ispell needs this, because the results are always lower-case
197 ;; It's mory efficient to fix it only when they are displayed.
198 (concat company-prefix (substring candidate (length company-prefix))))
199
200 (defsubst company-should-complete (prefix)
201 (and (eq company-idle-delay t)
202 (>= (length prefix) company-minimum-prefix-length)))
203
204 (defsubst company-call-frontends (command)
205 (dolist (frontend company-frontends)
206 (funcall frontend command)))
207
208 (defsubst company-calculate-candidates (prefix)
209 (or (setq company-candidates (cdr (assoc prefix company-candidates-cache)))
210 (let ((len (length prefix))
211 (completion-ignore-case (funcall company-backend 'ignore-case))
212 prev)
213 (dotimes (i len)
214 (when (setq prev (cdr (assoc (substring prefix 0 (- len i))
215 company-candidates-cache)))
216 (setq company-candidates (all-completions prefix prev))
217 (return t))))
218 (progn
219 (setq company-candidates (funcall company-backend 'candidates prefix))
220 (unless (funcall company-backend 'sorted)
221 (setq company-candidates (sort company-candidates 'string<)))))
222 (unless (assoc prefix company-candidates-cache)
223 (push (cons prefix company-candidates) company-candidates-cache))
224 (setq company-selection 0
225 company-prefix prefix)
226 (let ((completion-ignore-case (funcall company-backend 'ignore-case)))
227 (setq company-common (try-completion company-prefix company-candidates)))
228 (when (eq company-common t)
229 (setq company-candidates nil))
230 company-candidates)
231
232 (defun company-idle-begin ()
233 (and company-mode
234 (not company-candidates)
235 (not (equal (point) company-point))
236 (let ((company-idle-delay t))
237 (company-begin)
238 (company-post-command))))
239
240 (defun company-manual-begin ()
241 (and company-mode
242 (not company-candidates)
243 (let ((company-idle-delay t)
244 (company-minimum-prefix-length 0))
245 (company-begin)))
246 ;; Return non-nil if active.
247 company-candidates)
248
249 (defun company-continue ()
250 (when company-candidates
251 (let ((new-prefix (funcall company-backend 'prefix)))
252 (unless (and (= (- (point) (length new-prefix))
253 (- company-point (length company-prefix)))
254 (or (equal company-prefix new-prefix)
255 (company-calculate-candidates new-prefix)))
256 (setq company-candidates nil)))))
257
258 (defun company-begin ()
259 (company-continue)
260 (unless company-candidates
261 (let (prefix)
262 (dolist (backend company-backends)
263 (unless (fboundp backend)
264 (ignore-errors (require backend nil t)))
265 (if (fboundp backend)
266 (when (setq prefix (funcall backend 'prefix))
267 (when (company-should-complete prefix)
268 (setq company-backend backend)
269 (company-calculate-candidates prefix))
270 (return prefix))
271 (unless (memq backend company-disabled-backends)
272 (push backend company-disabled-backends)
273 (message "Company back-end '%s' could not be initialized"
274 backend))))))
275 (if company-candidates
276 (progn
277 (setq company-point (point))
278 (company-call-frontends 'update))
279 (company-cancel)))
280
281 (defun company-cancel ()
282 (setq company-backend nil
283 company-prefix nil
284 company-candidates nil
285 company-candidates-cache nil
286 company-common nil
287 company-selection 0
288 company-selection-changed nil
289 company-point nil)
290 (company-call-frontends 'hide))
291
292 (defun company-abort ()
293 (company-cancel)
294 ;; Don't start again, unless started manually.
295 (setq company-point (point)))
296
297 (defun company-pre-command ()
298 (unless (eq this-command 'company-show-doc-buffer)
299 (condition-case err
300 (when company-candidates
301 (company-call-frontends 'pre-command))
302 (error (message "Company: An error occurred in pre-command")
303 (message "%s" (error-message-string err))
304 (company-cancel)))))
305
306 (defun company-post-command ()
307 (unless (eq this-command 'company-show-doc-buffer)
308 (condition-case err
309 (progn
310 (unless (equal (point) company-point)
311 (company-begin))
312 (when company-candidates
313 (company-call-frontends 'post-command)))
314 (error (message "Company: An error occurred in post-command")
315 (message "%s" (error-message-string err))
316 (company-cancel)))))
317
318 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
319
320 (defun company-select-next ()
321 (interactive)
322 (when (company-manual-begin)
323 (setq company-selection (min (1- (length company-candidates))
324 (1+ company-selection))
325 company-selection-changed t))
326 (company-call-frontends 'update))
327
328 (defun company-select-previous ()
329 (interactive)
330 (when (company-manual-begin)
331 (setq company-selection (max 0 (1- company-selection))
332 company-selection-changed t))
333 (company-call-frontends 'update))
334
335 (defun company-complete-selection ()
336 (interactive)
337 (when (company-manual-begin)
338 (insert (company-strip-prefix (nth company-selection company-candidates)))
339 (company-abort)))
340
341 (defun company-complete-common ()
342 (interactive)
343 (when (company-manual-begin)
344 (insert (company-strip-prefix company-common))))
345
346 (defun company-complete ()
347 (interactive)
348 (when (company-manual-begin)
349 (if (or company-selection-changed
350 (eq last-command 'company-complete-common))
351 (call-interactively 'company-complete-selection)
352 (call-interactively 'company-complete-common)
353 (setq this-command 'company-complete-common))))
354
355 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
356
357 (defconst company-space-strings-limit 100)
358
359 (defconst company-space-strings
360 (let (lst)
361 (dotimes (i company-space-strings-limit)
362 (push (make-string (- company-space-strings-limit 1 i) ?\ ) lst))
363 (apply 'vector lst)))
364
365 (defsubst company-space-string (len)
366 (if (< len company-space-strings-limit)
367 (aref company-space-strings len)
368 (make-string len ?\ )))
369
370 (defsubst company-safe-substring (str from &optional to)
371 (let ((len (length str)))
372 (if (> from len)
373 ""
374 (if (and to (> to len))
375 (concat (substring str from)
376 (company-space-string (- to len)))
377 (substring str from to)))))
378
379 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
380
381 (defvar company-last-metadata nil)
382 (make-variable-buffer-local 'company-last-metadata)
383
384 (defun company-fetch-metadata ()
385 (let ((selected (nth company-selection company-candidates)))
386 (unless (equal selected (car company-last-metadata))
387 (setq company-last-metadata
388 (cons selected (funcall company-backend 'meta selected))))
389 (cdr company-last-metadata)))
390
391 (defun company-doc-buffer (&optional string)
392 (with-current-buffer (get-buffer-create "*Company meta-data*")
393 (erase-buffer)
394 (current-buffer)))
395
396 (defun company-show-doc-buffer ()
397 (interactive)
398 (when company-candidates
399 (save-window-excursion
400 (let* ((selected (nth company-selection company-candidates))
401 (buffer (funcall company-backend 'doc-buffer selected)))
402 (if (not buffer)
403 (error "No documentation available.")
404 (display-buffer buffer)
405 (read-event)
406 (when last-input-event
407 (clear-this-command-keys t)
408 (setq unread-command-events (list last-input-event))))))))
409
410 ;;; pseudo-tooltip ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
411
412 (defvar company-pseudo-tooltip-overlay nil)
413 (make-variable-buffer-local 'company-pseudo-tooltip-overlay)
414
415 (defvar company-tooltip-offset 0)
416 (make-variable-buffer-local 'company-tooltip-offset)
417
418 (defun company-pseudo-tooltip-update-offset (selection num-lines limit)
419
420 (decf limit 2)
421 (setq company-tooltip-offset
422 (max (min selection company-tooltip-offset)
423 (- selection -1 limit)))
424
425 (when (<= company-tooltip-offset 1)
426 (incf limit)
427 (setq company-tooltip-offset 0))
428
429 (when (>= company-tooltip-offset (- num-lines limit 1))
430 (incf limit)
431 (when (= selection (1- num-lines))
432 (setq company-tooltip-offset (max (1- company-tooltip-offset) 0))))
433
434 limit)
435
436 ;;; propertize
437
438 (defun company-fill-propertize (line width selected)
439 (setq line (company-safe-substring line 0 width))
440 (add-text-properties 0 width
441 (list 'face (if selected
442 'company-tooltip-selection
443 'company-tooltip)) line)
444 (add-text-properties 0 (length company-common)
445 (list 'face (if selected
446 'company-tooltip-common-selection
447 'company-tooltip-common)) line)
448 line)
449
450 ;;; replace
451
452 (defun company-buffer-lines (beg end)
453 (goto-char beg)
454 (let ((row (cdr (posn-col-row (posn-at-point))))
455 lines)
456 (while (< (point) end)
457 (move-to-window-line (incf row))
458 (push (buffer-substring beg (min end (1- (point)))) lines)
459 (setq beg (point)))
460 (nreverse lines)))
461
462 (defun company-modify-line (old new offset)
463 (concat (company-safe-substring old 0 offset)
464 new
465 (company-safe-substring old (+ offset (length new)))))
466
467 (defun company-replacement-string (old lines column nl)
468 (let (new)
469 ;; Inject into old lines.
470 (while old
471 (push (company-modify-line (pop old) (pop lines) column) new))
472 ;; Append whole new lines.
473 (while lines
474 (push (company-modify-line "" (pop lines) column) new))
475 (concat (when nl "\n")
476 (mapconcat 'identity (nreverse new) "\n")
477 "\n")))
478
479 (defun company-create-lines (column lines selection)
480
481 (let ((limit (max company-tooltip-limit 3))
482 (len (length lines))
483 width
484 lines-copy
485 previous
486 remainder
487 new)
488
489 ;; Scroll to offset.
490 (setq limit (company-pseudo-tooltip-update-offset selection len limit))
491
492 (when (> company-tooltip-offset 0)
493 (setq previous (format "...(%d)" company-tooltip-offset)))
494
495 (setq remainder (- len limit company-tooltip-offset)
496 remainder (when (> remainder 0)
497 (setq remainder (format "...(%d)" remainder))))
498
499 (decf selection company-tooltip-offset)
500 (setq width (min (length previous) (length remainder))
501 lines (nthcdr company-tooltip-offset lines)
502 len (min limit (length lines))
503 lines-copy lines)
504
505 (dotimes (i len)
506 (setq width (max (length (pop lines-copy)) width)))
507 (setq width (min width (- (window-width) column)))
508
509 (when previous
510 (push (propertize (company-safe-substring previous 0 width)
511 'face 'company-tooltip)
512 new))
513
514 (dotimes (i len)
515 (push (company-fill-propertize (company-reformat (pop lines))
516 width (equal i selection))
517 new))
518
519 (when remainder
520 (push (propertize (company-safe-substring remainder 0 width)
521 'face 'company-tooltip)
522 new))
523
524 (setq lines (nreverse new))))
525
526 ;; show
527
528 (defun company-pseudo-tooltip-show (row column lines selection)
529 (company-pseudo-tooltip-hide)
530 (unless lines (error "No text provided"))
531 (save-excursion
532
533 (move-to-column 0)
534
535 (let* ((lines (company-create-lines column lines selection))
536 (nl (< (move-to-window-line row) row))
537 (beg (point))
538 (end (save-excursion
539 (move-to-window-line (min (window-height)
540 (+ row company-tooltip-limit)))
541 (point)))
542 (old-string (company-buffer-lines beg end))
543 str)
544
545 (setq company-pseudo-tooltip-overlay (make-overlay beg end))
546
547 (overlay-put company-pseudo-tooltip-overlay 'company-old old-string)
548 (overlay-put company-pseudo-tooltip-overlay 'company-column column)
549 (overlay-put company-pseudo-tooltip-overlay 'company-nl nl)
550 (overlay-put company-pseudo-tooltip-overlay 'company-before
551 (company-replacement-string old-string lines column nl))
552
553 (overlay-put company-pseudo-tooltip-overlay 'window (selected-window)))))
554
555 (defun company-pseudo-tooltip-show-at-point (pos)
556 (let ((col-row (posn-col-row (posn-at-point pos))))
557 (company-pseudo-tooltip-show (1+ (cdr col-row)) (car col-row)
558 company-candidates company-selection)))
559
560 (defun company-pseudo-tooltip-edit (lines selection)
561 (let* ((old-string (overlay-get company-pseudo-tooltip-overlay 'company-old))
562 (column (overlay-get company-pseudo-tooltip-overlay 'company-column))
563 (nl (overlay-get company-pseudo-tooltip-overlay 'company-nl))
564 (lines (company-create-lines column lines selection)))
565 (overlay-put company-pseudo-tooltip-overlay 'company-before
566 (company-replacement-string old-string lines column nl))))
567
568 (defun company-pseudo-tooltip-hide ()
569 (when company-pseudo-tooltip-overlay
570 (delete-overlay company-pseudo-tooltip-overlay)
571 (setq company-pseudo-tooltip-overlay nil)))
572
573 (defun company-pseudo-tooltip-hide-temporarily ()
574 (when (overlayp company-pseudo-tooltip-overlay)
575 (overlay-put company-pseudo-tooltip-overlay 'invisible nil)
576 (overlay-put company-pseudo-tooltip-overlay 'before-string nil)))
577
578 (defun company-pseudo-tooltip-unhide ()
579 (when company-pseudo-tooltip-overlay
580 (overlay-put company-pseudo-tooltip-overlay 'invisible t)
581 (overlay-put company-pseudo-tooltip-overlay 'before-string
582 (overlay-get company-pseudo-tooltip-overlay 'company-before))))
583
584 (defun company-pseudo-tooltip-frontend (command)
585 (case command
586 ('pre-command (company-pseudo-tooltip-hide-temporarily))
587 ('post-command
588 (unless (overlayp company-pseudo-tooltip-overlay)
589 (company-pseudo-tooltip-show-at-point (- (point)
590 (length company-prefix))))
591 (company-pseudo-tooltip-unhide))
592 ('hide (company-pseudo-tooltip-hide)
593 (setq company-tooltip-offset 0))
594 ('update (when (overlayp company-pseudo-tooltip-overlay)
595 (company-pseudo-tooltip-edit company-candidates
596 company-selection)))))
597
598 (defun company-pseudo-tooltip-unless-just-one-frontend (command)
599 (unless (and (eq command 'post-command)
600 (not (cdr company-candidates)))
601 (company-pseudo-tooltip-frontend command)))
602
603 ;;; overlay ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
604
605 (defvar company-preview-overlay nil)
606 (make-variable-buffer-local 'company-preview-overlay)
607
608 (defun company-preview-show-at-point (pos)
609 (company-preview-hide)
610
611 (setq company-preview-overlay (make-overlay pos pos))
612
613 (let ((completion (company-strip-prefix (nth company-selection
614 company-candidates))))
615 (and (equal pos (point))
616 (not (equal completion ""))
617 (add-text-properties 0 1 '(cursor t) completion))
618
619 (setq completion (propertize completion 'face 'company-preview))
620 (add-text-properties 0 (- (length company-common) (length company-prefix))
621 '(face company-preview-common) completion)
622
623 (overlay-put company-preview-overlay 'after-string completion)
624 (overlay-put company-preview-overlay 'window (selected-window))))
625
626 (defun company-preview-hide ()
627 (when company-preview-overlay
628 (delete-overlay company-preview-overlay)
629 (setq company-preview-overlay nil)))
630
631 (defun company-preview-frontend (command)
632 (case command
633 ('pre-command (company-preview-hide))
634 ('post-command (company-preview-show-at-point (point)))
635 ('hide (company-preview-hide))))
636
637 (defun company-preview-if-just-one-frontend (command)
638 (unless (and (eq command 'post-command)
639 (cdr company-candidates))
640 (company-preview-frontend command)))
641
642 ;;; echo ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
643
644 (defvar company-echo-last-msg nil)
645 (make-variable-buffer-local 'company-echo-last-msg)
646
647 (defun company-echo-refresh ()
648 (let ((message-log-max nil))
649 (if company-echo-last-msg
650 (message "%s" company-echo-last-msg)
651 (message ""))))
652
653 (defun company-echo-show (candidates)
654
655 ;; Roll to selection.
656 (setq candidates (nthcdr company-selection candidates))
657
658 (let ((limit (window-width (minibuffer-window)))
659 (len -1)
660 comp msg)
661 (while candidates
662 (setq comp (company-reformat (pop candidates))
663 len (+ len 1 (length comp)))
664 (if (>= len limit)
665 (setq candidates nil)
666 (setq comp (propertize comp 'face 'company-echo))
667 (add-text-properties 0 (length company-common)
668 '(face company-echo-common) comp)
669 (push comp msg)))
670
671 (setq company-echo-last-msg (mapconcat 'identity (nreverse msg) " "))
672 (company-echo-refresh)))
673
674 (defun company-echo-frontend (command)
675 (case command
676 ('pre-command (company-echo-refresh))
677 ('post-command (company-echo-show company-candidates))
678 ('hide (setq company-echo-last-msg nil))))
679
680 (defun company-echo-metadata-frontend (command)
681 (case command
682 ('pre-command (company-echo-refresh))
683 ('post-command (setq company-echo-last-msg (company-fetch-metadata))
684 (company-echo-refresh))
685 ('hide (setq company-echo-last-msg nil))))
686
687
688 (provide 'company)
689 ;;; company.el ends here