]> code.delx.au - gnu-emacs-elpa/blobdiff - company-capf.el
company-capf: Add :company-prefix-length property function
[gnu-emacs-elpa] / company-capf.el
index 8e2868925a972d38eb7479fdb6c9b9ecf2b545fe..6554782d1de48014e282d5866891b44836578938 100644 (file)
     (`prefix
      (let ((res (company--capf-data)))
        (when res
-         (if (> (nth 2 res) (point))
-             'stop
-           (buffer-substring-no-properties (nth 1 res) (point))))))
+         (let* ((f (plist-get (nthcdr 4 res) :company-prefix-length))
+                (beg (nth 1 res))
+                (end (nth 2 res))
+                (length (and f (funcall f beg (point))))
+                (prefix (buffer-substring-no-properties beg (point))))
+           (cond
+            ((> end (point)) 'stop)
+            (length (cons prefix length))
+            (t prefix))))))
     (`candidates
      (let ((res (company--capf-data)))
        (when res