-;;; company-dabbrev.el --- dabbrev-like company-mode completion back-end -*- lexical-binding: t -*-
+;;; company-dabbrev.el --- dabbrev-like company-mode completion backend -*- lexical-binding: t -*-
-;; Copyright (C) 2009, 2011, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2011, 2014, 2015 Free Software Foundation, Inc.
;; Author: Nikolaj Schumacher
(require 'cl-lib)
(defgroup company-dabbrev nil
- "dabbrev-like completion back-end."
+ "dabbrev-like completion backend."
:group 'company)
(defcustom company-dabbrev-other-buffers 'all
(> (float-time (time-since ,start)) ,limit)
(throw 'done 'company-time-out))))))
-(defsubst company-dabbrev--make-regexp (prefix)
+(defun company-dabbrev--make-regexp (prefix)
(concat "\\<" (if (equal prefix "")
company-dabbrev-char-regexp
(regexp-quote prefix))
(defun company-dabbrev--search-buffer (regexp pos symbols start limit
ignore-comments)
(save-excursion
- (cl-flet ((maybe-collect-match
- ()
- (let ((match (match-string-no-properties 0)))
- (when (and (>= (length match) company-dabbrev-minimum-length)
- (not (and company-dabbrev-ignore-invisible
- (invisible-p (match-beginning 0)))))
- (push match symbols)))))
+ (cl-labels ((maybe-collect-match
+ ()
+ (let ((match (match-string-no-properties 0)))
+ (when (and (>= (length match) company-dabbrev-minimum-length)
+ (not (and company-dabbrev-ignore-invisible
+ (invisible-p (match-beginning 0)))))
+ (push match symbols)))))
(goto-char (if pos (1- pos) (point-min)))
;; search before pos
(company-dabrev--time-limit-while (re-search-backward regexp nil t)
start limit
- (if (and ignore-comments (company-in-string-or-comment))
+ (if (and ignore-comments (save-match-data (company-in-string-or-comment)))
(goto-char (nth 8 (syntax-ppss)))
(maybe-collect-match)))
(goto-char (or pos (point-min)))
;; search after pos
(company-dabrev--time-limit-while (re-search-forward regexp nil t)
start limit
- (if (and ignore-comments (company-in-string-or-comment))
+ (if (and ignore-comments (save-match-data (company-in-string-or-comment)))
(re-search-forward "\\s>\\|\\s!\\|\\s\"" nil t)
(maybe-collect-match)))
symbols)))
;;;###autoload
(defun company-dabbrev (command &optional arg &rest ignored)
- "dabbrev-like `company-mode' completion back-end."
+ "dabbrev-like `company-mode' completion backend."
(interactive (list 'interactive))
(cl-case command
(interactive (company-begin-backend 'company-dabbrev))