From 7c523f2c1552acfad7b06e0160a3e7a8a61eca05 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Sat, 27 Jul 2019 14:41:40 +0700 Subject: [PATCH] Uniquify completion candidates of whole lines If the same line is present more than once in the buffer, it will be offered more than once as a candidate. This commit deletes duplicate lines from the completion list. Signed-off-by: Rudi Grinberg --- modules/completion/company/autoload.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/completion/company/autoload.el b/modules/completion/company/autoload.el index 570765549..a37627d00 100644 --- a/modules/completion/company/autoload.el +++ b/modules/completion/company/autoload.el @@ -129,12 +129,13 @@ C-x C-l." (`candidates (all-completions arg - (split-string - (replace-regexp-in-string - "^[\t\s]+" "" - (concat (buffer-substring-no-properties (point-min) (line-beginning-position)) - (buffer-substring-no-properties (line-end-position) (point-max)))) - "\\(\r\n\\|[\n\r]\\)" t))))) + (delete-dups + (split-string + (replace-regexp-in-string + "^[\t\s]+" "" + (concat (buffer-substring-no-properties (point-min) (line-beginning-position)) + (buffer-substring-no-properties (line-end-position) (point-max)))) + "\\(\r\n\\|[\n\r]\\)" t)))))) ;;;###autoload (defun +company/dict-or-keywords ()