]> code.delx.au - gnu-emacs-elpa/commitdiff
* company-untabify: Rename to `company-plainify'.
authorDmitry Gutov <dgutov@yandex.ru>
Mon, 23 Sep 2013 00:36:31 +0000 (03:36 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Mon, 23 Sep 2013 00:36:31 +0000 (03:36 +0300)
* company-modify-line: Move `line-prefix' logic to `company-plainify'.

Fix #24, take four

company-tests.el
company.el

index 1031d0bc7878bb06997a8628d574067b2743b08d..870ad2b1022deaf9bc594c2c7aa9cb21e2db9685 100644 (file)
     (put-text-property (point-min) (point-max) 'line-prefix "  ")
     (should (= (company--column) 2))))
 
-(ert-deftest company-modify-line-with-line-prefix ()
-  (let ((str (propertize "foobar" 'line-prefix "-*-")))
+(ert-deftest company-plainify ()
+  (let ((tab-width 8))
+    (should (equal-including-properties
+             (company-plainify "\tabc\td\t")
+             (concat "        "
+                     "abc     "
+                     "d       "))))
+  (should (equal-including-properties
+           (company-plainify (propertize "foobar" 'line-prefix "-*-"))
+           "-*-foobar")))
+
+(ert-deftest company-modify-line ()
+  (let ((str "-*-foobar"))
     (should (equal-including-properties
              (company-modify-line str "zz" 4)
              "-*-fzzbar"))
-    (should (equal-including-properties
-             (company-modify-line str "zzxx" 1)
-             "-zzxxobar"))
     (should (equal-including-properties
              (company-modify-line str "xx" 0)
              "xx-foobar"))
index dff2e06b7a9c7df9a3721d3b5bfc4dccc2d593a9..253dcc02a10f454c49a514afdf31e3ba478e1ebe 100644 (file)
@@ -1637,7 +1637,11 @@ Example: \(company-begin-with '\(\"foo\" \"foobar\" \"foobarbaz\"\)\)"
 (defsubst company-round-tab (arg)
   (* (/ (+ arg tab-width) tab-width) tab-width))
 
-(defun company-untabify (str)
+(defun company-plainify (str)
+  (let ((prefix (get-text-property 0 'line-prefix str)))
+    (when prefix ; Keep the original value unmodified, for no special reason.
+      (setq str (concat prefix str))
+      (remove-text-properties 0 (length str) '(line-prefix) str)))
   (let* ((pieces (split-string str "\t"))
          (copy pieces))
     (while (cdr copy)
@@ -1698,10 +1702,6 @@ Example: \(company-begin-with '\(\"foo\" \"foobar\" \"foobarbaz\"\)\)"
     (nreverse lines)))
 
 (defun company-modify-line (old new offset)
-  (let ((prefix (get-text-property 0 'line-prefix old)))
-    (when prefix ; Keep the original value unmodified, for no special reason.
-      (setq old (concat prefix old))
-      (remove-text-properties 0 (length old) '(line-prefix) old)))
   (concat (company-safe-substring old 0 offset)
           new
           (company-safe-substring old (+ offset (length new)))))
@@ -1831,7 +1831,7 @@ Returns a negative number if the tooltip should be displayed above point."
                     (move-to-window-line (+ row (abs height)))
                     (point)))
              (ov (make-overlay beg end))
-             (args (list (mapcar 'company-untabify
+             (args (list (mapcar 'company-plainify
                                  (company-buffer-lines beg end))
                          column nl above)))