unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#4118: 23.1; eval-last-sexp-print-value is inconvenient
@ 2009-08-11 10:55 Eli Barzilay
  2009-08-12 20:57 ` Juri Linkov
  2016-06-15  0:35 ` Noam Postavsky
  0 siblings, 2 replies; 12+ messages in thread
From: Eli Barzilay @ 2009-08-11 10:55 UTC (permalink / raw)
  To: bug-gnu-emacs

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:


  `eval-last-sexp' is often useful with a prefix argument inside a
  buffer for all kinds of programmatic uses (for example, make a
  keyboard macro that massages some text into an S-expression, then
  use it to plant the result in the buffer).  This uses
  `eval-last-sexp-print-value', which will "helpfully" insert other
  junk into the buffer (the hex and the octal representations of the
  number).  This is cute to have on the echo area, but annoying for
  such use in macros.  It would be better to disable this extra output
  in the case of non-echo-area output.

  I have a rather simple solution -- redefine the
  `eval-last-sexp-print-value' function with an extra condition

      (let ((str (and (eq standard-output t) ; <--- HERE
                      (eval-expression-print-format value))))
	(if str (princ str)))

  which works reasonably well.



In GNU Emacs 23.1.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.10.14)
 of 2009-08-01 on winooski.ccs.neu.edu
Windowing system distributor `The X.Org Foundation', version 11.0.10300000
configured using `configure  '--prefix=/home/eli/bin/local/emacs-dir''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: POSIX
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US
  value of $XMODIFIERS: nil
  locale-coding-system: iso-latin-1-unix
  default-enable-multibyte-characters: t

Major mode: Text

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-x r e p o <tab> r <tab> <return>

Recent messages:
Loading ~/MyEmacs/pre...done
Loading ~/EliEmacs/eliemacs...done
Loading ~/MyEmacs/post...done
Making completion list...






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

* bug#4118: 23.1; eval-last-sexp-print-value is inconvenient
  2009-08-11 10:55 bug#4118: 23.1; eval-last-sexp-print-value is inconvenient Eli Barzilay
@ 2009-08-12 20:57 ` Juri Linkov
  2009-08-13  1:18   ` Eli Barzilay
  2016-06-15  0:35 ` Noam Postavsky
  1 sibling, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2009-08-12 20:57 UTC (permalink / raw)
  To: Eli Barzilay; +Cc: bug-gnu-emacs, 4118

>   `eval-last-sexp' is often useful with a prefix argument inside a
>   buffer for all kinds of programmatic uses (for example, make a
>   keyboard macro that massages some text into an S-expression, then
>   use it to plant the result in the buffer).  This uses
>   `eval-last-sexp-print-value', which will "helpfully" insert other
>   junk into the buffer (the hex and the octal representations of the
>   number).

But it inserts other representations only when you type `C-x C-e' twice.
Do you mean you don't want this after the second `C-x C-e' key press?

>   This is cute to have on the echo area, but annoying for
>   such use in macros.  It would be better to disable this extra output
>   in the case of non-echo-area output.

Sometimes I use `C-x C-e C-u C-x C-e' to insert other representations
to the current buffer to be able to copy their values as text.  Of course,
it's possible to copy them from the *Messages* buffer, but this is
less convenient.

-- 
Juri Linkov
http://www.jurta.org/emacs/





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

* bug#4118: 23.1; eval-last-sexp-print-value is inconvenient
  2009-08-12 20:57 ` Juri Linkov
@ 2009-08-13  1:18   ` Eli Barzilay
  2009-08-13 23:33     ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Barzilay @ 2009-08-13  1:18 UTC (permalink / raw)
  To: Juri Linkov; +Cc: bug-gnu-emacs, 4118

On Aug 12, Juri Linkov wrote:
> >   `eval-last-sexp' is often useful with a prefix argument inside a
> >   buffer for all kinds of programmatic uses (for example, make a
> >   keyboard macro that massages some text into an S-expression,
> >   then use it to plant the result in the buffer).  This uses
> >   `eval-last-sexp-print-value', which will "helpfully" insert
> >   other junk into the buffer (the hex and the octal
> >   representations of the number).
> 
> But it inserts other representations only when you type `C-x C-e' twice.
> Do you mean you don't want this after the second `C-x C-e' key press?

Hmm, I see that the reason for what I've seen is that I'm using it
indirectly through my own function, and for some reason
`eval-expression-print-format' decides whether to do its thing based
on the current command.  This looks like an odd interface...  A better
and more consistent interface seems to me to always print the extra
information unless it goes into a buffer -- something like:

  (defun eval-expression-print-format (value)
    ...
    (if (and (integerp value) (not (bufferp standard-output)))
        ...))

But you seem to suggest that there are practical uses to get that
extra stuff into the buffer?  I don't see any occasion that would make
it desirable...

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!






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

* bug#4118: 23.1; eval-last-sexp-print-value is inconvenient
  2009-08-13  1:18   ` Eli Barzilay
@ 2009-08-13 23:33     ` Juri Linkov
  2009-08-14  1:25       ` Eli Barzilay
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2009-08-13 23:33 UTC (permalink / raw)
  To: Eli Barzilay; +Cc: 4118

>> But it inserts other representations only when you type `C-x C-e' twice.
>> Do you mean you don't want this after the second `C-x C-e' key press?
>
> Hmm, I see that the reason for what I've seen is that I'm using it
> indirectly through my own function, and for some reason
> `eval-expression-print-format' decides whether to do its thing based
> on the current command.  This looks like an odd interface...  A better
> and more consistent interface seems to me to always print the extra
> information unless it goes into a buffer -- something like:
>
>   (defun eval-expression-print-format (value)
>     ...
>     (if (and (integerp value) (not (bufferp standard-output)))
>         ...))

The reason not to print the extra information on the first invocation of
`eval-last-sexp' is the following.  Most often users want to see the integer
result of the evaluated expression, but the extra information also contains
a character representation of this integer that might print some unrelated
character that might load some weird fonts the user doesn't want to load.

> But you seem to suggest that there are practical uses to get that
> extra stuff into the buffer?  I don't see any occasion that would make
> it desirable...

When the current buffer contains an integer, typing `C-x C-e' twice
inserts it to the same buffer as a character.  However, this is
not too convenient, so I'd like to improve this interface.

-- 
Juri Linkov
http://www.jurta.org/emacs/





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

* bug#4118: 23.1; eval-last-sexp-print-value is inconvenient
  2009-08-13 23:33     ` Juri Linkov
@ 2009-08-14  1:25       ` Eli Barzilay
  2009-08-14 22:54         ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Barzilay @ 2009-08-14  1:25 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 4118

On Aug 14, Juri Linkov wrote:
> >> But it inserts other representations only when you type `C-x C-e' twice.
> >> Do you mean you don't want this after the second `C-x C-e' key press?
> >
> > Hmm, I see that the reason for what I've seen is that I'm using it
> > indirectly through my own function, and for some reason
> > `eval-expression-print-format' decides whether to do its thing based
> > on the current command.  This looks like an odd interface...  A better
> > and more consistent interface seems to me to always print the extra
> > information unless it goes into a buffer -- something like:
> >
> >   (defun eval-expression-print-format (value)
> >     ...
> >     (if (and (integerp value) (not (bufferp standard-output)))
> >         ...))
> 
> The reason not to print the extra information on the first
> invocation of `eval-last-sexp' is the following.  Most often users
> want to see the integer result of the evaluated expression, but the
> extra information also contains a character representation of this
> integer that might print some unrelated character that might load
> some weird fonts the user doesn't want to load.

In that case the obvious way to do this is to not print the character
form if it requires such a font.  If this is not easy to do, then
making it work only for ASCII seems better than the current weird
behavior.  (The reason I consider it weird is that I managed to use
Emacs for more than 15 years without noticing it.)


> > But you seem to suggest that there are practical uses to get that
> > extra stuff into the buffer?  I don't see any occasion that would
> > make it desirable...
> 
> When the current buffer contains an integer, typing `C-x C-e' twice
> inserts it to the same buffer as a character.  However, this is not
> too convenient, so I'd like to improve this interface.

The main point (IMO) of making it consistent is keyboard macros, and
in that case, if you want the character, then it's easy to just wrap
an (insert ...) around the expression.  Using it to insert the
character and then removing all the preceding text is much more
difficult for that.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!





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

* bug#4118: 23.1; eval-last-sexp-print-value is inconvenient
  2009-08-14  1:25       ` Eli Barzilay
@ 2009-08-14 22:54         ` Juri Linkov
  2009-08-15  1:38           ` Eli Barzilay
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2009-08-14 22:54 UTC (permalink / raw)
  To: Eli Barzilay; +Cc: 4118

>> The reason not to print the extra information on the first
>> invocation of `eval-last-sexp' is the following.  Most often users
>> want to see the integer result of the evaluated expression, but the
>> extra information also contains a character representation of this
>> integer that might print some unrelated character that might load
>> some weird fonts the user doesn't want to load.
>
> In that case the obvious way to do this is to not print the character
> form if it requires such a font.  If this is not easy to do, then
> making it work only for ASCII seems better than the current weird
> behavior.  (The reason I consider it weird is that I managed to use
> Emacs for more than 15 years without noticing it.)

There is no way to guess whether the user want to see the character
(however weird it is) or not.

> The main point (IMO) of making it consistent is keyboard macros, and
> in that case, if you want the character, then it's easy to just wrap
> an (insert ...) around the expression.  Using it to insert the
> character and then removing all the preceding text is much more
> difficult for that.

Wrapping an (insert ...) around the expression is not as easy as typing
`C-u C-x C-e', copying the character and undoing the change with C-/.

-- 
Juri Linkov
http://www.jurta.org/emacs/





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

* bug#4118: 23.1; eval-last-sexp-print-value is inconvenient
  2009-08-14 22:54         ` Juri Linkov
@ 2009-08-15  1:38           ` Eli Barzilay
  2009-08-15 23:16             ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Barzilay @ 2009-08-15  1:38 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 4118

On Aug 15, Juri Linkov wrote:
> >> The reason not to print the extra information on the first
> >> invocation of `eval-last-sexp' is the following.  Most often users
> >> want to see the integer result of the evaluated expression, but the
> >> extra information also contains a character representation of this
> >> integer that might print some unrelated character that might load
> >> some weird fonts the user doesn't want to load.
> >
> > In that case the obvious way to do this is to not print the
> > character form if it requires such a font.  If this is not easy to
> > do, then making it work only for ASCII seems better than the
> > current weird behavior.  (The reason I consider it weird is that I
> > managed to use Emacs for more than 15 years without noticing it.)
> 
> There is no way to guess whether the user want to see the character
> (however weird it is) or not.

The weird thing is not showing the character -- it is the fact that
the extra information is "sometimes there" -- it is the fact that the
behavior depends on whether the command was issued two times in a row.


> > The main point (IMO) of making it consistent is keyboard macros,
> > and in that case, if you want the character, then it's easy to
> > just wrap an (insert ...) around the expression.  Using it to
> > insert the character and then removing all the preceding text is
> > much more difficult for that.
> 
> Wrapping an (insert ...) around the expression is not as easy as
> typing `C-u C-x C-e', copying the character and undoing the change
> with C-/.

...and this is a good description for a solution: have it print out
the extra information only on something like an explicit positive
prefix argument (eg, C-u C-1 C-x C-e), and otherwise don't show it.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!





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

* bug#4118: 23.1; eval-last-sexp-print-value is inconvenient
  2009-08-15  1:38           ` Eli Barzilay
@ 2009-08-15 23:16             ` Juri Linkov
  2009-08-16  0:00               ` Eli Barzilay
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2009-08-15 23:16 UTC (permalink / raw)
  To: Eli Barzilay; +Cc: 4118

>> Wrapping an (insert ...) around the expression is not as easy as
>> typing `C-u C-x C-e', copying the character and undoing the change
>> with C-/.
>
> ...and this is a good description for a solution: have it print out
> the extra information only on something like an explicit positive
> prefix argument (eg, C-u C-1 C-x C-e), and otherwise don't show it.

And then the number could mean the verbosity level, e.g. `C-1 C-x C-e'
prints octal and hex, and `C-2 C-x C-e' prints octal, hex and a character.

But I don't see how to insert different representations to the current
buffer instead of displaying them in the echo area since `C-u C-1 C-x C-e'
and `C-1 C-x C-e' have the same numeric argument `1'.

-- 
Juri Linkov
http://www.jurta.org/emacs/





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

* bug#4118: 23.1; eval-last-sexp-print-value is inconvenient
  2009-08-15 23:16             ` Juri Linkov
@ 2009-08-16  0:00               ` Eli Barzilay
  2009-08-17  0:52                 ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Barzilay @ 2009-08-16  0:00 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 4118

On Aug 16, Juri Linkov wrote:
> >> Wrapping an (insert ...) around the expression is not as easy as
> >> typing `C-u C-x C-e', copying the character and undoing the change
> >> with C-/.
> >
> > ...and this is a good description for a solution: have it print out
> > the extra information only on something like an explicit positive
> > prefix argument (eg, C-u C-1 C-x C-e), and otherwise don't show it.
> 
> And then the number could mean the verbosity level, e.g. `C-1 C-x
> C-e' prints octal and hex, and `C-2 C-x C-e' prints octal, hex and a
> character.

Cute idea,

> But I don't see how to insert different representations to the
> current buffer instead of displaying them in the echo area since
> `C-u C-1 C-x C-e' and `C-1 C-x C-e' have the same numeric argument
> `1'.

but yes, that won't work as is.  It could work as a verbosity level
indicator for insertion into the buffer, and echo-area messages could
still do the different output based on the number of times it was
called.  The echo area messages won't be consistent but that's not as
important.  And negative prefixes could be used for those rare cases
where you want the verbose output into the echo area.  Something like
this:

  A prefix of
    1 (or just C-u) -> output a plain number into the buffer
    2 -> number + alternative radix outputs into the buffer
    3 -> number + alternates + character into the buffer
    -1, -2, -3 -> same as above, but for the echo area
  And the above always behaves the same.

  *No* prefix means:
    show the plain number output in the echo area on first use
    number + alternates on second use (with no prefix, of course)
    number + alternates + character on the third use.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!





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

* bug#4118: 23.1; eval-last-sexp-print-value is inconvenient
  2009-08-16  0:00               ` Eli Barzilay
@ 2009-08-17  0:52                 ` Juri Linkov
  2009-08-17  3:18                   ` Eli Barzilay
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2009-08-17  0:52 UTC (permalink / raw)
  To: Eli Barzilay; +Cc: 4118

>   A prefix of
>     1 (or just C-u) -> output a plain number into the buffer
>     2 -> number + alternative radix outputs into the buffer
>     3 -> number + alternates + character into the buffer
>     -1, -2, -3 -> same as above, but for the echo area
>   And the above always behaves the same.
>
>   *No* prefix means:
>     show the plain number output in the echo area on first use
>     number + alternates on second use (with no prefix, of course)
>     number + alternates + character on the third use.

Then maybe the same scheme should be applied to `eval-expression'
(`M-:') as well.

-- 
Juri Linkov
http://www.jurta.org/emacs/





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

* bug#4118: 23.1; eval-last-sexp-print-value is inconvenient
  2009-08-17  0:52                 ` Juri Linkov
@ 2009-08-17  3:18                   ` Eli Barzilay
  0 siblings, 0 replies; 12+ messages in thread
From: Eli Barzilay @ 2009-08-17  3:18 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 4118

On Aug 17, Juri Linkov wrote:
> >   A prefix of
> >     1 (or just C-u) -> output a plain number into the buffer
> >     2 -> number + alternative radix outputs into the buffer
> >     3 -> number + alternates + character into the buffer
> >     -1, -2, -3 -> same as above, but for the echo area
> >   And the above always behaves the same.
> >
> >   *No* prefix means:
> >     show the plain number output in the echo area on first use
> >     number + alternates on second use (with no prefix, of course)
> >     number + alternates + character on the third use.
> 
> Then maybe the same scheme should be applied to `eval-expression'
> (`M-:') as well.

Yes, that sounds good to me.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!





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

* bug#4118: 23.1; eval-last-sexp-print-value is inconvenient
  2009-08-11 10:55 bug#4118: 23.1; eval-last-sexp-print-value is inconvenient Eli Barzilay
  2009-08-12 20:57 ` Juri Linkov
@ 2016-06-15  0:35 ` Noam Postavsky
  1 sibling, 0 replies; 12+ messages in thread
From: Noam Postavsky @ 2016-06-15  0:35 UTC (permalink / raw)
  To: 4118-done

Version: 24.4

This was fixed along with #12985 by b41594fd (Thu Dec 19 23:02:46 2013 +0200)

"* lisp/simple.el (eval-expression-print-format): Don't check for
command names and the last command.  Always display additional
formats of the integer result in the echo area, and insert them
to the current buffer only with a zero prefix arg.
Display character when char-displayable-p is non-nil.
(eval-expression): With a zero prefix arg, set `print-length' and
`print-level' to nil, and insert the integer values from
`eval-expression-print-format' at the end.  Doc fix.
[...]"





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

end of thread, other threads:[~2016-06-15  0:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-11 10:55 bug#4118: 23.1; eval-last-sexp-print-value is inconvenient Eli Barzilay
2009-08-12 20:57 ` Juri Linkov
2009-08-13  1:18   ` Eli Barzilay
2009-08-13 23:33     ` Juri Linkov
2009-08-14  1:25       ` Eli Barzilay
2009-08-14 22:54         ` Juri Linkov
2009-08-15  1:38           ` Eli Barzilay
2009-08-15 23:16             ` Juri Linkov
2009-08-16  0:00               ` Eli Barzilay
2009-08-17  0:52                 ` Juri Linkov
2009-08-17  3:18                   ` Eli Barzilay
2016-06-15  0:35 ` Noam Postavsky

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