Discussion:
Automatic minor modes?
(too old to reply)
Lars Ingebrigtsen
2018-04-14 14:56:55 UTC
Permalink
I was going to write a mode for ~/.authinfo and ~/.netrc that would
cover up the passwords visually so that things are slightly less "eek"
if somebody should happen to walk behind you while you're editing that
file.

But then it was suggested that this should be a minor mode, and that
makes sense: There might well be other kinds of files where you'd rather
cover stuff up, and the minor mode could allow hooks to define syntaxes
and stuff.

But then back to the original remit: ~/.authinfo. So I now have to
write a major mode for ~/.authinfo that will basically do nothing else
than switch this new minor mode on... er... `hide-passwords-mode',
let's call it.

Do we have a method for this? That is, a way to say "this major mode
will activate these minor modes, unless the user has disabled that"?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Yuri Khan
2018-04-14 15:23:43 UTC
Permalink
Post by Lars Ingebrigtsen
I was going to write a mode for ~/.authinfo and ~/.netrc that would
cover up the passwords visually so that things are slightly less "eek"
if somebody should happen to walk behind you while you're editing that
file.
Could be just a few regexen for prettify-symbols-mode. Comes with an
ability to unmask the one the point is on.
Lars Ingebrigtsen
2018-04-14 15:27:43 UTC
Permalink
Post by Yuri Khan
Could be just a few regexen for prettify-symbols-mode. Comes with an
ability to unmask the one the point is on.
It's similar, yes, but it should have commands to allow
unmasking/remasking a single password, I think?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Clément Pit-Claudel
2018-04-14 15:39:42 UTC
Permalink
Post by Lars Ingebrigtsen
Do we have a method for this? That is, a way to say "this major mode
will activate these minor modes, unless the user has disabled that"?
The way it's usually done is with a globalized minor mode. The major mode then sets a variable (eldoc-documentation-function, or prettify-symbols-alist), and the minor mode turns itself on based on that variable.
Lars Ingebrigtsen
2018-04-14 15:45:14 UTC
Permalink
Post by Clément Pit-Claudel
Post by Lars Ingebrigtsen
Do we have a method for this? That is, a way to say "this major mode
will activate these minor modes, unless the user has disabled that"?
The way it's usually done is with a globalized minor mode. The major
mode then sets a variable (eldoc-documentation-function, or
prettify-symbols-alist), and the minor mode turns itself on based on
that variable.
Ah, I see. So `hide-password-mode' would be a globalized minor mode
that's on by default, and the ~/.authinfo major mode would set a
`hide-password-alist' (or something) buffer-local variable to signal
that it should do its work in that buffer?

That makes sense.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Clément Pit-Claudel
2018-04-14 16:40:26 UTC
Permalink
Post by Lars Ingebrigtsen
Post by Clément Pit-Claudel
Post by Lars Ingebrigtsen
Do we have a method for this? That is, a way to say "this major mode
will activate these minor modes, unless the user has disabled that"?
The way it's usually done is with a globalized minor mode. The major
mode then sets a variable (eldoc-documentation-function, or
prettify-symbols-alist), and the minor mode turns itself on based on
that variable.
Ah, I see. So `hide-password-mode' would be a globalized minor mode
that's on by default, and the ~/.authinfo major mode would set a
`hide-password-alist' (or something) buffer-local variable to signal
that it should do its work in that buffer?
That's how I would do it, yup.
Charles A. Roelli
2018-04-14 11:49:31 UTC
Permalink
Date: Sat, 14 Apr 2018 16:56:55 +0200
I was going to write a mode for ~/.authinfo and ~/.netrc that would
cover up the passwords visually so that things are slightly less "eek"
if somebody should happen to walk behind you while you're editing that
file.
Could it build on hs-minor-mode?
Lars Ingebrigtsen
2018-04-14 18:59:42 UTC
Permalink
Post by Charles A. Roelli
Could it build on hs-minor-mode?
Hm, I hadn't seen that one before... I just played with it for a minute
or so, and it seems a bit heavy...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Loading...