unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29763: New Feature: Remove unneeded eval-expression in minibuffer-history
@ 2017-12-18  4:13 Robert Weiner
  2017-12-18 15:46 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Robert Weiner @ 2017-12-18  4:13 UTC (permalink / raw)
  To: 29763


[-- Attachment #1.1: Type: text/plain, Size: 816 bytes --]

For as long as I can remember, I have wanted the minibuffer history to
strip the eval-expression wrapper around expressions that I enter by
invoking eval-expression with M-:.  I want this because the wrapper
adds a lot of visual noise when searching for a specific expression and
makes it much harder to edit the expression and get trailing parentheses
right.

So if I enter:

  M-: (/ 1.0 9) RET

then C-x ESC ESC shows me:

  (eval-expression (quote (/ 1.0 9)) nil nil 127)

but I want to see just the expression that I want to reuse or edit:

  (/ 1.0 9)

This small patch against Emacs 27.0.50  gives me that; it does the same
removal for commands already in the history if you load the change in
the middle of an Emacs session.  Please consider adding it to Emacs; it is
already improving my productivity.

Bob

[-- Attachment #1.2: Type: text/html, Size: 2605 bytes --]

[-- Attachment #2: simple.el.patch --]
[-- Type: application/octet-stream, Size: 1616 bytes --]

*** simple-orig.el.gz	2017-12-17 22:54:50.000000000 -0500
--- simple.el.gz	2017-12-17 22:54:50.000000000 -0500
***************
*** 1563,1572 ****
--- 1563,1580 ----
                          (eval-expression-print-format (car values)))))
            (when str (princ str out)))))))
  
+ (defun minibuffer-history-edit-element (elt)
+   "Automatically simplify ELT if possible, e.g. removing eval-expression."
+   (or (and (consp elt) (eq (car elt) 'eval-expression)
+ 	   ;; Remove eval-expression wrapper and leave just the expression.
+ 	   (cadadr elt))
+       elt))
+ 
  (defun edit-and-eval-command (prompt command)
    "Prompting with PROMPT, let user edit COMMAND and eval result.
  COMMAND is a Lisp expression.  Let user edit that expression in
  the minibuffer, then read and evaluate the result."
+   (setq command (minibuffer-history-edit-element command))
    (let ((command
  	 (let ((print-level nil)
  	       (minibuffer-history-sexp-flag (1+ (minibuffer-depth))))
***************
*** 1601,1606 ****
--- 1609,1615 ----
  	newcmd)
      (if elt
  	(progn
+ 	  (setq elt (minibuffer-history-edit-element elt))
  	  (setq newcmd
  		(let ((print-level nil)
  		      (minibuffer-history-position arg)
***************
*** 2070,2075 ****
--- 2079,2085 ----
  	   (setq minibuffer-text-before-history nil))
  	  (t (setq elt (nth (1- minibuffer-history-position)
  			    (symbol-value minibuffer-history-variable)))))
+     (setq elt (minibuffer-history-edit-element elt))
      (insert
       (if (and (eq minibuffer-history-sexp-flag (minibuffer-depth))
  	      (not minibuffer-returned-to-present))

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

end of thread, other threads:[~2019-06-27  2:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-18  4:13 bug#29763: New Feature: Remove unneeded eval-expression in minibuffer-history Robert Weiner
2017-12-18 15:46 ` Eli Zaretskii
2017-12-18 23:04   ` Robert Weiner
2017-12-22 10:28     ` Eli Zaretskii
2019-06-24 20:25       ` Lars Ingebrigtsen
2019-06-27  2:29         ` Robert Weiner
2017-12-22 12:16 ` Tomas Nordin
2017-12-22 12:58 ` Andreas Schwab
2017-12-22 14:21   ` Robert Weiner

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