0

I am sick of pressing Insert instead of Backspace and running into problems in certain modes.

How can I fix it?

One option is to have some visual indication that overwrite mode has been activated, so I can press Insert again and correct my mistake.

6
  • In a generic build of Emacs 26.3, when the minor-mode overwrite-mode is active, the mode-line states Ovwrt -- and, that Ovwrt visualization disappears from the mode-line when overwrite-mode is deactivated. The area of the mode-line where Ovwrt appears/disappears is the section dedicated to active minor-modes. You could also check by typing C-h v aka M-x describe-variable and see whether the variable overwrite-mode is non-nil overwrite-mode-textual (i.e., active) of nil (i.e., deactivated). If that does not answer your question, then consider editing your question ... – lawlist Jul 19 '20 at 23:06
  • The problem is Ovwrt is not visible when Emacs takes only half of the screen in a very common side by side workflow. How can I make it better? – ruby_object Jul 19 '20 at 23:19
  • Changed the question title. The question is not about knowing whether you're in some minor mode, which is typically about how to know from Lisp. The question is apparently how to easily tell, interactively, whether you're in overwrite-mode. – Drew Jul 19 '20 at 23:26
  • Yes, but still the answer I found on SO may prove useful to some extent. – ruby_object Jul 19 '20 at 23:38
  • There is a code that produces 'Overwrite mode enabled in current buffer' and 'Overwrite mode disabled in current buffer', so if i could figure out how to add my own code to that, I could theoretically do something more visible. – ruby_object Jul 19 '20 at 23:42
1

If it is the position of the key that is the problem, then you can unbind the key so that it does not enable overwrite-mode any longer:

(global-set-key (kbd "<insert>") nil)

If you still want to be able to enable the mode with a key, you can bind some other key to it, perhaps a function key:

(global-set-key (kbd "<f8>") #'overwrite-mode)

although you will have to figure out what would work for you.

0

In the end, I used https://www.emacswiki.org/emacs/AlarmBell and added some code to overwrite-mode-hook. So now I get a visible alarm, which may be better than completely disabling the key. Time will tell if this is better than the other answer.

(defun double-flash-mode-line ()
    (let ((flash-sec (/ 1.0 20)))
      (invert-face 'mode-line)
      (run-with-timer flash-sec nil #'invert-face 'mode-line)
      (run-with-timer (* 2 flash-sec) nil #'invert-face 'mode-line)
      (run-with-timer (* 3 flash-sec) nil #'invert-face 'mode-line)))


(add-hook 'overwrite-mode-hook #'(lambda () (double-flash-mode-line)))
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.