Skip to content

Commit

Permalink
Removed unnecessary space insertion.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomohiro Matsuyama committed Apr 5, 2011
1 parent 5e7e67a commit 9d40fc3
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions auto-complete.el
Expand Up @@ -753,18 +753,15 @@ You can not use it in source definition like (prefix . `NAME')."
(popup-delete ac-menu)
(setq ac-menu)))

(defsubst ac-inline-marker ()
(nth 0 ac-inline))

(defsubst ac-inline-overlay ()
(nth 1 ac-inline))
(nth 0 ac-inline))

(defsubst ac-inline-live-p ()
(and ac-inline (ac-inline-overlay) t))

(defun ac-inline-show (point string)
(unless ac-inline
(setq ac-inline (list (make-marker) nil)))
(setq ac-inline (list nil)))
(save-excursion
(let ((overlay (ac-inline-overlay))
(width 0)
Expand All @@ -786,11 +783,9 @@ You can not use it in source definition like (prefix . `NAME')."
(goto-char point)
(cond
((= width 0)
(set-marker (ac-inline-marker) point)
(let ((buffer-undo-list t))
(insert " "))
(setq width 1
length 1))
;; End-of-line
;; Do nothing
)
((<= width string-width)
;; No space to show
;; Do nothing
Expand All @@ -804,13 +799,20 @@ You can not use it in source definition like (prefix . `NAME')."
(move-overlay overlay point (+ point length))
(overlay-put overlay 'invisible nil))
(setq overlay (make-overlay point (+ point length)))
(setf (nth 1 ac-inline) overlay)
(setf (nth 0 ac-inline) overlay)
(overlay-put overlay 'priority 9999)
;; Help prefix-overlay in some cases
(overlay-put overlay 'keymap ac-current-map))
(overlay-put overlay 'display (substring string 0 1))
;; TODO no width but char
(overlay-put overlay 'after-string (substring string 1))
(if (eq length 0)
;; Case: End-of-line
(progn
(put-text-property 0 1 'cursor t string)
(overlay-put overlay 'after-string string))
(let ((display (substring string 0 1))
(after-string (substring string 1)))
(overlay-put overlay 'display display)
(overlay-put overlay 'after-string after-string)))
(overlay-put overlay 'string original-string))))

(defun ac-inline-delete ()
Expand All @@ -822,14 +824,8 @@ You can not use it in source definition like (prefix . `NAME')."
(defun ac-inline-hide ()
(when (ac-inline-live-p)
(let ((overlay (ac-inline-overlay))
(marker (ac-inline-marker))
(buffer-undo-list t))
(when overlay
(when (marker-position marker)
(save-excursion
(goto-char marker)
(delete-char 1)
(set-marker marker nil)))
(move-overlay overlay (point-min) (point-min))
(overlay-put overlay 'invisible t)
(overlay-put overlay 'display nil)
Expand Down

0 comments on commit 9d40fc3

Please sign in to comment.