I am trying to stop emacs from expanding abbrevs after I press the return key. If I press return, I simply want to create a new line without expanding any abbrev at point.

I am relatively new at elisp. I’m assuming the answer involves pre-abbrev-expand-hook, but I haven’t found an answer in my research.

  • 1
    Does this answer your question? Prevent abbrev-mode from expanding on underscore – Tyler May 20 at 14:28
  • @Tyler yes, I linked to that thread in the marked Answer below. Let me know if I should clarify further. – Faulkner77 May 22 at 5:53
  • That's fine, no need to do anything further @Faulkner77. This question will probably end up getting closed, since it already has an answer in the linked post. That doesn't mean there's anything wrong here, just that we want to keep the site streamlined, with a single question/answer post for each issue. – Tyler May 23 at 17:09

It seems this has been addressed after all in similar post here that I found after the fact. The solution I settled on was as follows:

(defun my-self-insert-no-abbrev-RET ()
  (let ((abbrev-mode nil))
    (newline nil t)))

(global-set-key (kbd "RET") #'my-self-insert-no-abbrev-RET)
  • Please link to any duplicate Q&As here. – phils Apr 18 at 12:46

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.