0

I am using abbrev-mode to perform the reverse process, writing a perfectly written word, and an abbreviation gets inserted instead. I want a quick way to disable the replacement when I want to. During a normal session I would be enabling and disabling abbrev-mode several times.

This is my current setup

(defun roto-abbrev ()
  "Enables words to be expanded as one types."
  (interactive)

  (dolist
      (hook '(lisp-interaction-mode-hook 
          emacs-lisp-mode-hook
          text-mode-hook
          org-mode-hook
          prog-mode-hook))
    (add-hook hook #'abbrev-mode))

  (kill-all-abbrevs)
  
  (define-abbrev-table 'global-abbrev-table
    (apply #'append
           (mapcar #'tablet-name (number-sequence 1 56)))))
6
  • 1
    I don't understand the question: when a buffer with the appropriate major mode is created, abbrev-mode will be enabled automatically. Isn't that what you want? Why would you want to enable it again? As for disabling, C-- M-x abbrev-mode disables it interactively. What more do you want?
    – NickD
    Aug 5 at 14:46
  • 1
    I am actually doing the reverse, writing a perfectly written word, and an abbreviation being inserted. I want a quick way to disable the replacement when a want to. During a normal session I would be enabling and disabling abbrev-mode several times.
    – Ephram
    Aug 5 at 15:29
  • So bind abbrev-mode to maybe a function key. Every time you press the key, it will toggle abbrev-mode from on to off to on ...
    – NickD
    Aug 5 at 15:47
  • E.g. (global-set-key [f12] #'abbrev-mode) to bind it to f12. Note BTW, how much clearer your comment is than the original question (and how quickly a solution can be given when the question is clear). I'd suggest that you edit your question and put the comment in its place.
    – NickD
    Aug 5 at 15:54
  • Is global-abbrev-table a global variable? Meaning that once it is setup, doing (abbrev-mode -1) would not kill or flush the table?
    – Ephram
    Aug 5 at 16:12

0

Your Answer

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

Browse other questions tagged or ask your own question.