Properly keep cursor out of minibuffer prompt

The prompt in the minibuffer is read-only. You are able to move the
cursor into it before this fix.

This also more effectively silences echo-area output when deleting text
in the minibuffer. No more "Text is read-only" blocking what you're
typing.
This commit is contained in:
Henrik Lissner 2019-03-01 15:37:42 -05:00
parent fb57f367e7
commit 21e01189b9
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 14 additions and 14 deletions

View file

@ -526,18 +526,20 @@ it to fix all that visual noise."
frame))) frame)))
(add-hook 'after-make-frame-functions #'doom|disable-whitespace-mode-in-childframes) (add-hook 'after-make-frame-functions #'doom|disable-whitespace-mode-in-childframes)
(defun doom*silence-motion-errors (orig-fn &rest args) ;; Don't allow cursor to enter the prompt
"Prevent disruptive motion errors taking over the minibuffer while we're in (setq minibuffer-prompt-properties '(read-only t intangible t cursor-intangible t face minibuffer-prompt))
it." (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
(if (not (minibufferp))
(apply orig-fn args) ;; Don't display messages in the minibuffer when using the minibuffer
(ignore-errors (apply orig-fn args)) (defmacro doom-silence-motion-key (command key)
(when (<= (point) (minibuffer-prompt-end)) (let ((key-command (intern (format "doom/silent-%s" command))))
(goto-char (minibuffer-prompt-end))))) `(progn
(advice-add #'left-char :around #'doom*silence-motion-errors) (defun ,key-command ()
(advice-add #'right-char :around #'doom*silence-motion-errors) (interactive)
(advice-add #'delete-backward-char :around #'doom*silence-motion-errors) (ignore-errors (call-interactively ',command)))
(advice-add #'backward-kill-sentence :around #'doom*silence-motion-errors) (define-key minibuffer-local-map (kbd ,key) #',key-command))))
(doom-silence-motion-key backward-delete-char "<backspace>")
(doom-silence-motion-key delete-char "<delete>")
;; Switch to `doom-fallback-buffer' if on last real buffer ;; Switch to `doom-fallback-buffer' if on last real buffer
(advice-add #'kill-this-buffer :around #'doom*switch-to-fallback-buffer-maybe) (advice-add #'kill-this-buffer :around #'doom*switch-to-fallback-buffer-maybe)

View file

@ -230,8 +230,6 @@ and `doom-exit-window-hook'."
inhibit-default-init t inhibit-default-init t
initial-major-mode 'fundamental-mode initial-major-mode 'fundamental-mode
initial-scratch-message nil initial-scratch-message nil
;; keep the point out of the minibuffer
minibuffer-prompt-properties '(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt)
;; History & backup settings (save nothing, that's what git is for) ;; History & backup settings (save nothing, that's what git is for)
auto-save-default nil auto-save-default nil
create-lockfiles nil create-lockfiles nil