[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to define a (derived) minor mode inaccessible to the user
From: |
Marcin Borkowski |
Subject: |
Re: How to define a (derived) minor mode inaccessible to the user |
Date: |
Thu, 28 Jan 2021 08:45:08 +0100 |
User-agent: |
mu4e 1.1.0; emacs 28.0.50 |
On 2021-01-23, at 14:08, Michael Heerdegen <michael_heerdegen@web.de> wrote:
> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> Hello everyone,
>>
>> I'd like to define a special-purpose major mode, derived from
>> `special-mode', in such a way that the user cannot set it using M-x.
>> (It is to be called via another command.)
>
> I wonder if that feature then does have to be defined as a regular mode
> at all, or if something else would fit: if there could be some other
> solution to what you want.
Well, I could just use special-mode instead of a custom, derived one.
But I think it would not be good practice - I assume special-mode is not
to be used directly but only to create derived modes.
> Second point: If it's really bad for the user to enable the mode, give
> it a name like "*-helper-mode" or so, and I guess you could add
> something like
>
> (when (called-interactively-p 'any)
> (user-error "This mode is for internal use only"))
>
> to the mode function's body.
Nice, thanks!
It's not that it would be _bad_ for the user. It just doesn't make any
sense. And given that people sometimes do things by accident, and not
everyone knows about view-lossage etc., making it impossible/hard to
turn such a mode manually seems reasonable.
Best,
--
Marcin Borkowski
http://mbork.pl
Re: How to define a (derived) minor mode inaccessible to the user, Michael Heerdegen, 2021/01/23
- Re: How to define a (derived) minor mode inaccessible to the user,
Marcin Borkowski <=