all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Marcin Borkowski <mbork@mbork.pl>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Re: How to define a (derived) minor mode inaccessible to the user
Date: Thu, 28 Jan 2021 08:45:08 +0100	[thread overview]
Message-ID: <87tur1ijy3.fsf@mbork.pl> (raw)
In-Reply-To: <87zh0zreah.fsf@web.de>


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



      reply	other threads:[~2021-01-28  7:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-22  5:11 How to define a (derived) minor mode inaccessible to the user Marcin Borkowski
2021-01-22  5:34 ` [External] : " Drew Adams
2021-01-22 15:01   ` Marcin Borkowski
2021-01-22 14:19 ` Stefan Monnier
2021-01-22 15:23   ` Marcin Borkowski
2021-01-22 15:38     ` Stefan Monnier
2021-01-28  7:42       ` Marcin Borkowski
2021-01-28 14:31         ` Stefan Monnier
2021-01-23 13:08 ` Michael Heerdegen
2021-01-28  7:45   ` Marcin Borkowski [this message]

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

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

  git send-email \
    --in-reply-to=87tur1ijy3.fsf@mbork.pl \
    --to=mbork@mbork.pl \
    --cc=help-gnu-emacs@gnu.org \
    --cc=michael_heerdegen@web.de \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.