]> code.delx.au - gnu-emacs-elpa/commitdiff
Deal with tabs.
authorNikolaj Schumacher <git@nschum.de>
Wed, 18 Mar 2009 07:58:27 +0000 (08:58 +0100)
committerNikolaj Schumacher <git@nschum.de>
Fri, 20 Mar 2009 11:58:29 +0000 (12:58 +0100)
company.el

index 4a79875f62ef27530c2118c88bf6b06fc0d64600..ce6c11d07ec60bd1e1f4f6ff51f1e31d2b5591a2 100644 (file)
 
 ;;; propertize
 
+(defsubst company-round-tab (arg)
+  (* (/ (+ arg tab-width) tab-width) tab-width))
+
+(defun company-untabify (str)
+  (let* ((pieces (split-string str "\t"))
+         (copy pieces))
+    (while (cdr copy)
+      (setcar copy (company-safe-substring
+                    (car copy) 0 (company-round-tab (string-width (car copy)))))
+      (pop copy))
+    (apply 'concat pieces)))
+
 (defun company-fill-propertize (line width selected)
   (setq line (company-safe-substring line 0 width))
   (add-text-properties 0 width (list 'face 'company-tooltip) line)
            (end (save-excursion
                   (move-to-window-line (+ row height))
                   (point)))
-           (old-string (company-buffer-lines beg end))
+           (old-string
+            (mapcar 'company-untabify (company-buffer-lines beg end)))
            str)
 
       (setq company-pseudo-tooltip-overlay (make-overlay beg end))