From 87e53578861a37748cdfc7cb017b73c2bcf572a4 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Fri, 12 Nov 2021 09:02:28 +0100 Subject: [PATCH] lisp/icomplete.el (icomplete-fido-backward-updir): Expand "~/" * lisp/icomplete.el (icomplete-fido-backward-updir): Expand "~/" (bug#43925). --- lisp/icomplete.el | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lisp/icomplete.el b/lisp/icomplete.el index a61c9d6354c..f909a3b1771 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -380,13 +380,17 @@ if that doesn't produce a completion match." (defun icomplete-fido-backward-updir () "Delete char before or go up directory, like `ido-mode'." (interactive) - (if (and (eq (char-before) ?/) - (eq (icomplete--category) 'file)) - (save-excursion - (goto-char (1- (point))) - (when (search-backward "/" (point-min) t) - (delete-region (1+ (point)) (point-max)))) - (call-interactively 'backward-delete-char))) + (cond ((and (eq (char-before) ?/) + (eq (icomplete--category) 'file)) + (when (string-equal (icomplete--field-string) "~/") + (delete-region (icomplete--field-beg) (icomplete--field-end)) + (insert (expand-file-name "~/")) + (goto-char (line-end-position))) + (save-excursion + (goto-char (1- (point))) + (when (search-backward "/" (point-min) t) + (delete-region (1+ (point)) (point-max))))) + (t (call-interactively 'backward-delete-char)))) (defvar icomplete-fido-mode-map (let ((map (make-sparse-keymap))) -- 2.39.2