branch: externals/company
commit b0a522ac5bf8ba3d2f4f22e3aa846a4f82978a16
Merge: 42c2aa60b8 06e9a9782a
Author: Dmitry Gutov <dmi...@gutov.dev>
Commit: GitHub <nore...@github.com>

    Merge pull request #1462 from Hi-Angel/dont-change-match-data
    
    Replace `string-match` with `string-match-p` when appropriate and use 
`string-empty-p` helper
---
 company-dabbrev-code.el |  2 +-
 company-files.el        |  2 +-
 company-ispell.el       |  2 +-
 company-semantic.el     |  4 ++--
 company.el              | 20 ++++++++++----------
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/company-dabbrev-code.el b/company-dabbrev-code.el
index cf435f28b2..5d7bf66475 100644
--- a/company-dabbrev-code.el
+++ b/company-dabbrev-code.el
@@ -78,7 +78,7 @@ also `company-dabbrev-code-time-limit'."
 (defun company-dabbrev-code--make-regexp (prefix)
   (let ((prefix-re
          (cond
-          ((equal prefix "")
+          ((string-empty-p prefix)
            "\\([a-zA-Z]\\|\\s_\\)")
           ((not company-dabbrev-code-completion-styles)
            (regexp-quote prefix))
diff --git a/company-files.el b/company-files.el
index 6a53ada5f8..ebe3a6a28a 100644
--- a/company-files.el
+++ b/company-files.el
@@ -53,7 +53,7 @@ Set this to nil to disable that behavior."
                         (lambda (s1 s2) (string-lessp (downcase s1) (downcase 
s2))))))
         (when company-files-exclusions
           (setq comp (company-files--exclusions-filtered comp)))
-        (if (equal prefix "")
+        (if (string-empty-p prefix)
             (delete "../" (delete "./" comp))
           comp))
     (file-error nil)))
diff --git a/company-ispell.el b/company-ispell.el
index d40d8c6eb4..2699d30bed 100644
--- a/company-ispell.el
+++ b/company-ispell.el
@@ -81,7 +81,7 @@ If nil, use `ispell-complete-word-dict' or 
`ispell-alternate-dictionary'."
                                   (lambda () (ispell-lookup-words "" dict))
                                   :check-tag dict))
             (completion-ignore-case t))
-       (if (string= arg "")
+       (if (string-empty-p arg)
            ;; Small optimization.
            all-words
          (company-substitute-prefix
diff --git a/company-semantic.el b/company-semantic.el
index 53b11c0320..df20e6260e 100644
--- a/company-semantic.el
+++ b/company-semantic.el
@@ -140,7 +140,7 @@ and `c-electric-colon', for automatic completion right 
after \">\" and
                  (memq major-mode company-semantic-modes)
                  (not (company-in-string-or-comment))
                  (or (company-semantic--prefix) 'stop)))
-    (candidates (if (and (equal arg "")
+    (candidates (if (and (string-empty-p arg)
                          (not (looking-back "->\\|\\.\\|::" (- (point) 2))))
                     (company-semantic-completions-raw arg)
                   (company-semantic-completions arg)))
@@ -151,7 +151,7 @@ and `c-electric-colon', for automatic completion right 
after \">\" and
     (doc-buffer (company-semantic-doc-buffer
                  (assoc arg company-semantic--current-tags)))
     ;; Because "" is an empty context and doesn't return local variables.
-    (no-cache (equal arg ""))
+    (no-cache (string-empty-p arg))
     (duplicates t)
     (location (let ((tag (assoc arg company-semantic--current-tags)))
                 (when (buffer-live-p (semantic-tag-buffer tag))
diff --git a/company.el b/company.el
index 2764bbff09..2f3a24f55f 100644
--- a/company.el
+++ b/company.el
@@ -1991,7 +1991,7 @@ Keywords and function definition names are ignored."
             (cl-delete-if
              (lambda (candidate)
                (goto-char w-start)
-               (when (and (not (equal candidate ""))
+               (when (and (not (string-empty-p candidate))
                           (search-forward candidate w-end t)
                           ;; ^^^ optimize for large lists where most elements
                           ;; won't have a match.
@@ -2145,8 +2145,8 @@ For more details see `company-insertion-on-trigger' and
          (if (consp company-insertion-triggers)
              (memq (char-syntax (string-to-char input))
                    company-insertion-triggers)
-           (string-match (regexp-quote (substring input 0 1))
-                         company-insertion-triggers)))))
+           (string-match-p (regexp-quote (substring input 0 1))
+                           company-insertion-triggers)))))
 
 (defun company--incremental-p ()
   (and (> (point) company-point)
@@ -2506,9 +2506,9 @@ each one wraps a part of the input string."
 (defun company--search-update-predicate (ss)
   (let* ((re (funcall company-search-regexp-function ss))
          (company-candidates-predicate
-          (and (not (string= re ""))
+          (and (not (string-empty-p re))
                company-search-filtering
-               (lambda (candidate) (string-match re candidate))))
+               (lambda (candidate) (string-match-p re candidate))))
          (cc (company-calculate-candidates company-prefix
                                            (company-call-backend 
'ignore-case))))
     (unless cc (user-error "No match"))
@@ -2524,7 +2524,7 @@ each one wraps a part of the input string."
 
 (defun company--search-assert-input ()
   (company--search-assert-enabled)
-  (when (string= company-search-string "")
+  (when (string-empty-p company-search-string)
     (user-error "Empty search string")))
 
 (defun company-search-repeat-forward ()
@@ -2577,7 +2577,7 @@ each one wraps a part of the input string."
 (defun company-search-delete-char ()
   (interactive)
   (company--search-assert-enabled)
-  (if (string= company-search-string "")
+  (if (string-empty-p company-search-string)
       (ding)
     (let ((ss (substring company-search-string 0 -1)))
       (when company-search-filtering
@@ -3427,7 +3427,7 @@ If SHOW-VERSION is non-nil, show the version in the echo 
area."
                                 nil line))
     (when (let ((re (funcall company-search-regexp-function
                              company-search-string)))
-            (and (not (string= re ""))
+            (and (not (string-empty-p re))
                  (string-match re value)))
       (pcase-dolist (`(,mbeg . ,mend) (company--search-chunks))
         (let ((beg (+ margin mbeg))
@@ -4111,7 +4111,7 @@ Delay is determined by `company-tooltip-idle-delay'."
                                (substring completion 1))))
 
     (and (equal pos (point))
-         (not (equal completion ""))
+         (not (string-empty-p completion))
          (add-text-properties 0 1 '(cursor 1) completion))
 
     (let* ((beg pos)
@@ -4298,7 +4298,7 @@ Delay is determined by `company-tooltip-idle-delay'."
               "}"))))
 
 (defun company-echo-hide ()
-  (unless (equal company-echo-last-msg "")
+  (unless (string-empty-p company-echo-last-msg)
     (setq company-echo-last-msg "")
     (company-echo-show)))
 

Reply via email to