bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#46092: [External] : bug#53507: 27.1; syntax highlight in the eval-ex


From: Drew Adams
Subject: bug#46092: [External] : bug#53507: 27.1; syntax highlight in the eval-expression prompt
Date: Wed, 26 Jan 2022 19:53:33 +0000

> So then I guess it's only a matter of merging the minibuffer
> keymap with emacs lisp mode map in the eval-expression prompt.

FWIW -

I know that this enhancement request is about having 
Lisp font-locking while typing a sexp to evaluate.

My remarks are only partly related, I guess, and are
offered as food for thought.

1. Font-locking a sexp you're typing isn't very
   important.

   Not saying it can't or shouldn't happen.  But
   compared to font-locking the _resulting value_,
   it's really not so important, IMHO.

2. Turning on `emacs-lisp-mode' for reading the sexp
   is overkill.  Unless you prevent it, it entails
   running the mode hook, which can do all kinds of
   things and might take a while.  It's likely to be
   problematic.

3. Although in principle it's only orthogonal, what
   I'd propose is to concentrate on the _result_
   sexp, instead of the input sexp to evaluate.

___

This is what I do, for #3.  I think it, or similar,
makes sense also for vanilla Emacs:

1. Bind `M-:' to `pp-eval-expression', not to
   `eval-expression'.  This means you can get the
   output in the echo area or a separate buffer,
   and that buffer can be better Lisp-enabled:
   font-lock, undo, `emacs-lisp-mode'.

2. Optionally show the result in a tooltip.
   Provide a user option, but commands can flip
   the behavior on the fly (with a prefix arg).

3. `pp-display-expression':

   * When result is shown in a buffer: Put
     buffer in `emacs-lisp-mode', with undo
     and font-locked. 
   * But use NO `emacs-lisp-mode-hook' or
     `change-major-mode-hook'.

   `pp-eval-expression':

   * Read the input sexp with completion.
     Completion uses a PP+ keymap, which is like
     `read-expression-map' but with some Elisp
     key bindings.
   * By default, use `pp-display-expression'.
     But with non-zero prefix arg insert result
     into current buffer, with or without
     double-quotes if result is a string (prefix
     arg < 0 means without).
   * Respect pp versions of print options:
     `pp-eval-expression-print-length',
     `pp-eval-expression-print-level', and
     `pp-max-tooltip-size'.  (No reason to
     force the same behavior for pretty-printing
     as for nonpretty-printing.)
   * Respect `eval-expression-debug-on-error'.
   * Return result of evaluation (as well as
     having it as car variable `values').

The code for pp+.el is here:

https://www.emacswiki.org/emacs/download/pp%2b.el

reply via email to

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