;; Copyright (C) 2009 Nikolaj Schumacher
;;
;; Author: Nikolaj Schumacher <bugs * nschum de>
-;; Version: 0.4
+;; Version: 0.4.1
;; Keywords: abbrev, convenience, matchis
;; URL: http://nschum.de/src/emacs/company/
;; Compatibility: GNU Emacs 22.x, GNU Emacs 23.x
;;
;;; Change Log:
;;
+;; Windows compatibility fixes.
+;;
+;; 2009-04-19 (0.4.1)
+;; Added `global-company-mode'.
;; Performance enhancements.
;; Added `company-eclim' back-end.
;; Added safer workaround for Emacs `posn-col-row' bug.
keymap)
"Keymap that is enabled during an active completion.")
+(defvar company--disabled-backends nil)
+
(defun company-init-backend (backend)
(and (symbolp backend)
(not (fboundp backend))
(if (ignore-errors (funcall backend 'init) t)
(put backend 'company-init t)
(put backend 'company-init 'failed)
- (message "Company back-end '%s' could not be initialized"
- backend)
+ (unless (memq backend company--disabled-backends)
+ (message "Company back-end '%s' could not be initialized"
+ backend)
+ (push backend company--disabled-backends))
nil)
(mapc 'company-init-backend backend)))
(company-cancel)
(kill-local-variable 'company-point)))
+(define-globalized-minor-mode global-company-mode company-mode
+ (lambda () (company-mode 1)))
+
(defsubst company-assert-enabled ()
(unless company-mode
(company-uninstall-map)
(car (setq ppss (cdr ppss)))
(nth 3 ppss))))
+(if (fboundp 'locate-dominating-file)
+ (defalias 'company-locate-dominating-file 'locate-dominating-file)
+ (defun company-locate-dominating-file (file name)
+ (catch 'root
+ (let ((dir (file-name-directory file))
+ (prev-dir nil))
+ (while (not (equal dir prev-dir))
+ (when (file-exists-p (expand-file-name name dir))
+ (throw 'root dir))
+ (setq prev-dir dir
+ dir (file-name-directory (directory-file-name dir))))))))
+
(defun company-call-backend (&rest args)
(if (functionp company-backend)
(apply company-backend args)
(company-input-noop)
(company-post-command)))))
-(defun company-manual-begin ()
- (interactive)
+(defun company-auto-begin ()
(company-assert-enabled)
(and company-mode
(not company-candidates)
(let ((company-idle-delay t)
(company-minimum-prefix-length 0)
(company-begin-commands t))
- (setq company--explicit-action t)
(company-begin)))
;; Return non-nil if active.
company-candidates)
+(defun company-manual-begin ()
+ (interactive)
+ (setq company--explicit-action t)
+ (company-auto-begin))
+
(defun company-require-match-p ()
(let ((backend-value (company-call-backend 'require-match)))
(or (eq backend-value t)
(message "%s" (error-message-string err))
(company-cancel))))
(when company-timer
- (cancel-timer company-timer))
+ (cancel-timer company-timer)
+ (setq company-timer nil))
(company-uninstall-map))
(defun company-post-command ()
(progn
(unless (equal (point) company-point)
(company-begin))
- (when company-candidates
- (company-call-frontends 'post-command))
- (and (numberp company-idle-delay)
- (or (eq t company-begin-commands)
- (memq this-command company-begin-commands))
- (setq company-timer
- (run-with-timer company-idle-delay nil 'company-idle-begin
- (current-buffer) (selected-window)
- (buffer-chars-modified-tick) (point)))))
+ (if company-candidates
+ (company-call-frontends 'post-command)
+ (and (numberp company-idle-delay)
+ (or (eq t company-begin-commands)
+ (memq this-command company-begin-commands))
+ (setq company-timer
+ (run-with-timer company-idle-delay nil
+ 'company-idle-begin
+ (current-buffer) (selected-window)
+ (buffer-chars-modified-tick) (point))))))
(error (message "Company: An error occurred in post-command")
(message "%s" (error-message-string err))
(company-cancel))))