Mercurial > emacs
comparison lisp/simple.el @ 47599:1362c8e5d501
(edit-and-eval-command): Protect command-history.
(repeat-complex-command): Protect command-history.
author | Markus Rost <rost@math.uni-bielefeld.de> |
---|---|
date | Tue, 24 Sep 2002 18:39:48 +0000 |
parents | b8282a873821 |
children | d3416b0f856c |
comparison
equal
deleted
inserted
replaced
47598:0025c3f82558 | 47599:1362c8e5d501 |
---|---|
648 | 648 |
649 (defun edit-and-eval-command (prompt command) | 649 (defun edit-and-eval-command (prompt command) |
650 "Prompting with PROMPT, let user edit COMMAND and eval result. | 650 "Prompting with PROMPT, let user edit COMMAND and eval result. |
651 COMMAND is a Lisp expression. Let user edit that expression in | 651 COMMAND is a Lisp expression. Let user edit that expression in |
652 the minibuffer, then read and evaluate the result." | 652 the minibuffer, then read and evaluate the result." |
653 (let ((command (read-from-minibuffer prompt | 653 (let ((command |
654 (prin1-to-string command) | 654 (unwind-protect |
655 read-expression-map t | 655 (read-from-minibuffer prompt |
656 '(command-history . 1)))) | 656 (prin1-to-string command) |
657 ;; If command was added to command-history as a string, | 657 read-expression-map t |
658 ;; get rid of that. We want only evaluable expressions there. | 658 '(command-history . 1)) |
659 (if (stringp (car command-history)) | 659 ;; If command was added to command-history as a string, |
660 (setq command-history (cdr command-history))) | 660 ;; get rid of that. We want only evaluable expressions there. |
661 (if (stringp (car command-history)) | |
662 (setq command-history (cdr command-history)))))) | |
661 | 663 |
662 ;; If command to be redone does not match front of history, | 664 ;; If command to be redone does not match front of history, |
663 ;; add it to the history. | 665 ;; add it to the history. |
664 (or (equal command (car command-history)) | 666 (or (equal command (car command-history)) |
665 (setq command-history (cons command command-history))) | 667 (setq command-history (cons command command-history))) |
681 (progn | 683 (progn |
682 (setq newcmd | 684 (setq newcmd |
683 (let ((print-level nil) | 685 (let ((print-level nil) |
684 (minibuffer-history-position arg) | 686 (minibuffer-history-position arg) |
685 (minibuffer-history-sexp-flag (1+ (minibuffer-depth)))) | 687 (minibuffer-history-sexp-flag (1+ (minibuffer-depth)))) |
686 (read-from-minibuffer | 688 (unwind-protect |
687 "Redo: " (prin1-to-string elt) read-expression-map t | 689 (read-from-minibuffer |
688 (cons 'command-history arg)))) | 690 "Redo: " (prin1-to-string elt) read-expression-map t |
689 | 691 (cons 'command-history arg)) |
690 ;; If command was added to command-history as a string, | 692 |
691 ;; get rid of that. We want only evaluable expressions there. | 693 ;; If command was added to command-history as a |
692 (if (stringp (car command-history)) | 694 ;; string, get rid of that. We want only |
693 (setq command-history (cdr command-history))) | 695 ;; evaluable expressions there. |
696 (if (stringp (car command-history)) | |
697 (setq command-history (cdr command-history)))))) | |
694 | 698 |
695 ;; If command to be redone does not match front of history, | 699 ;; If command to be redone does not match front of history, |
696 ;; add it to the history. | 700 ;; add it to the history. |
697 (or (equal newcmd (car command-history)) | 701 (or (equal newcmd (car command-history)) |
698 (setq command-history (cons newcmd command-history))) | 702 (setq command-history (cons newcmd command-history))) |