unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: "Stefan Monnier" <monnier@iro.umontreal.ca>,
	"Clément Pit-Claudel" <cpitclaudel@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: questions about correct reveal-mode usage to hide passwords
Date: Tue, 16 Jun 2020 18:09:48 +0000	[thread overview]
Message-ID: <7dw6naqb.fsf@lifelogs.com> (raw)
In-Reply-To: <4krg9s2y.fsf@lifelogs.com> (Ted Zlatanov's message of "Fri, 12 Jun 2020 16:17:25 +0000")

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



  parent reply	other threads:[~2020-06-16 18:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-11 14:09 questions about correct reveal-mode usage to hide passwords Ted Zlatanov
2020-06-11 14:21 ` Clément Pit-Claudel
2020-06-11 17:33   ` Stefan Monnier
2020-06-11 17:43     ` Clément Pit-Claudel
2020-06-11 17:49       ` Stefan Monnier
2020-06-11 18:31         ` Ted Zlatanov
2020-06-11 19:51           ` Stefan Monnier
2020-06-12 16:17             ` Ted Zlatanov
2020-06-12 16:35               ` Clément Pit-Claudel
2020-06-12 17:08                 ` Ted Zlatanov
2020-06-16 18:09               ` Ted Zlatanov [this message]
2020-06-18 18:38                 ` Ted Zlatanov

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=7dw6naqb.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=cpitclaudel@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 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).