In an Emacs Lisp function, I would like to insert some text at point or - if the region is active - overwrite it with such text. How to do it?
1 Answer
For Emacs setting:
(delete-selection-mode t) ; delete seleted text when typing
For lisp code, add following line before insert:
(if (region-active-p) (delete-region (region-beginning) (region-end)))
-
-
Sorry, I didn't read your question carefully. I updated my answer, hope it helps.– AhLeungMay 30, 2018 at 5:36