unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* so-long and special major modes
@ 2020-12-08  5:30 Richard Stallman
  2020-12-08 20:08 ` Phil Sainty
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Stallman @ 2020-12-08  5:30 UTC (permalink / raw)
  To: Phil Sainty; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

Emacs distinguishes two kinds of major modes: those that are for a
kind of data, and those that correspond to special applications.  In
the former, q will self-insert.  In the latter, q probably means
"quit".  The way to distinguish is to test the mode-class property of
the major mode symbol.

Dired, Rmail and Info are examples of special major modes.

so-long-major-mode may be ok to use in an ordinary major mode, but it
is no good in a special mode.  In that situation, it is necessary to
use so-long-minor-mode.
 
-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: so-long and special major modes
  2020-12-08  5:30 so-long and special major modes Richard Stallman
@ 2020-12-08 20:08 ` Phil Sainty
  2020-12-09  6:48   ` Richard Stallman
  0 siblings, 1 reply; 4+ messages in thread
From: Phil Sainty @ 2020-12-08 20:08 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

On 8/12/20 6:30 pm, Richard Stallman wrote:
> Emacs distinguishes two kinds of major modes: those that are for a
> kind of data, and those that correspond to special applications.  In
> the former, q will self-insert.  In the latter, q probably means
> "quit".  The way to distinguish is to test the mode-class property of
> the major mode symbol.
> 
> Dired, Rmail and Info are examples of special major modes.
> 
> so-long-major-mode may be ok to use in an ordinary major mode, but it
> is no good in a special mode.  In that situation, it is necessary to
> use so-long-minor-mode.

In general I felt it was necessary to white-list the modes for which
it is acceptable for so-long to take action, because I don't think it's
possible to automatically detect every mode in which it might be
problematic.

The `so-long-target-modes' variable serves this purpose -- the automated
behaviour only kicks in for buffers using a major mode (or derivative
thereof) from this list.  That's (prog-mode css-mode sgml-mode nxml-mode)
by default.


-Phil



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: so-long and special major modes
  2020-12-08 20:08 ` Phil Sainty
@ 2020-12-09  6:48   ` Richard Stallman
  2020-12-09 10:46     ` Phil Sainty
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Stallman @ 2020-12-09  6:48 UTC (permalink / raw)
  To: Phil Sainty; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > In general I felt it was necessary to white-list the modes for which
  > it is acceptable for so-long to take action, because I don't think it's
  > possible to automatically detect every mode in which it might be
  > problematic.

How about if you try activating for all except special modes?
It MIGHT turn out to be exactly right.  And if not, you can override
as needed.


-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: so-long and special major modes
  2020-12-09  6:48   ` Richard Stallman
@ 2020-12-09 10:46     ` Phil Sainty
  0 siblings, 0 replies; 4+ messages in thread
From: Phil Sainty @ 2020-12-09 10:46 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

On 9/12/20 7:48 pm, Richard Stallman wrote:
>   > In general I felt it was necessary to white-list the
>   > modes for which it is acceptable for so-long to take
>   > action, because I don't think it's possible to
>   > automatically detect every mode in which it might be
>   > problematic.
> 
> How about if you try activating for all except special
> modes?  It MIGHT turn out to be exactly right.  And if
> not, you can override as needed.

I don't have the broad knowledge of major modes necessary to say
whether your idea would be right in all cases.  I think that it
would increase the number of major modes being considered by a
significant margin, though, so to me it sounds risky, but I'd
welcome additional input from anyone who feels confident on the
matter.

It's certainly broadening the scope of the library, which was
originally written to mitigate issues with files of 'minified'
programming code and data formats (being a somewhat common
situation in which implicit assumptions made by modes about a
buffer's contents could end up being badly incorrect).

If the rule isn't correct in all cases, then I'm firmly against
the notion of maintaining a manual list of exceptions.  If we
don't have a reliable rule, I would greatly prefer that we err on
the side of caution, and only trigger so-long in situations where
we are confident that we will not be causing worse problems than
the one we're trying to solve.

If anyone would like to experiment with the idea, though, you
can do that by setting `so-long-target-modes' to `t', and then
writing a custom `so-long-predicate' function.


-Phil




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-09 10:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08  5:30 so-long and special major modes Richard Stallman
2020-12-08 20:08 ` Phil Sainty
2020-12-09  6:48   ` Richard Stallman
2020-12-09 10:46     ` Phil Sainty

Code repositories for project(s) associated with this public inbox

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

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).