# HG changeset patch # User Karl Heuer # Date 766096244 0 # Node ID 42c6431d1e00738f185991e21615fdc7f6b7c999 # Parent c451a18c19450466773c5a069291ad0cd31f2ec8 (comint-dynamic-complete-as-filename): Save end of match before calling other functions. Handle non-match too. diff -r c451a18c1945 -r 42c6431d1e00 lisp/comint.el --- a/lisp/comint.el Mon Apr 11 20:09:44 1994 +0000 +++ b/lisp/comint.el Mon Apr 11 20:30:44 1994 +0000 @@ -1836,11 +1836,14 @@ (let* ((completion-ignore-case nil) (completion-ignored-extensions comint-completion-fignore) (success t) - (filename (or (comint-match-partial-filename) "")) - (pathdir (file-name-directory filename)) - (pathnondir (file-name-nondirectory filename)) - (directory (if pathdir (comint-directory pathdir) default-directory)) - (completion (file-name-completion pathnondir directory))) + (filename (comint-match-partial-filename)) + endpos pathdir pathnondir directory completion) + (setq endpos (if filename (match-end 0) (point))) + (or filename (setq filename "")) + (setq pathdir (file-name-directory filename) + pathnondir (file-name-nondirectory filename) + directory (if pathdir (comint-directory pathdir) default-directory) + completion (file-name-completion pathnondir directory)) (cond ((null completion) (message "No completions of %s" filename) (setq success nil)) @@ -1851,7 +1854,7 @@ (comint-dynamic-list-filename-completions)) (t ; Completion string returned. (let ((file (concat (file-name-as-directory directory) completion))) - (goto-char (match-end 0)) + (goto-char endpos) (insert (substring (directory-file-name completion) (length pathnondir))) (cond ((symbolp (file-name-completion completion directory))