]> code.delx.au - gnu-emacs-elpa/commitdiff
Merge commit 'a015fb350abe50d250e3e7a9c3c762397326977f' from company
authorDmitry Gutov <dgutov@yandex.ru>
Mon, 2 Feb 2015 15:22:35 +0000 (17:22 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Mon, 2 Feb 2015 15:22:35 +0000 (17:22 +0200)
1  2 
packages/company/NEWS.md
packages/company/company-clang.el
packages/company/company.el

diff --combined packages/company/NEWS.md
index 4139186095e763af57f0b639abbcda1081702566,c7a1afe53d45a634998f3727dd5da3df6eeb4d4a..c7a1afe53d45a634998f3727dd5da3df6eeb4d4a
@@@ -1,5 -1,12 +1,12 @@@
  # History of user-visible changes
  
+ ## 2015-02-02 (0.8.10)
+ * New variable `company-lighter-base`.
+ * Better tracking of the current selection.
+ * Pressing `M-0`...`M-9` works in the search mode.
+ * Pressing `<up>` or `<down>` doesn't quit the search mode.
  ## 2015-01-23 (0.8.9)
  
  * New commands `company-next-page` and `company-previous-page`, remapping
index 8114b3b5bb0a145239a039dc8fa5d8233a785d08,e85e8655bfcb9513393e9fbc91e4223f605a14a6..e85e8655bfcb9513393e9fbc91e4223f605a14a6
@@@ -189,6 -189,7 +189,7 @@@ or automatically through a custom `comp
  (defun company-clang--start-process (prefix callback &rest args)
    (let ((objc (derived-mode-p 'objc-mode))
          (buf (get-buffer-create "*clang-output*"))
+         ;; Looks unnecessary in Emacs 25.1 and later.
          (process-adaptive-read-buffering nil))
      (with-current-buffer buf (erase-buffer))
      (if (get-buffer-process buf)
index 4c7e160662573688bf3f2d7951f1fcb406b32de8,86d93c238b13c6193126cf84c514a3ea2361ae5a..86d93c238b13c6193126cf84c514a3ea2361ae5a
@@@ -5,7 -5,7 +5,7 @@@
  ;; Author: Nikolaj Schumacher
  ;; Maintainer: Dmitry Gutov <dgutov@yandex.ru>
  ;; URL: http://company-mode.github.io/
- ;; Version: 0.8.9
+ ;; Version: 0.8.10
  ;; Keywords: abbrev, convenience, matching
  ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
  
@@@ -662,9 -662,26 +662,26 @@@ asynchronous call into synchronous."
        (unless (keywordp b)
          (company-init-backend b))))))
  
- (defvar company-default-lighter " company")
+ (defcustom company-lighter-base "company"
+   "Base string to use for the `company-mode' lighter."
+   :type 'string
+   :package-version '(company . "0.8.10"))
  
- (defvar-local company-lighter company-default-lighter)
+ (defvar company-lighter '(" "
+                           (company-backend
+                            (:eval
+                             (if (consp company-backend)
+                                 (company--group-lighter (nth company-selection
+                                                              company-candidates)
+                                                         company-lighter-base)
+                               (symbol-name company-backend)))
+                            company-lighter-base))
+   "Mode line lighter for Company.
+ The value of this variable is a mode line template as in
+ `mode-line-format'.")
+ (put 'company-lighter 'risky-local-variable t)
  
  ;;;###autoload
  (define-minor-mode company-mode
@@@ -1045,34 -1062,36 +1062,36 @@@ can retrieve meta-data for them.
              (mod selection company-candidates-length)
            (max 0 (min (1- company-candidates-length) selection))))
    (when (or force-update (not (equal selection company-selection)))
-     (company--update-group-lighter (nth selection company-candidates))
      (setq company-selection selection
            company-selection-changed t)
      (company-call-frontends 'update)))
  
- (defun company--update-group-lighter (candidate)
-   (when (listp company-backend)
-     (let ((backend (or (get-text-property 0 'company-backend candidate)
-                        (car company-backend))))
-       (when (and backend (symbolp backend))
-         (let ((name (replace-regexp-in-string "company-\\|-company" ""
-                                               (symbol-name backend))))
-           (setq company-lighter (format " company-<%s>" name)))))))
+ (defun company--group-lighter (candidate base)
+   (let ((backend (or (get-text-property 0 'company-backend candidate)
+                      (car company-backend))))
+     (when (and backend (symbolp backend))
+       (let ((name (replace-regexp-in-string "company-\\|-company" ""
+                                             (symbol-name backend))))
+         (format "%s-<%s>" base name)))))
  
  (defun company-update-candidates (candidates)
    (setq company-candidates-length (length candidates))
-   (if (> company-selection 0)
+   (if company-selection-changed
        ;; Try to restore the selection
        (let ((selected (nth company-selection company-candidates)))
          (setq company-selection 0
                company-candidates candidates)
          (when selected
-           (while (and candidates (string< (pop candidates) selected))
-             (cl-incf company-selection))
-           (unless candidates
-             ;; Make sure selection isn't out of bounds.
-             (setq company-selection (min (1- company-candidates-length)
-                                          company-selection)))))
+           (catch 'found
+             (while candidates
+               (let ((candidate (pop candidates)))
+                 (when (and (string= candidate selected)
+                            (equal (company-call-backend 'annotation candidate)
+                                   (company-call-backend 'annotation selected)))
+                   (throw 'found t)))
+               (cl-incf company-selection))
+             (setq company-selection 0
+                   company-selection-changed nil))))
      (setq company-selection 0
            company-candidates candidates))
    ;; Calculate common.
@@@ -1448,9 -1467,6 +1467,6 @@@ from the rest of the back-ends in the g
                  (message "No completion found"))
              (when company--manual-action
                (setq company--manual-prefix prefix))
-             (if (symbolp backend)
-                 (setq company-lighter (concat " " (symbol-name backend)))
-               (company--update-group-lighter (car c)))
              (company-update-candidates c)
              (run-hook-with-args 'company-completion-started-hook
                                  (company-explicit-action-p))
            company-selection-changed nil
            company--manual-action nil
            company--manual-prefix nil
-           company-lighter company-default-lighter
            company--point-max nil
            company-point nil)
      (when company-timer
  
  (defvar-local company-search-string "")
  
- (defvar-local company-search-lighter " Search: \"\"")
+ (defvar company-search-lighter '(" "
+                                  (company-search-filtering "Filter" "Search")
+                                  ": \""
+                                  company-search-string
+                                  "\""))
  
  (defvar-local company-search-filtering nil
    "Non-nil to filter the completion candidates by the search string")
  
  (defvar-local company--search-old-selection 0)
  
+ (defvar-local company--search-old-changed nil)
  (defun company--search (text lines)
    (let ((quoted (regexp-quote text))
          (i 0))
    (let* ((pos (company--search new (nthcdr company-selection company-candidates))))
      (if (null pos)
          (ding)
-       (setq company-search-string new
-             company-search-lighter (format " %s: \"%s\""
-                                            (if company-search-filtering
-                                                "Filter"
-                                              "Search")
-                                            new))
+       (setq company-search-string new)
        (company-set-selection (+ company-selection pos) t))))
  
  (defun company--search-assert-input ()
    (interactive)
    (company--search-assert-enabled)
    (company-search-mode 0)
-   (company-set-selection company--search-old-selection t))
+   (company-set-selection company--search-old-selection t)
+   (setq company-selection-changed company--search-old-changed))
  
  (defun company-search-other-char ()
    (interactive)
      (define-key keymap (vector meta-prefix-char t) 'company-search-other-char)
      (define-key keymap (kbd "M-n") 'company-select-next)
      (define-key keymap (kbd "M-p") 'company-select-previous)
+     (define-key keymap (kbd "<down>") 'company-select-next-or-abort)
+     (define-key keymap (kbd "<up>") 'company-select-previous-or-abort)
      (define-key keymap "\e\e\e" 'company-search-other-char)
      (define-key keymap [escape escape escape] 'company-search-other-char)
      (define-key keymap (kbd "DEL") 'company-search-delete-char)
      (define-key keymap "\C-s" 'company-search-repeat-forward)
      (define-key keymap "\C-r" 'company-search-repeat-backward)
      (define-key keymap "\C-o" 'company-search-toggle-filtering)
+     (dotimes (i 10)
+       (define-key keymap (read-kbd-macro (format "M-%d" i)) 'company-complete-number))
      keymap)
    "Keymap used for incrementally searching the completion candidates.")
  
@@@ -1730,13 -1751,15 +1751,15 @@@ Don't start this directly, use `company
    (if company-search-mode
        (if (company-manual-begin)
            (progn
-             (setq company--search-old-selection company-selection)
-             (company-call-frontends 'update))
+             (setq company--search-old-selection company-selection
+                   company--search-old-changed company-selection-changed)
+             (company-call-frontends 'update)
+             (company-enable-overriding-keymap company-search-map))
          (setq company-search-mode nil))
      (kill-local-variable 'company-search-string)
-     (kill-local-variable 'company-search-lighter)
      (kill-local-variable 'company-search-filtering)
      (kill-local-variable 'company--search-old-selection)
+     (kill-local-variable 'company--search-old-changed)
      (when company-backend
        (company--search-update-predicate "")
        (company-call-frontends 'update))
@@@ -1762,8 -1785,7 +1785,7 @@@ Regular characters are appended to the 
  The command `company-search-toggle-filtering' (\\[company-search-toggle-filtering])
  uses the search string to filter the completion candidates."
    (interactive)
-   (company-search-mode 1)
-   (company-enable-overriding-keymap company-search-map))
+   (company-search-mode 1))
  
  (defvar company-filter-map
    (let ((keymap (make-keymap)))