I have an elisp file named toro.el that I want to call in my init file

(defconst tablet2 
   '( ("is" "s")      ("it" "t")       ("know" "no")
      ("like" "lk")   ("little" "ll")  ("more" "mo")

(defun toro-abbrev ()
  "Enables words to be expanded as one types."
  (abbrev-mode 1)
  (define-abbrev-table 'global-abbrev-table tablet2))

(provide 'toro)

I then do

(require 'toro)

Yet, the automatic abbrev does not take effect until I call M-x abbrev-mode in my buffer. Why do I have to call M-x abbrev-mode when (toro-abbrev) should enable (abbrev-mode 1).

1 Answer 1


Presumably because you run toro-abbrev in a different buffer than the one where you expect abbrev-mode to take effect: the doc string of abbrev-mode tells you that it does its job in the current buffer. So you have to make the buffer your current buffer and run toro-abbrev there. If you do it from lisp, use with-current-buffer:

(with-current-buffer "foo" (toro-abbrev))

specifically targeting the foo buffer.

  • Is it possible to automatically enable it globally or by major-mode? How would the configuration look like?
    – Dilna
    Aug 3, 2022 at 21:02
  • There you go again: you ask a question, you get an answer and then you ask a different question in a comment. If you have a second question, ask a different question! How hard is that to understand?
    – NickD
    Aug 3, 2022 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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