Skip to content

Commit

Permalink
New command to delete char backward
Browse files Browse the repository at this point in the history
When deleting char backward very fast (keep pressing DEL), cursor hit
prompt and we have a read-only error; Helm in this case doesn't have
the time to update according to minibuffer contents. This command
ensure this is done.
  • Loading branch information
thierryvolpiatto committed Sep 27, 2023
1 parent 8d208ac commit 31d2dfe
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions helm-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ i.e. the loop is not entered after running COMMAND."
(define-key map (kbd "M-(") #'helm-prev-visible-mark)
(define-key map (kbd "M-)") #'helm-next-visible-mark)
(define-key map (kbd "C-k") #'helm-delete-minibuffer-contents)
(define-key map (kbd "DEL") #'helm-delete-char-backward)
(define-key map (kbd "C-x C-f") #'helm-quit-and-find-file)
(define-key map (kbd "M-m") #'helm-toggle-all-marks)
(define-key map (kbd "M-a") #'helm-mark-all)
Expand Down Expand Up @@ -4014,16 +4015,29 @@ Update is reenabled when idle 1s."
(with-helm-alive-p
(unless helm--suspend-update-interactive-flag
(helm-suspend-update 1))
(delete-char (- arg))
(helm-delete-char-backward arg)
(run-with-idle-timer
1 nil
(lambda ()
(unless helm--suspend-update-interactive-flag
(helm-suspend-update -1)
(helm-check-minibuffer-input)
(helm-force-update))))))
;; Already done by helm-delete-char-backward.
(unless (string= (minibuffer-contents) "")
(helm-force-update)))))))
(put 'helm-delete-backward-no-update 'helm-only t)

(defun helm-delete-char-backward (arg)
"Delete char backward and update when reaching prompt."
(interactive "p")
(condition-case _err
(delete-char (- arg))
(buffer-read-only
(progn
(helm-update)
(helm-reset-yank-point)))))
(put 'helm-delete-char-backward 'helm-only t)

(defun helm--suspend-read-passwd (old--fn &rest args)
"Suspend Helm while reading password.
This is used to advice `tramp-read-passwd', `ange-ftp-get-passwd'
Expand Down

0 comments on commit 31d2dfe

Please sign in to comment.