all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Robert Weiner <rsw@gnu.org>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: 29763@debbugs.gnu.org
Subject: bug#29763: New Feature: Remove unneeded eval-expression in minibuffer-history
Date: Fri, 22 Dec 2017 09:21:38 -0500	[thread overview]
Message-ID: <CA+OMD9gTxnMfo8iWX7O12rURy5BgASBYMybzC4O2i=cKon_JTA@mail.gmail.com> (raw)
In-Reply-To: <878tdu9awm.fsf@linux-m68k.org>


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

On Fri, Dec 22, 2017 at 7:58 AM, Andreas Schwab <schwab@linux-m68k.org>
wrote:

> On Dez 17 2017, Robert Weiner <rsw@gnu.org> wrote:
>
> > + (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))
>
> That mishandles self-evaluating expressions, they are not wrapped with
> quote.
>

​You are correct.  This version resolves that issue and changes
repeat-complex-command to use eval-expression instead of
funcall-interactively to handle expressions rather than function
calls, including properly redoing:

   (quote emacs-version)

for example.

See attached.

Bob

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

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

*** simple-orig.el.gz	2017-12-22 09:15:29.000000000 -0500
--- simple.el.gz	2017-12-22 09:15:29.000000000 -0500
***************
*** 1563,1572 ****
--- 1563,1581 ----
                          (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."
+     (when (and (consp elt) (eq (car elt) 'eval-expression))
+       (setq elt (cadr elt))
+       (when (and (consp elt) (eq (car elt) 'quote))
+ 	(setq elt (cadr 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 ****
--- 1610,1616 ----
  	newcmd)
      (if elt
  	(progn
+ 	  (setq elt (minibuffer-history-edit-element elt))
  	  (setq newcmd
  		(let ((print-level nil)
  		      (minibuffer-history-position arg)
***************
*** 1620,1628 ****
  	  ;; add it to the history.
  	  (or (equal newcmd (car command-history))
  	      (setq command-history (cons newcmd command-history)))
!           (apply #'funcall-interactively
! 		 (car newcmd)
! 		 (mapcar (lambda (e) (eval e t)) (cdr newcmd))))
        (if command-history
  	  (error "Argument %d is beyond length of command history" arg)
  	(error "There are no previous complex commands to repeat")))))
--- 1630,1636 ----
  	  ;; add it to the history.
  	  (or (equal newcmd (car command-history))
  	      (setq command-history (cons newcmd command-history)))
! 	  (eval-expression newcmd))
        (if command-history
  	  (error "Argument %d is beyond length of command history" arg)
  	(error "There are no previous complex commands to repeat")))))
***************
*** 2070,2075 ****
--- 2078,2084 ----
  	   (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))

      reply	other threads:[~2017-12-22 14:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

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

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

  git send-email \
    --in-reply-to='CA+OMD9gTxnMfo8iWX7O12rURy5BgASBYMybzC4O2i=cKon_JTA@mail.gmail.com' \
    --to=rsw@gnu.org \
    --cc=29763@debbugs.gnu.org \
    --cc=rswgnu@gmail.com \
    --cc=schwab@linux-m68k.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.