unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: Automatic minor modes?
  2018-04-14 14:56 Automatic minor modes? Lars Ingebrigtsen
@ 2018-04-14 11:49 ` Charles A. Roelli
  2018-04-14 18:59   ` Lars Ingebrigtsen
  2018-04-14 15:23 ` Yuri Khan
  2018-04-14 15:39 ` Automatic minor modes? Clément Pit-Claudel
  2 siblings, 1 reply; 23+ messages in thread
From: Charles A. Roelli @ 2018-04-14 11:49 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

> From: Lars Ingebrigtsen <larsi@gnus.org>
> 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?



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

* Automatic minor modes?
@ 2018-04-14 14:56 Lars Ingebrigtsen
  2018-04-14 11:49 ` Charles A. Roelli
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Lars Ingebrigtsen @ 2018-04-14 14:56 UTC (permalink / raw)
  To: emacs-devel

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




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

* Re: Automatic minor modes?
  2018-04-14 14:56 Automatic minor modes? Lars Ingebrigtsen
  2018-04-14 11:49 ` Charles A. Roelli
@ 2018-04-14 15:23 ` Yuri Khan
  2018-04-14 15:27   ` Lars Ingebrigtsen
  2018-04-14 15:39 ` Automatic minor modes? Clément Pit-Claudel
  2 siblings, 1 reply; 23+ messages in thread
From: Yuri Khan @ 2018-04-14 15:23 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Emacs developers

On Sat, Apr 14, 2018 at 9:56 PM, Lars Ingebrigtsen <larsi@gnus.org> wrote:
> 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.



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

* Re: Automatic minor modes?
  2018-04-14 15:23 ` Yuri Khan
@ 2018-04-14 15:27   ` Lars Ingebrigtsen
  2018-06-27  1:31     ` Ted Zlatanov
  0 siblings, 1 reply; 23+ messages in thread
From: Lars Ingebrigtsen @ 2018-04-14 15:27 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Emacs developers

Yuri Khan <yuri.v.khan@gmail.com> writes:

> 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



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

* Re: Automatic minor modes?
  2018-04-14 14:56 Automatic minor modes? Lars Ingebrigtsen
  2018-04-14 11:49 ` Charles A. Roelli
  2018-04-14 15:23 ` Yuri Khan
@ 2018-04-14 15:39 ` Clément Pit-Claudel
  2018-04-14 15:45   ` Lars Ingebrigtsen
  2 siblings, 1 reply; 23+ messages in thread
From: Clément Pit-Claudel @ 2018-04-14 15:39 UTC (permalink / raw)
  To: emacs-devel

On 2018-04-14 10:56, Lars Ingebrigtsen wrote:
> 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.



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

* Re: Automatic minor modes?
  2018-04-14 15:39 ` Automatic minor modes? Clément Pit-Claudel
@ 2018-04-14 15:45   ` Lars Ingebrigtsen
  2018-04-14 16:40     ` Clément Pit-Claudel
  0 siblings, 1 reply; 23+ messages in thread
From: Lars Ingebrigtsen @ 2018-04-14 15:45 UTC (permalink / raw)
  To: Clément Pit-Claudel; +Cc: emacs-devel

Clément Pit-Claudel <cpitclaudel@gmail.com> writes:

> On 2018-04-14 10:56, Lars Ingebrigtsen wrote:
>> 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



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

* Re: Automatic minor modes?
  2018-04-14 15:45   ` Lars Ingebrigtsen
@ 2018-04-14 16:40     ` Clément Pit-Claudel
  0 siblings, 0 replies; 23+ messages in thread
From: Clément Pit-Claudel @ 2018-04-14 16:40 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

On 2018-04-14 11:45, Lars Ingebrigtsen wrote:
> Clément Pit-Claudel <cpitclaudel@gmail.com> writes:
> 
>> On 2018-04-14 10:56, Lars Ingebrigtsen wrote:
>>> 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.



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

* Re: Automatic minor modes?
  2018-04-14 11:49 ` Charles A. Roelli
@ 2018-04-14 18:59   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 23+ messages in thread
From: Lars Ingebrigtsen @ 2018-04-14 18:59 UTC (permalink / raw)
  To: Charles A. Roelli; +Cc: emacs-devel

charles@aurox.ch (Charles A. Roelli) writes:

> 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



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

* Re: Automatic minor modes?
  2018-04-14 15:27   ` Lars Ingebrigtsen
@ 2018-06-27  1:31     ` Ted Zlatanov
  2018-07-22 12:26       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 23+ messages in thread
From: Ted Zlatanov @ 2018-06-27  1:31 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Emacs developers, Yuri Khan

On Sat, 14 Apr 2018 17:27:43 +0200 Lars Ingebrigtsen <larsi@gnus.org> wrote: 

LI> Yuri Khan <yuri.v.khan@gmail.com> writes:
>> Could be just a few regexen for prettify-symbols-mode. Comes with an
>> ability to unmask the one the point is on.

LI> It's similar, yes, but it should have commands to allow
LI> unmasking/remasking a single password, I think?

prettify-symbols-mode has built-in the perfect tool for what
you're describing, `prettify-symbols-unprettify-at-point':

prettify-symbols-unprettify-at-point is a variable defined in ‘prog-mode.el’.
Its value is ‘right-edge’
Original value was nil

Documentation:
If non-nil, show the non-prettified version of a symbol when point is on it.
If set to the symbol ‘right-edge’, also unprettify if point
is immediately after the symbol.  The prettification will be
reapplied as soon as point moves away from the symbol.  If
set to nil, the prettification persists even when point is
on the symbol.



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

* Re: Automatic minor modes?
  2018-06-27  1:31     ` Ted Zlatanov
@ 2018-07-22 12:26       ` Lars Ingebrigtsen
  2018-07-22 15:51         ` Clément Pit-Claudel
  0 siblings, 1 reply; 23+ messages in thread
From: Lars Ingebrigtsen @ 2018-07-22 12:26 UTC (permalink / raw)
  To: Yuri Khan; +Cc: Emacs developers

Ted Zlatanov <tzz@lifelogs.com> writes:

>>> Could be just a few regexen for prettify-symbols-mode. Comes with an
>>> ability to unmask the one the point is on.
>
> LI> It's similar, yes, but it should have commands to allow
> LI> unmasking/remasking a single password, I think?
>
> prettify-symbols-mode has built-in the perfect tool for what
> you're describing, `prettify-symbols-unprettify-at-point':
>
> prettify-symbols-unprettify-at-point is a variable defined in ‘prog-mode.el’.
> Its value is ‘right-edge’

Ah, cool, then we should perhaps just activate that minor mode in
.authino/.netrc buffers?  (With the appropriate regexps to hide the
"passwd" token.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



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

* Re: Automatic minor modes?
  2018-07-22 12:26       ` Lars Ingebrigtsen
@ 2018-07-22 15:51         ` Clément Pit-Claudel
  2018-07-22 19:01           ` Stefan Monnier
  0 siblings, 1 reply; 23+ messages in thread
From: Clément Pit-Claudel @ 2018-07-22 15:51 UTC (permalink / raw)
  To: emacs-devel

On 2018-07-22 08:26, Lars Ingebrigtsen wrote:
> Ted Zlatanov <tzz@lifelogs.com> writes:
> 
>>>> Could be just a few regexen for prettify-symbols-mode. Comes with an
>>>> ability to unmask the one the point is on.
>>
>> LI> It's similar, yes, but it should have commands to allow
>> LI> unmasking/remasking a single password, I think?
>>
>> prettify-symbols-mode has built-in the perfect tool for what
>> you're describing, `prettify-symbols-unprettify-at-point':
>>
>> prettify-symbols-unprettify-at-point is a variable defined in ‘prog-mode.el’.
>> Its value is ‘right-edge’
> 
> Ah, cool, then we should perhaps just activate that minor mode in
> .authino/.netrc buffers?  (With the appropriate regexps to hide the
> "passwd" token.)

Even better would be to move the "unmask-at-point" feature out of prettify-symbols-mode, so that more complex hiding could use it too (prettify-symbols-mode is fairly strict in its inputs).

As a concrete example, company-coq prettifies abc__hijk as abcₕᵢⱼₖ (notice the hidden "__"), and I had to reimplement the unmasking feature.

Clément.



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

* Re: Automatic minor modes?
  2018-07-22 15:51         ` Clément Pit-Claudel
@ 2018-07-22 19:01           ` Stefan Monnier
  2018-07-22 20:06             ` Clément Pit-Claudel
  0 siblings, 1 reply; 23+ messages in thread
From: Stefan Monnier @ 2018-07-22 19:01 UTC (permalink / raw)
  To: emacs-devel

> Even better would be to move the "unmask-at-point" feature out of
> prettify-symbols-mode, so that more complex hiding could use it too
> (prettify-symbols-mode is fairly strict in its inputs).

How 'bout adding it to `reveal-mode`?


        Stefan




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

* Re: Automatic minor modes?
  2018-07-22 19:01           ` Stefan Monnier
@ 2018-07-22 20:06             ` Clément Pit-Claudel
  2018-10-08  1:05               ` Ted Zlatanov
  0 siblings, 1 reply; 23+ messages in thread
From: Clément Pit-Claudel @ 2018-07-22 20:06 UTC (permalink / raw)
  To: emacs-devel

On 2018-07-22 15:01, Stefan Monnier wrote:
>> Even better would be to move the "unmask-at-point" feature out of
>> prettify-symbols-mode, so that more complex hiding could use it too
>> (prettify-symbols-mode is fairly strict in its inputs).
> 
> How 'bout adding it to `reveal-mode`?

Maybe ? But bonus points if each type of revealing can be turned on or off separately; maybe something like buffer-invisibility-spec? (I think currently you can disable revealing for some overlays, but not the other way around? basically I'd like my minor mode to be able to turn on revealing, but only for the overlays it created)



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

* Re: Automatic minor modes?
  2018-07-22 20:06             ` Clément Pit-Claudel
@ 2018-10-08  1:05               ` Ted Zlatanov
  2018-10-08 14:57                 ` Stefan Monnier
  0 siblings, 1 reply; 23+ messages in thread
From: Ted Zlatanov @ 2018-10-08  1:05 UTC (permalink / raw)
  To: emacs-devel

On Sun, 22 Jul 2018 16:06:01 -0400 Clément Pit-Claudel <cpitclaudel@gmail.com> wrote: 

CP> On 2018-07-22 15:01, Stefan Monnier wrote:
>>> Even better would be to move the "unmask-at-point" feature out of
>>> prettify-symbols-mode, so that more complex hiding could use it too
>>> (prettify-symbols-mode is fairly strict in its inputs).
>> 
>> How 'bout adding it to `reveal-mode`?

CP> Maybe ? But bonus points if each type of revealing can be turned on or off
CP> separately; maybe something like buffer-invisibility-spec? (I think currently
CP> you can disable revealing for some overlays, but not the other way around?
CP> basically I'd like my minor mode to be able to turn on revealing, but only for
CP> the overlays it created)

Any ideas here? This is still a feature worth having, I think. But
Clément and Stefan's comments have confused me so I don't know if it's
waiting for something and if there's a "right" way to do it?

Ted




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

* Re: Automatic minor modes?
  2018-10-08  1:05               ` Ted Zlatanov
@ 2018-10-08 14:57                 ` Stefan Monnier
  2018-10-09 19:44                   ` Ted Zlatanov
  0 siblings, 1 reply; 23+ messages in thread
From: Stefan Monnier @ 2018-10-08 14:57 UTC (permalink / raw)
  To: emacs-devel

> Any ideas here? This is still a feature worth having, I think. But
> Clément and Stefan's comments have confused me so I don't know if it's
> waiting for something and if there's a "right" way to do it?

IIUC there are many different right ways.


        Stefan




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

* Re: Automatic minor modes?
  2018-10-08 14:57                 ` Stefan Monnier
@ 2018-10-09 19:44                   ` Ted Zlatanov
  2018-10-14  3:59                     ` Ted Zlatanov
  0 siblings, 1 reply; 23+ messages in thread
From: Ted Zlatanov @ 2018-10-09 19:44 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Mon, 08 Oct 2018 10:57:23 -0400 Stefan Monnier <monnier@iro.umontreal.ca> wrote: 

>> Any ideas here? This is still a feature worth having, I think. But
>> Clément and Stefan's comments have confused me so I don't know if it's
>> waiting for something and if there's a "right" way to do it?

SM> IIUC there are many different right ways.

Stefan, can you recommend one? We all trust your expertise and you did a
lot of the work on prettify-symbols-mode that would apply here :)

Thanks
Ted



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

* Re: Automatic minor modes?
  2018-10-09 19:44                   ` Ted Zlatanov
@ 2018-10-14  3:59                     ` Ted Zlatanov
  2018-10-14 14:44                       ` Eli Zaretskii
  0 siblings, 1 reply; 23+ messages in thread
From: Ted Zlatanov @ 2018-10-14  3:59 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On Tue, 09 Oct 2018 19:44:05 +0000 Ted Zlatanov <tzz@lifelogs.com> wrote: 

TZ> On Mon, 08 Oct 2018 10:57:23 -0400 Stefan Monnier <monnier@iro.umontreal.ca> wrote: 
>>> Any ideas here? This is still a feature worth having, I think. But
>>> Clément and Stefan's comments have confused me so I don't know if it's
>>> waiting for something and if there's a "right" way to do it?

SM> IIUC there are many different right ways.

TZ> Stefan, can you recommend one? We all trust your expertise and you did a
TZ> lot of the work on prettify-symbols-mode that would apply here :)

I found several other threads about this, asking more or less the same
things "how to I use prettify-symbols-mode with strings/regexps"

https://emacs.stackexchange.com/questions/36572/prettify-symbols-mode-and-multi-character-replacements?noredirect=1&lq=1
https://emacs.stackexchange.com/questions/34808/using-prettify-symbols-with-strings-instead-of-characters?noredirect=1&lq=1

and "how do I hide secrets in Emacs"

https://www.reddit.com/r/emacs/comments/9ncypp/hide_copy_and_edit_secrets_in_gpg_encrypted_file/

The users are asking for this--it's not just us here. From my side, I
wanted to add support for it to JSON mode (for authinfo.json users) and
a netrc minor mode or something.

So... I looked at several things:

`reveal-mode`: the docs are simply unclear about how to use it:

;; Reveal mode is a minor mode that makes sure that text around point
;; is always visible.  When point enters a region of hidden text,
;; `reveal-mode' temporarily makes it visible.
...
;; It only works with packages that hide text using overlays.

...but no explanation of how to use it, practically, just references to
other packages which don't explain it either. It all seems custom-fitted
together in a way that's hard to reuse.

Then I looked at "(elisp) Replacing Specs" which let me to "(elisp)
Other Display Specs" and "(elisp) Overlay Properties" and... it was
not easy to follow when I just wanted to use reveal-mode. OK, I can make
overlays with special display properties... but how do I hook that with
font-lock and why do I have to know these details?

I then looked at the hideshow and outline modes, and they didn't have
generic functionality either, and it wasn't clear to me how to use them.

I looked at prettify-symbols-mode but extending it for strings and
regexps seems a bit inconsistent with how it was designed. I could hack
it probably.

Thus I was not able to make progress on this one. Maybe someone else
will, or be able to help me.

Ted



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

* Re: Automatic minor modes?
  2018-10-14  3:59                     ` Ted Zlatanov
@ 2018-10-14 14:44                       ` Eli Zaretskii
  2018-10-14 15:48                         ` Ted Zlatanov
  0 siblings, 1 reply; 23+ messages in thread
From: Eli Zaretskii @ 2018-10-14 14:44 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: monnier, emacs-devel

> From: Ted Zlatanov <tzz@lifelogs.com>
> Date: Sun, 14 Oct 2018 03:59:29 +0000
> Cc: emacs-devel@gnu.org
> 
> Thus I was not able to make progress on this one. Maybe someone else
> will, or be able to help me.

It is very hard to follow a discussion that is spread over several
months, and each month produces a about 3 messages.  I personally long
ago lost focus of the thread; in particular, I no longer remember what
prettify-symbols-mode and/or reveal-mode have to do with the subject
of this discussion.

So I think it would help if you summarize the issue, and then let's
try finishing this discussion in less than a month ;-)



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

* Re: Automatic minor modes?
  2018-10-14 14:44                       ` Eli Zaretskii
@ 2018-10-14 15:48                         ` Ted Zlatanov
  2018-10-14 16:05                           ` Eli Zaretskii
  2018-10-14 18:23                           ` Hiding passords in authinfo (was: Automatic minor modes?) Stefan Monnier
  0 siblings, 2 replies; 23+ messages in thread
From: Ted Zlatanov @ 2018-10-14 15:48 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: monnier, emacs-devel

On Sun, 14 Oct 2018 17:44:33 +0300 Eli Zaretskii <eliz@gnu.org> wrote: 

>> From: Ted Zlatanov <tzz@lifelogs.com>
>> Date: Sun, 14 Oct 2018 03:59:29 +0000
>> Cc: emacs-devel@gnu.org
>> 
>> Thus I was not able to make progress on this one. Maybe someone else
>> will, or be able to help me.

EZ> It is very hard to follow a discussion that is spread over several
EZ> months, and each month produces a about 3 messages.  I personally long
EZ> ago lost focus of the thread; in particular, I no longer remember what
EZ> prettify-symbols-mode and/or reveal-mode have to do with the subject
EZ> of this discussion.

I'll try to summarize. Sorry for the long lapses.

EZ> So I think it would help if you summarize the issue, and then let's
EZ> try finishing this discussion in less than a month ;-)

When I open a file such as authinfo.json.gpg, the passwords are clearly
visible to anyone that can see my screen. I'd like to hide them
visually. Ideally in a way that reveals them when I move inside them,
like `prettify-symbols-mode` does. Stefan suggested `reveal-mode` may be
the right place to do this work, so I investigated a little.

I think Lars was also interested in this, and I posted several URLs
where people are looking for more or less the same thing.

Ted



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

* Re: Automatic minor modes?
  2018-10-14 15:48                         ` Ted Zlatanov
@ 2018-10-14 16:05                           ` Eli Zaretskii
  2018-10-14 18:23                           ` Hiding passords in authinfo (was: Automatic minor modes?) Stefan Monnier
  1 sibling, 0 replies; 23+ messages in thread
From: Eli Zaretskii @ 2018-10-14 16:05 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: monnier, emacs-devel

> From: Ted Zlatanov <tzz@lifelogs.com>
> Cc: monnier@iro.umontreal.ca,  emacs-devel@gnu.org
> Date: Sun, 14 Oct 2018 15:48:22 +0000
> 
> When I open a file such as authinfo.json.gpg, the passwords are clearly
> visible to anyone that can see my screen. I'd like to hide them
> visually. Ideally in a way that reveals them when I move inside them,
> like `prettify-symbols-mode` does. Stefan suggested `reveal-mode` may be
> the right place to do this work, so I investigated a little.

OK, but what, if anything, does that have to do with "automatic minor
modes", something that sounds like a much more general subject?



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

* Hiding passords in authinfo (was: Automatic minor modes?)
  2018-10-14 15:48                         ` Ted Zlatanov
  2018-10-14 16:05                           ` Eli Zaretskii
@ 2018-10-14 18:23                           ` Stefan Monnier
  2018-10-14 19:31                             ` Hiding passords in authinfo Ted Zlatanov
  1 sibling, 1 reply; 23+ messages in thread
From: Stefan Monnier @ 2018-10-14 18:23 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> When I open a file such as authinfo.json.gpg, the passwords are clearly
> visible to anyone that can see my screen.  I'd like to hide them
> visually.

I'd recommend to do this via jit-lock-register.

> Ideally in a way that reveals them when I move inside them,
> like `prettify-symbols-mode` does. Stefan suggested `reveal-mode` may be
> the right place to do this work, so I investigated a little.

No, I suggested reveal-mode might be the right thing to use to do that
"reveal" part.  reveal-mode doesn't deal with hiding, only with revealing.


        Stefan



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

* Re: Hiding passords in authinfo
  2018-10-14 18:23                           ` Hiding passords in authinfo (was: Automatic minor modes?) Stefan Monnier
@ 2018-10-14 19:31                             ` Ted Zlatanov
  2018-10-14 20:55                               ` Stefan Monnier
  0 siblings, 1 reply; 23+ messages in thread
From: Ted Zlatanov @ 2018-10-14 19:31 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eli Zaretskii, emacs-devel

On Sun, 14 Oct 2018 14:23:57 -0400 Stefan Monnier <monnier@IRO.UMontreal.CA> wrote: 

>> When I open a file such as authinfo.json.gpg, the passwords are clearly
>> visible to anyone that can see my screen.  I'd like to hide them
>> visually.

SM> I'd recommend to do this via jit-lock-register.

OK, glasses.el seems to use it in a similar way to what I'm trying to do.

>> Ideally in a way that reveals them when I move inside them,
>> like `prettify-symbols-mode` does. Stefan suggested `reveal-mode` may be
>> the right place to do this work, so I investigated a little.

SM> No, I suggested reveal-mode might be the right thing to use to do that
SM> "reveal" part.  reveal-mode doesn't deal with hiding, only with revealing.

Right. I tried to find a standard way to do the hiding part, especially
one that would work with `reveal-mode`, and failed. Would doing it with
`jit-lock-register` work with `reveal-mode` automatically?

On Sun, 14 Oct 2018 19:05:40 +0300 Eli Zaretskii <eliz@gnu.org> wrote: 

EZ> OK, but what, if anything, does that have to do with "automatic minor
EZ> modes", something that sounds like a much more general subject?

I apologize for not changing the thread subject sooner. Stefan has done
that, fortunately.

Ted



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

* Re: Hiding passords in authinfo
  2018-10-14 19:31                             ` Hiding passords in authinfo Ted Zlatanov
@ 2018-10-14 20:55                               ` Stefan Monnier
  0 siblings, 0 replies; 23+ messages in thread
From: Stefan Monnier @ 2018-10-14 20:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

> Right. I tried to find a standard way to do the hiding part, especially
> one that would work with `reveal-mode`, and failed. Would doing it with
> `jit-lock-register` work with `reveal-mode` automatically?

reveal-mode doesn't care which mechanism you use to add the `invisible`
property, so doing it with jit-lock-register will neither help nor
hinder the use of reveal-mode.

The current constraint of reveal-mode is that it only works for text
hidden using the `invisible' property, and only if that property is
applied via an overlay.

It might very well be too restrictive for your use case (e.g. you might
prefer to hide the passwords by replacing them with ******* or something
like that, which requires the use of a `display` rather than
`invisible` property, and you might also prefer to use a text-property
rather than an overlay), but my suggestion was to extend reveal-mode to
be able to handle such cases.

You can see in reveal-open-new-overlays what tests are applied before
"opening" an overlay:

                  (and inv
                       ;; There's an `invisible' property.  Make sure it's
                       ;; actually invisible, and ellipsized.
                       (and (consp buffer-invisibility-spec)
                            (cdr (assq inv buffer-invisibility-spec)))
                       (or (setq open
                                 (or (overlay-get ol 'reveal-toggle-invisible)
                                     (and (symbolp inv)
                                          (get inv 'reveal-toggle-invisible))
                                     (overlay-get ol 'isearch-open-invisible-temporary)))
                           (overlay-get ol 'isearch-open-invisible)
                           (and (consp buffer-invisibility-spec)
                                (cdr (assq inv buffer-invisibility-spec))))
                       (overlay-put ol 'reveal-invisible inv))

It could test for the presence of the `display` property (and maybe
check for the presence of a reveal-specific property like
reveal-toggle-invisible above, so that it doesn't reveal any and all
`display` properties but only those that were designed to be revealed).


        Stefan



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

end of thread, other threads:[~2018-10-14 20:55 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-14 14:56 Automatic minor modes? Lars Ingebrigtsen
2018-04-14 11:49 ` Charles A. Roelli
2018-04-14 18:59   ` Lars Ingebrigtsen
2018-04-14 15:23 ` Yuri Khan
2018-04-14 15:27   ` Lars Ingebrigtsen
2018-06-27  1:31     ` Ted Zlatanov
2018-07-22 12:26       ` Lars Ingebrigtsen
2018-07-22 15:51         ` Clément Pit-Claudel
2018-07-22 19:01           ` Stefan Monnier
2018-07-22 20:06             ` Clément Pit-Claudel
2018-10-08  1:05               ` Ted Zlatanov
2018-10-08 14:57                 ` Stefan Monnier
2018-10-09 19:44                   ` Ted Zlatanov
2018-10-14  3:59                     ` Ted Zlatanov
2018-10-14 14:44                       ` Eli Zaretskii
2018-10-14 15:48                         ` Ted Zlatanov
2018-10-14 16:05                           ` Eli Zaretskii
2018-10-14 18:23                           ` Hiding passords in authinfo (was: Automatic minor modes?) Stefan Monnier
2018-10-14 19:31                             ` Hiding passords in authinfo Ted Zlatanov
2018-10-14 20:55                               ` Stefan Monnier
2018-04-14 15:39 ` Automatic minor modes? Clément Pit-Claudel
2018-04-14 15:45   ` Lars Ingebrigtsen
2018-04-14 16:40     ` Clément Pit-Claudel

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