emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: questions about correct reveal-mode usage to hide passwords


From: Ted Zlatanov
Subject: Re: questions about correct reveal-mode usage to hide passwords
Date: Tue, 16 Jun 2020 18:09:48 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

On Fri, 12 Jun 2020 16:17:25 +0000 Ted Zlatanov <tzz@lifelogs.com> wrote: 

TZ> I spent a few hours in that direction, but prettify-symbols-mode was
TZ> just too easy to extend... I've pushed my proposed patch to
TZ> scratch/tzz/auth-source-reveal-mode as follows:

TZ> * allow regexps in prettify-symbols-alist using a new extended format. I
TZ>   wasn't sure here if I should go with the current format, and the
TZ>   replacement lookup does extra string-match calls, so it's not ideal.
TZ>   This specific extension was requested fairly often, looking back at
TZ>   the last few years on various Emacs forums.

I extended the new format to allow any symbol as an identifier, and
speed up lookups based on the identifier. Each fixed entry is still
collected in one big optimized regexp by
prettify-symbols--make-fixed-matcher, and there is no identifier (we
just do a fast assoc as before). But in addition, each regexp entry in
prettify-symbols-alist now gets processed by
prettify-symbols--make-regexp-keywords, with the identifier propagated
down the call chain. I think this is fairly clean.

TZ> * define a new local variable prettify-symbols-compose-replacer for the
TZ>   function that looks up and replaces the symbol

TZ> * create the new auth-source-reveal-mode that behaves as proposed, both
TZ>   in JSON and in netrc/authinfo buffers. It warns if
TZ>   prettify-symbols-unprettify-at-point is nil, since I think the
TZ>   experience is much less pleasant without it. It doesn't check syntax
TZ>   as carefully as prettify-symbols-mode.

TZ> * document the composition layout format enough that users can customize
TZ>   auth-source-reveal-hider to show a fancy string instead of a single
TZ>   character. I think this will appeal to prettify-symbols-mode users in
TZ>   general, since I have seen quite a few hacks for it in various Emacs
TZ>   forums and even a helper library 
https://github.com/Ilazki/prettify-utils.el/blob/master/prettify-utils.el

TZ> * the new code in auth-source.el and prog-mode.el is much less than the
TZ>   other approaches I tried, and much much less confusing. I like that :)

Following Clément's suggestion, I started on the library path by
creating some new functions to install and remove prettifications.
Coupled with the new identifier symbols and regexps, I think this covers
all the use cases for touching or bypassing prettify-symbols-alist I've
seen.

prettify-symbols-add-prettification-entry
  "Add ENTRY to `prettify-symbols-alist' for the current buffer.
prettify-symbols-add-prettification-rx
  "Convenience wrapper of `prettify-symbols-add-prettification-entry' to 
prettify REGEXP with REPLACEMENT."
prettify-symbols-add-prettification-string
  "Convenience wrapper of `prettify-symbols-add-prettification-entry' to 
prettify FIXED-STRING with REPLACEMENT."
prettify-symbols-remove-prettification
  "Remove ENTRY to `prettify-symbols-alist' for the current buffer.
prettify-symbols-remove-prettifications
  "Remove all IDENTIFIER entries from `prettify-symbols-alist' for the current 
buffer.

TZ> Let me know if you have strong objections or any suggestions, otherwise
TZ> in a day or two I'll document and push this patch.

I haven't heard from Stefan, so I'm still holding off merging and would
appreciate feedback.

Ted



reply via email to

[Prev in Thread] Current Thread [Next in Thread]