(defun company--column (&optional pos)
(save-excursion
(when pos (goto-char pos))
- (save-restriction
- (narrow-to-region (save-excursion
- (vertical-motion 0) (point))
- (point))
- (current-column))))
+ (let ((pt (point)))
+ (save-restriction
+ (+ (save-excursion
+ (vertical-motion 0)
+ (narrow-to-region (point) pt)
+ (let ((prefix (get-text-property (point) 'line-prefix)))
+ (if prefix (length prefix) 0)))
+ (current-column))))))
(defun company--row (&optional pos)
(save-excursion
(or company--explicit-action
company-selection-changed))
-(defsubst company-reformat (candidate)
+(defun company-reformat (candidate)
;; company-ispell needs this, because the results are always lower-case
;; It's mory efficient to fix it only when they are displayed.
(concat company-prefix (substring candidate (length company-prefix))))
(and (symbolp this-command) (get this-command 'company-begin)))
(not (and transient-mark-mode mark-active))))
-(defsubst company-call-frontends (command)
+(defun company-call-frontends (command)
(dolist (frontend company-frontends)
(condition-case err
(funcall frontend command)
(error (error "Company: Front-end %s error \"%s\" on command %s"
frontend (error-message-string err) command)))))
-(defsubst company-set-selection (selection &optional force-update)
+(defun company-set-selection (selection &optional force-update)
(setq selection (max 0 (min (1- company-candidates-length) selection)))
(when (or force-update (not (equal selection company-selection)))
(setq company-selection selection
(push (make-string (- company-space-strings-limit 1 i) ?\ ) lst))
(apply 'vector lst)))
-(defsubst company-space-string (len)
+(defun company-space-string (len)
(if (< len company-space-strings-limit)
(aref company-space-strings len)
(make-string len ?\ )))
-(defsubst company-safe-substring (str from &optional to)
+(defun company-safe-substring (str from &optional to)
(if (> from (string-width str))
""
(with-temp-buffer
(defun company-buffer-lines (beg end)
(goto-char beg)
(let (lines)
- (while (< (point) end)
- (let ((bol (point)))
+ (while (and (= 1 (vertical-motion 1))
+ (<= (point) end))
+ (let ((bound (min end (1- (point)))))
;; A visual line can contain several physical lines (e.g. with outline's
;; folding overlay). Take only the first one.
- (re-search-forward "$")
- (push (buffer-substring bol (min end (point))) lines))
- (vertical-motion 1))
+ (push (buffer-substring beg
+ (save-excursion
+ (goto-char beg)
+ (re-search-forward "$" bound 'move)
+ (point)))
+ lines))
+ (setq beg (point)))
+ (unless (eq beg end)
+ (push (buffer-substring beg end) lines))
(nreverse lines)))
-(defsubst company-modify-line (old new offset)
- (concat (company-safe-substring old 0 offset)
- new
- (company-safe-substring old (+ offset (length new)))))
+(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))))))
(defsubst company--length-limit (lst limit)
(if (nthcdr limit lst)
(let ((edges (window-inside-edges)))
(- (nth 3 edges) (nth 1 edges))))
-(defsubst company--pseudo-tooltip-height ()
+(defun company--pseudo-tooltip-height ()
"Calculate the appropriate tooltip height.
Returns a negative number if the tooltip should be displayed above point."
(let* ((lines (company--row))
(overlay-put company-pseudo-tooltip-overlay 'invisible t)
;; Beat outline's folding overlays, at least.
(overlay-put company-pseudo-tooltip-overlay 'priority 1)
+ ;; No (extra) prefix for the first line.
+ (overlay-put company-pseudo-tooltip-overlay 'line-prefix "")
(overlay-put company-pseudo-tooltip-overlay 'before-string
(overlay-get company-pseudo-tooltip-overlay 'company-before))
(overlay-put company-pseudo-tooltip-overlay 'window (selected-window))))
(message "%s" company-echo-last-msg)
(message ""))))
-(defsubst company-echo-show-soon (&optional getter)
+(defun company-echo-show-soon (&optional getter)
(when company-echo-timer
(cancel-timer company-echo-timer))
(setq company-echo-timer (run-with-timer 0 nil 'company-echo-show getter)))
(defsubst company-echo-show-when-idle (&optional getter)
- (when (sit-for .01)
- (company-echo-show getter)))
-
-(defsubst company-echo-show-when-not-busy (&optional getter)
- "Run `company-echo-show' with arg GETTER once Emacs isn't busy."
(when (sit-for company-echo-delay)
(company-echo-show getter)))