From 17e5c0cc8f2c51a5773e09aa45eee7a9e6c9e961 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 24 May 2013 22:21:49 -0400 Subject: [PATCH] * lisp/simple.el (read--expression): New function, extracted from eval-expression. Set completion-at-point-functions. (eval-expression, eval-minibuffer): Use it. * lisp/progmodes/flymake.el (flymake-nop): Don't return a string. (flymake-set-at): Fix typo. Fixes: debbugs:14465 --- lisp/ChangeLog | 9 +++++++++ lisp/progmodes/flymake.el | 10 +++++----- lisp/simple.el | 22 +++++++++++++--------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3cb0535ce5e..0fa162b1d80 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2013-05-25 Stefan Monnier + + * progmodes/flymake.el (flymake-nop): Don't return a string. + (flymake-set-at): Fix typo. + + * simple.el (read--expression): New function, extracted from + eval-expression. Set completion-at-point-functions (bug#14465). + (eval-expression, eval-minibuffer): Use it. + 2013-05-25 Xue Fuqiao * progmodes/flymake.el (flymake-save-buffer-in-file) diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index aed62b27450..99b48e8d0db 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -170,7 +170,8 @@ See `x-popup-menu' for the menu specifier format." (if (featurep 'xemacs) (progn (defun flymake-nop () - "Do nothing.") + "Do nothing." + nil) (defun flymake-make-xemacs-menu (menu-data) "Return a menu specifier using MENU-DATA." @@ -251,15 +252,14 @@ are the string substitutions (see the function `format')." (defun flymake-ins-after (list pos val) "Insert VAL into LIST after position POS. POS counts from zero." - (let ((tmp (copy-sequence list))) ; Bind `tmp' to a copy of LIST + (let ((tmp (copy-sequence list))) (setcdr (nthcdr pos tmp) (cons val (nthcdr (1+ pos) tmp))) tmp)) (defun flymake-set-at (list pos val) -) -"Set VAL at position POS in LIST. + "Set VAL at position POS in LIST. POS counts from zero." -(let ((tmp (copy-sequence list))) ; Bind `tmp' to a copy of LIST + (let ((tmp (copy-sequence list))) (setcar (nthcdr pos tmp) val) tmp)) diff --git a/lisp/simple.el b/lisp/simple.el index 82c7100f589..18a360faa61 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1268,9 +1268,7 @@ is a string to insert in the minibuffer before reading. \(INITIAL-CONTENTS can also be a cons of a string and an integer. Such arguments are used as in `read-from-minibuffer'.)" ;; Used for interactive spec `X'. - ;; FIXME: Share code with `eval-expression'. - (eval (read-from-minibuffer prompt initial-contents read-expression-map - t read-expression-history))) + (eval (read--expression prompt initial-contents))) (defvar minibuffer-completing-symbol nil "Non-nil means completing a Lisp symbol in the minibuffer.") @@ -1322,6 +1320,17 @@ display the result of expression evaluation." (defvar eval-expression-minibuffer-setup-hook nil "Hook run by `eval-expression' when entering the minibuffer.") +(defun read--expression (prompt &optional initial-contents) + (let ((minibuffer-completing-symbol t)) + (minibuffer-with-setup-hook + (lambda () + (add-hook 'completion-at-point-functions + #'lisp-completion-at-point nil t) + (run-hooks 'eval-expression-minibuffer-setup-hook)) + (read-from-minibuffer prompt initial-contents + read-expression-map t + 'read-expression-history)))) + ;; We define this, rather than making `eval' interactive, ;; for the sake of completion of names like eval-region, eval-buffer. (defun eval-expression (exp &optional insert-value) @@ -1338,12 +1347,7 @@ and `eval-expression-print-level'. If `eval-expression-debug-on-error' is non-nil, which is the default, this command arranges for all errors to enter the debugger." (interactive - (list (let ((minibuffer-completing-symbol t)) - (minibuffer-with-setup-hook - (lambda () (run-hooks 'eval-expression-minibuffer-setup-hook)) - (read-from-minibuffer "Eval: " - nil read-expression-map t - 'read-expression-history))) + (list (read--expression "Eval: ") current-prefix-arg)) (if (null eval-expression-debug-on-error) -- 2.39.2