Mercurial > emacs
comparison lisp/simple.el @ 4821:2c16f99ef5dc
(edit-and-eval-command): Let `read-from-minibuffer' manipulate the
history list, don't manipulate it directly.
(repeat-complex-command): Same thing.
author | Brian Fox <bfox@gnu.org> |
---|---|
date | Tue, 05 Oct 1993 01:19:12 +0000 |
parents | 5815d7b38e9a |
children | a3a72fce1143 |
comparison
equal
deleted
inserted
replaced
4820:fdc2ebb95bed | 4821:2c16f99ef5dc |
---|---|
392 "Prompting with PROMPT, let user edit COMMAND and eval result. | 392 "Prompting with PROMPT, let user edit COMMAND and eval result. |
393 COMMAND is a Lisp expression. Let user edit that expression in | 393 COMMAND is a Lisp expression. Let user edit that expression in |
394 the minibuffer, then read and evaluate the result." | 394 the minibuffer, then read and evaluate the result." |
395 (let ((command (read-from-minibuffer prompt | 395 (let ((command (read-from-minibuffer prompt |
396 (prin1-to-string command) | 396 (prin1-to-string command) |
397 read-expression-map t))) | 397 read-expression-map t |
398 ;; Add edited command to command history, unless redundant. | 398 '(command-history . 1)))) |
399 (or (equal command (car command-history)) | 399 ;;; Don't add the command to the history; read-from-minibuffer has |
400 (setq command-history (cons command command-history))) | 400 ;;; already done that. |
401 ;;; ;; Add edited command to command history, unless redundant. | |
402 ;;; (or (equal command (car command-history)) | |
403 ;;; (setq command-history (cons command command-history))) | |
401 (eval command))) | 404 (eval command))) |
402 | 405 |
403 (defun repeat-complex-command (arg) | 406 (defun repeat-complex-command (arg) |
404 "Edit and re-evaluate last complex command, or ARGth from last. | 407 "Edit and re-evaluate last complex command, or ARGth from last. |
405 A complex command is one which used the minibuffer. | 408 A complex command is one which used the minibuffer. |
414 (minibuffer-history-position arg) | 417 (minibuffer-history-position arg) |
415 (minibuffer-history-sexp-flag t) | 418 (minibuffer-history-sexp-flag t) |
416 newcmd) | 419 newcmd) |
417 (if elt | 420 (if elt |
418 (progn | 421 (progn |
419 (setq newcmd (read-from-minibuffer "Redo: " | 422 (setq newcmd |
420 (prin1-to-string elt) | 423 (read-from-minibuffer |
421 read-expression-map | 424 "Redo: " (prin1-to-string elt) read-expression-map t |
422 t | 425 (cons 'command-history arg))) |
423 (cons 'command-history | 426 |
424 arg))) | 427 ;;; read-from-minibuffer handles the adding of what is read to the history |
425 ;; If command was added to command-history as a string, | 428 ;;; variable. |
426 ;; get rid of that. We want only evallable expressions there. | 429 ;;; |
427 (if (stringp (car command-history)) | 430 ;;; ;; If command was added to command-history as a string, |
428 (setq command-history (cdr command-history))) | 431 ;;; ;; get rid of that. We want only evallable expressions there. |
429 ;; If command to be redone does not match front of history, | 432 ;;; (if (stringp (car command-history)) |
430 ;; add it to the history. | 433 ;;; (setq command-history (cdr command-history))) |
431 (or (equal newcmd (car command-history)) | 434 ;;; |
432 (setq command-history (cons newcmd command-history))) | 435 ;;; ;; If command to be redone does not match front of history, |
436 ;;; ;; add it to the history. | |
437 ;;; (or (equal newcmd (car command-history)) | |
438 ;;; (setq command-history (cons newcmd command-history))) | |
433 (eval newcmd)) | 439 (eval newcmd)) |
434 (ding)))) | 440 (ding)))) |
435 | 441 |
436 (defvar minibuffer-history nil | 442 (defvar minibuffer-history nil |
437 "Default minibuffer history list. | 443 "Default minibuffer history list. |