Commit ee0998bd authored by Troels Henriksen's avatar Troels Henriksen
Browse files

Fixed issue where the symbol-completer was a bit too eager in deleting

the original partial symbol.
parent 9ba9d1d4
......@@ -245,24 +245,22 @@ Definition command was issued."
(clear-completions)))
(define-command (com-complete-symbol :name t :command-table lisp-table) ()
"Attempt to complete the symbol at mark.
"Attempt to complete the symbol at mark. If successful, move point
to end of symbol.
If more than one completion is available, a list of possible
completions will be displayed."
If more than one completion is available, a list of
possible completions will be displayed."
(let* ((pane (current-window))
(buffer (buffer pane))
(syntax (syntax buffer))
(point-current-window (point pane))
(name (symbol-name-at-mark point-current-window
(mark (point pane))
(name (symbol-name-at-mark mark
syntax)))
(when name
(with-syntax-package syntax point-current-window (package)
(let ((completion (show-completions syntax name package))
(mark (clone-mark point-current-window)))
(with-syntax-package syntax mark (package)
(let ((completion (show-completions syntax name package)))
(unless (= (length completion) 0)
(backward-object mark (length name))
(delete-region mark point-current-window)
(insert-sequence point-current-window completion)))))))
(replace-symbol-at-mark mark syntax completion)))))))
(define-command (com-fuzzily-complete-symbol :name t :command-table lisp-table) ()
"Attempt to fuzzily complete the abbreviation at mark.
......@@ -273,17 +271,14 @@ will be displayed."
(let* ((pane (current-window))
(buffer (buffer pane))
(syntax (syntax buffer))
(point-current-window (point pane))
(name (symbol-name-at-mark point-current-window
(mark (mark pane))
(name (symbol-name-at-mark mark
syntax)))
(when name
(with-syntax-package syntax point-current-window (package)
(let ((completion (show-fuzzy-completions syntax name package))
(mark (clone-mark point-current-window)))
(with-syntax-package syntax mark (package)
(let ((completion (show-fuzzy-completions syntax name package)))
(unless (= (length completion) 0)
(backward-object mark (length name))
(delete-region mark point-current-window)
(insert-sequence point-current-window completion)))))))
(replace-symbol-at-mark mark syntax completion)))))))
(define-presentation-to-command-translator lookup-symbol-arglist
(symbol com-lookup-arglist lisp-table
......
......@@ -1573,6 +1573,19 @@ returned."
(let ((token (symbol-at-mark mark syntax)))
(when token (token-string syntax token))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Useful functions for modifying forms based on the mark.
(defun replace-symbol-at-mark (mark syntax string)
"Replace the symbol at `mark' with `string' and move `mark' to
after `string'."
(let ((token (symbol-at-mark mark syntax)))
(unless (= (offset mark) (start-offset token))
(backward-expression mark syntax 1 nil))
(forward-kill-expression mark syntax)
(insert-sequence mark string)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; display
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment