From: Vitalie Spinu Date: Sat, 12 Sep 2015 10:56:40 +0000 (+0200) Subject: [Fix #317] Allow :sorted keyword in grouped backends X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/5d68a504742d6e6a4f79882431f4648a0654a5b9?hp=7afffbc99040f50b032713276936511deaaf0568 [Fix #317] Allow :sorted keyword in grouped backends --- diff --git a/company.el b/company.el index c64f0d6fb..abace2cac 100644 --- a/company.el +++ b/company.el @@ -429,6 +429,9 @@ the keyword `:with', the backends after it are ignored for this command. The completions from backends in a group are merged (but only from those that return the same `prefix'). +If a grouped backend contains keyword `:sorted', the final (merged) list of +candidates is not sorted. + Asynchronous backends: The return value of each command can also be a cons (:async . FETCHER) @@ -892,14 +895,17 @@ means that `company-mode' is always turned on except in `message-mode' buffers." when (not (and (symbolp b) (eq 'failed (get b 'company-init)))) collect b))) - (setq backends - (if (eq command 'prefix) - (butlast backends (length (member :with backends))) - (delq :with backends))) + + (when (eq command 'prefix) + (setq backends (butlast backends (length (member :with backends))))) + + (unless (memq command '(sorted)) + (setq backends (cl-delete-if #'keywordp backends))) + (pcase command (`candidates (company--multi-backend-adapter-candidates backends (car args))) - (`sorted nil) + (`sorted (memq :sorted backends)) (`duplicates t) ((or `prefix `ignore-case `no-cache `require-match) (let (value)