Skip to content
Browse files

Removed unnecessary space insertion.

  • Loading branch information...
1 parent 5e7e67a commit 9d40fc3b43fc16dd4a3a51fa6f062064cc9b272d Tomohiro Matsuyama committed Apr 5, 2011
Showing with 15 additions and 19 deletions.
  1. +15 −19 auto-complete.el
View
34 auto-complete.el
@@ -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)
@@ -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
@@ -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 ()
@@ -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)

0 comments on commit 9d40fc3

Please sign in to comment.
Something went wrong with that request. Please try again.