X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/fae643a95ed3ba2cefbe70c94d16da7b17877dca..34e3d94eb31cd286c429f12c2a318f7a79dcec4b:/packages/company/company.el diff --git a/packages/company/company.el b/packages/company/company.el index 39a3a17c2..ec0f2b342 100644 --- a/packages/company/company.el +++ b/packages/company/company.el @@ -4,7 +4,7 @@ ;; Author: Nikolaj Schumacher ;; Maintainer: Dmitry Gutov -;; Version: 0.6.10 +;; Version: 0.6.12 ;; Keywords: abbrev, convenience, matching ;; URL: http://company-mode.github.io/ ;; Compatibility: GNU Emacs 22.x, GNU Emacs 23.x, GNU Emacs 24.x @@ -215,6 +215,7 @@ If this many lines are not available, prefer to display the tooltip above." '((company-abbrev . "Abbrev") (company-capf . "completion-at-point-functions") (company-clang . "Clang") + (company-cmake . "CMake") (company-css . "CSS") (company-dabbrev . "dabbrev for plain text") (company-dabbrev-code . "dabbrev for code") @@ -243,8 +244,8 @@ If this many lines are not available, prefer to display the tooltip above." (return t)))))) (defcustom company-backends '(company-elisp company-nxml company-css - company-semantic company-clang company-eclim - company-xcode company-ropemacs + company-eclim company-semantic company-clang + company-xcode company-ropemacs company-cmake (company-gtags company-etags company-dabbrev-code company-keywords) company-oddmuse company-files company-dabbrev) @@ -407,7 +408,7 @@ immediately when a prefix of `company-minimum-prefix-length' is reached." (const :tag "immediate (t)" t) (number :tag "seconds"))) -(defcustom company-begin-commands t +(defcustom company-begin-commands '(self-insert-command) "A list of commands following which company will start completing. If this is t, it will complete after any command. See `company-idle-delay'. @@ -523,11 +524,33 @@ keymap during active completions (`company-active-map'): (company-cancel) (kill-local-variable 'company-point))) +(defcustom company-global-modes t + "Modes for which `company-mode' mode is turned on by `global-company-mode'. +If nil, means no modes. If t, then all major modes have it turned on. +If a list, it should be a list of `major-mode' symbol names for which +`company-mode' should be automatically turned on. The sense of the list is +negated if it begins with `not'. For example: + (c-mode c++-mode) +means that `company-mode' is turned on for buffers in C and C++ modes only. + (not message-mode) +means that `company-mode' is always turned on except in `message-mode' buffers." + :type '(choice (const :tag "none" nil) + (const :tag "all" t) + (set :menu-tag "mode specific" :tag "modes" + :value (not) + (const :tag "Except" not) + (repeat :inline t (symbol :tag "mode"))))) + ;;;###autoload (define-globalized-minor-mode global-company-mode company-mode company-mode-on) (defun company-mode-on () - (unless (or noninteractive (eq (aref (buffer-name) 0) ?\s)) + (when (and (not (or noninteractive (eq (aref (buffer-name) 0) ?\s))) + (cond ((eq company-global-modes t) + t) + ((eq (car-safe company-global-modes) 'not) + (not (memq major-mode (cdr company-global-modes)))) + (t (memq major-mode company-global-modes)))) (company-mode 1))) (defsubst company-assert-enabled () @@ -575,14 +598,13 @@ keymap during active completions (`company-active-map'): (defun company--column (&optional pos) (save-excursion (when pos (goto-char pos)) - (let ((pt (point))) - (save-restriction - (+ (save-excursion - (vertical-motion 0) - (narrow-to-region (point) pt) - (let ((prefix (get-text-property (point) 'line-prefix))) - (if prefix (length prefix) 0))) - (current-column)))))) + (save-restriction + (+ (save-excursion + (vertical-motion 0) + (narrow-to-region (point) (point-max)) + (let ((prefix (get-text-property (point) 'line-prefix))) + (if prefix (length prefix) 0))) + (current-column))))) (defun company--row (&optional pos) (save-excursion @@ -1615,7 +1637,11 @@ Example: \(company-begin-with '\(\"foo\" \"foobar\" \"foobarbaz\"\)\)" (defsubst company-round-tab (arg) (* (/ (+ arg tab-width) tab-width) tab-width)) -(defun company-untabify (str) +(defun company-plainify (str) + (let ((prefix (get-text-property 0 'line-prefix str))) + (when prefix ; Keep the original value unmodified, for no special reason. + (setq str (concat prefix str)) + (remove-text-properties 0 (length str) '(line-prefix) str))) (let* ((pieces (split-string str "\t")) (copy pieces)) (while (cdr copy) @@ -1676,10 +1702,6 @@ Example: \(company-begin-with '\(\"foo\" \"foobar\" \"foobarbaz\"\)\)" (nreverse lines))) (defun company-modify-line (old new offset) - (let ((prefix (get-text-property 0 'line-prefix old))) - (when prefix ; Keep the original value unmodified, for no special reason. - (setq old (concat prefix old)) - (remove-text-properties 0 (length old) '(line-prefix) old))) (concat (company-safe-substring old 0 offset) new (company-safe-substring old (+ offset (length new))))) @@ -1809,7 +1831,7 @@ Returns a negative number if the tooltip should be displayed above point." (move-to-window-line (+ row (abs height))) (point))) (ov (make-overlay beg end)) - (args (list (mapcar 'company-untabify + (args (list (mapcar 'company-plainify (company-buffer-lines beg end)) column nl above))) @@ -1817,7 +1839,7 @@ Returns a negative number if the tooltip should be displayed above point." (overlay-put ov 'company-replacement-args args) (let ((lines (company--create-lines selection (abs height)))) - (overlay-put ov 'company-before + (overlay-put ov 'company-after (apply 'company--replacement-string lines args)) (overlay-put ov 'company-width (string-width (car lines)))) @@ -1831,7 +1853,7 @@ Returns a negative number if the tooltip should be displayed above point." (defun company-pseudo-tooltip-edit (selection) (let ((height (overlay-get company-pseudo-tooltip-overlay 'company-height))) - (overlay-put company-pseudo-tooltip-overlay 'company-before + (overlay-put company-pseudo-tooltip-overlay 'company-after (apply 'company--replacement-string (company--create-lines selection (abs height)) (overlay-get company-pseudo-tooltip-overlay @@ -1845,7 +1867,8 @@ Returns a negative number if the tooltip should be displayed above point." (defun company-pseudo-tooltip-hide-temporarily () (when (overlayp company-pseudo-tooltip-overlay) (overlay-put company-pseudo-tooltip-overlay 'invisible nil) - (overlay-put company-pseudo-tooltip-overlay 'before-string nil))) + (overlay-put company-pseudo-tooltip-overlay 'line-prefix nil) + (overlay-put company-pseudo-tooltip-overlay 'after-string nil))) (defun company-pseudo-tooltip-unhide () (when company-pseudo-tooltip-overlay @@ -1854,8 +1877,8 @@ Returns a negative number if the tooltip should be displayed above point." (overlay-put company-pseudo-tooltip-overlay 'priority 1) ;; No (extra) prefix for the first line. (overlay-put company-pseudo-tooltip-overlay 'line-prefix "") - (overlay-put company-pseudo-tooltip-overlay 'before-string - (overlay-get company-pseudo-tooltip-overlay 'company-before)) + (overlay-put company-pseudo-tooltip-overlay 'after-string + (overlay-get company-pseudo-tooltip-overlay 'company-after)) (overlay-put company-pseudo-tooltip-overlay 'window (selected-window)))) (defun company-pseudo-tooltip-guard ()