unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Rodrigo Morales <rodrigo-mailing-lists@morales.pe>
To: <help-gnu-emacs@gnu.org>
Subject: How to disable abbrev-mode in all major modes?
Date: Fri, 18 Oct 2024 18:34:38 -0500	[thread overview]
Message-ID: <87ed4ddlyp.fsf@morales.pe> (raw)


Let me explain my use case: I want abbrev-mode to be disabled in all buffers because I want to expand abbreviations by explicitly calling the function =expand-abbrev=, but the default behavior is that abbreviations are expanded when pressing SPC, punctuations (e.g. PERIOD and COMMA) or C-i. After some investigation, I found out that abbrev-mode is enabled in message-mode (see next section for details on how I found that out).

I know that I can define a function that disables abbrev-mode and add it as a hook of those major modes where abbrev-mode is enabled by default, but I wonder if there is a cleaner way than doing this, because I don't want to be editing my configuration whenever I found out another major mode enables abbrev-mode by default.

#+BEGIN_SRC elisp
(defun my-abbrev-mode-disable ()
  (abbrev-mode -1))
(add-hook 'message-mode-hook 'my-abbrev-mode-disable)
#+END_SRC

*** Finding out abbrev-mode is enabled in message-mode

I started Emacs by using the command shown below:

#+BEGIN_SRC sh
emacs -Q
#+END_SRC

In the buffer =*scratch*=, the value of the variable =abbrev-mode= was nil, so I conclude that =abbrev-mode= was not enabled. The major mode of the buffer =*scratch*= was =lisp-interaction-mode=.

I called compose-mail (by default bound to =C-x m= in GNU Emacs 29.4). In the buffer =*unsent mail*=, the value of the variable =abbrev-mode= was t, so I conclude that =abbrev-mode= was enabled. The major mode of the buffer =*unsent mail*= was =message-mode=.




             reply	other threads:[~2024-10-18 23:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18 23:34 Rodrigo Morales [this message]
2024-10-19  0:28 ` How to disable abbrev-mode in all major modes? Kristoffer Balintona
2024-10-19  5:52 ` Michael Heerdegen via Users list for the GNU Emacs text editor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ed4ddlyp.fsf@morales.pe \
    --to=rodrigo-mailing-lists@morales.pe \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).