From: Nikolaj Schumacher Date: Sun, 15 Mar 2009 21:28:48 +0000 (+0100) Subject: Added special keymap that is activated on demand. X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/ddc54a061616e806e49661d6f863f041eb1dffc8 Added special keymap that is activated on demand. --- diff --git a/company-elisp.el b/company-elisp.el index df7e5686b..231446b7f 100644 --- a/company-elisp.el +++ b/company-elisp.el @@ -60,8 +60,9 @@ (doc (if (fboundp symbol) (documentation symbol t) (documentation-property symbol 'variable-documentation t)))) - (when (string-match ".*$" doc) - (match-string 0 doc)))) + (and (stringp doc) + (string-match ".*$" doc) + (match-string 0 doc)))) (defun company-elisp (command &optional arg &rest ignored) (case command diff --git a/company.el b/company.el index e479fa490..e3867b84f 100644 --- a/company.el +++ b/company.el @@ -161,21 +161,28 @@ ;;; mode ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defvar company-mode-map +(defvar company-current-map (make-sparse-keymap)) + +(defvar company-mode-map (make-sparse-keymap)) + +(defvar company-active-map (let ((keymap (make-sparse-keymap))) + (set-keymap-parent keymap company-mode-map) (define-key keymap (kbd "M-n") 'company-select-next) (define-key keymap (kbd "M-p") 'company-select-previous) - (define-key keymap (kbd "M-") 'company-complete-selection) - (define-key keymap "\t" 'company-complete) + (define-key keymap "\C-m" 'company-complete-selection) + (define-key keymap "\t" 'company-complete-common) (define-key keymap (kbd "") 'company-show-doc-buffer) keymap)) ;;;###autoload (define-minor-mode company-mode "" - nil " comp" company-mode-map + nil " comp" nil (if company-mode (progn + (add-to-list 'minor-mode-overriding-map-alist + (cons 'company-mode company-current-map)) (add-hook 'pre-command-hook 'company-pre-command nil t) (add-hook 'post-command-hook 'company-post-command nil t) (company-timer-set 'company-idle-delay @@ -309,6 +316,7 @@ (if company-candidates (progn (setq company-point (point)) + (set-keymap-parent company-current-map company-active-map) (company-call-frontends 'update)) (company-cancel))) @@ -321,7 +329,8 @@ company-selection 0 company-selection-changed nil company-point nil) - (company-call-frontends 'hide)) + (company-call-frontends 'hide) + (set-keymap-parent company-current-map company-mode-map)) (defun company-abort () (company-cancel)