From: Stefan Monnier Date: Sat, 4 May 2013 19:27:41 +0000 (-0400) Subject: * lisp/simple.el (read-expression-map): Use completion-at-point. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~314 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=30c7e54299fc81cd3122a17ef130ab69e9855f99;p=emacs.git * lisp/simple.el (read-expression-map): Use completion-at-point. Move the declaration from C. (read-minibuffer, eval-minibuffer): Move from C. (completion-setup-function): Avoid minibuffer-completion-contents. * src/minibuf.c (Fread_minibuffer, Feval_minibuffer): Move to Elisp. (syms_of_minibuf): Adjust accodingly. * src/lread.c (Fread): * src/callint.c (Fcall_interactively): Adjust calls accordingly. Fixes: debbugs:14255 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a2719a2ebf4..88bc79ad707 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,9 +1,16 @@ +2013-05-04 Stefan Monnier + + * simple.el (read-expression-map): Use completion-at-point (bug#14255). + Move the declaration from C. + (read-minibuffer, eval-minibuffer): Move from C. + (completion-setup-function): Avoid minibuffer-completion-contents. + 2013-05-03 Leo Liu * progmodes/octave.el (octave-font-lock-keywords): Do not dehighlight 'end' in comments or strings. - (octave-completing-read, octave-goto-function-definition): New - helpers. + (octave-completing-read, octave-goto-function-definition): + New helpers. (octave-help-buffer): New user variable. (octave-help-file, octave-help-function): New button types. (octave-help): New command and bind it to C-h ;. @@ -24,8 +31,8 @@ 2013-05-02 Leo Liu - * progmodes/octave.el (octave-syntax-propertize-function): Include - the case when ' is at line beginning. (Bug#14336) + * progmodes/octave.el (octave-syntax-propertize-function): + Include the case when ' is at line beginning. (Bug#14336) 2013-05-02 Glenn Morris @@ -75,8 +82,8 @@ 2013-04-30 Alan Mackenzie Handle arbitrarily long C++ member initialisation lists. - * progmodes/cc-engine.el (c-back-over-member-initializers): new - function. + * progmodes/cc-engine.el (c-back-over-member-initializers): + new function. (c-guess-basic-syntax): New CASE 5R (extracted from 5B) to handle (most) member init lists. @@ -172,8 +179,8 @@ 2013-04-27 Ingo Lohmar (tiny change) * ls-lisp.el (ls-lisp-insert-directory): If no files are - displayed, move point to after the totals line. See - http://lists.gnu.org/archive/html/emacs-devel/2013-04/msg00677.html + displayed, move point to after the totals line. + See http://lists.gnu.org/archive/html/emacs-devel/2013-04/msg00677.html for the details. 2013-04-27 Stefan Monnier diff --git a/lisp/simple.el b/lisp/simple.el index 5fda9021004..7ded4cbe58c 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -1236,13 +1236,35 @@ in *Help* buffer. See also the command `describe-char'." bidi-fixer encoding-msg pos total percent col hscroll)))))) ;; Initialize read-expression-map. It is defined at C level. -(let ((m (make-sparse-keymap))) - (define-key m "\M-\t" 'lisp-complete-symbol) - ;; Might as well bind TAB to completion, since inserting a TAB char is much - ;; too rarely useful. - (define-key m "\t" 'lisp-complete-symbol) - (set-keymap-parent m minibuffer-local-map) - (setq read-expression-map m)) +(defvar read-expression-map + (let ((m (make-sparse-keymap))) + (define-key m "\M-\t" 'completion-at-point) + ;; Might as well bind TAB to completion, since inserting a TAB char is + ;; much too rarely useful. + (define-key m "\t" 'completion-at-point) + (set-keymap-parent m minibuffer-local-map) + m)) + +(defun read-minibuffer (prompt &optional initial-contents) + "Return a Lisp object read using the minibuffer, unevaluated. +Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS +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'. + (read-from-minibuffer prompt initial-contents minibuffer-local-map + t minibuffer-history)) + +(defun eval-minibuffer (prompt &optional initial-contents) + "Return value of Lisp expression read using the minibuffer. +Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS +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))) (defvar minibuffer-completing-symbol nil "Non-nil means completing a Lisp symbol in the minibuffer.") @@ -6714,15 +6736,21 @@ Called from `temp-buffer-show-hook'." (defun completion-setup-function () (let* ((mainbuf (current-buffer)) (base-dir - ;; When reading a file name in the minibuffer, - ;; try and find the right default-directory to set in the - ;; completion list buffer. - ;; FIXME: Why do we do that, actually? --Stef + ;; FIXME: This is a bad hack. We try to set the default-directory + ;; in the *Completions* buffer so that the relative file names + ;; displayed there can be treated as valid file names, independently + ;; from the completion context. But this suffers from many problems: + ;; - It's not clear when the completions are file names. With some + ;; completion tables (e.g. bzr revision specs), the listed + ;; completions can mix file names and other things. + ;; - It doesn't pay attention to possible quoting. + ;; - With fancy completion styles, the code below will not always + ;; find the right base directory. (if minibuffer-completing-file-name (file-name-as-directory (expand-file-name - (substring (minibuffer-completion-contents) - 0 (or completion-base-size 0))))))) + (buffer-substring (minibuffer-prompt-end) + (- (point) (or completion-base-size 0)))))))) (with-current-buffer standard-output (let ((base-size completion-base-size) ;Read before killing localvars. (base-position completion-base-position) diff --git a/src/ChangeLog b/src/ChangeLog index 325babb4d86..86327fc7fb2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,8 +1,15 @@ +2013-05-04 Stefan Monnier + + * minibuf.c (Fread_minibuffer, Feval_minibuffer): Move to Elisp. + (syms_of_minibuf): Adjust accodingly. + * lread.c (Fread): + * callint.c (Fcall_interactively): Adjust calls accordingly. + 2013-05-04 Eli Zaretskii * dispextern.h (WINDOW_WANTS_HEADER_LINE_P): Verify that - w->contents is a buffer before computing everything else. Use - parentheses to disambiguate last part of the condition. + w->contents is a buffer before computing everything else. + Use parentheses to disambiguate last part of the condition. * w32fns.c (w32_wnd_proc): Remove temporary code used to trap assertion violations. (Bug#14062) diff --git a/src/callint.c b/src/callint.c index 940ff3ed249..389f9410625 100644 --- a/src/callint.c +++ b/src/callint.c @@ -733,12 +733,12 @@ invoke it. If KEYS is omitted or nil, the return value of break; case 'x': /* Lisp expression read but not evaluated. */ - args[i] = Fread_minibuffer (callint_message, Qnil); + args[i] = call1 (intern ("read-minibuffer"), callint_message); visargs[i] = last_minibuf_string; break; case 'X': /* Lisp expression read and evaluated. */ - args[i] = Feval_minibuffer (callint_message, Qnil); + args[i] = call1 (intern ("eval-minibuffer"), callint_message); visargs[i] = last_minibuf_string; break; diff --git a/src/lread.c b/src/lread.c index 8e623e838c7..1a8a57e57a7 100644 --- a/src/lread.c +++ b/src/lread.c @@ -1976,7 +1976,9 @@ STREAM or the value of `standard-input' may be: if (EQ (stream, Qt)) stream = Qread_char; if (EQ (stream, Qread_char)) - return Fread_minibuffer (build_string ("Lisp expression: "), Qnil); + /* FIXME: ¿¡ When is this used !? */ + return call1 (intern ("read-minibuffer"), + build_string ("Lisp expression: ")); return read_internal_start (stream, Qnil, Qnil); } diff --git a/src/minibuf.c b/src/minibuf.c index b96d27e0742..b69a16eff42 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -986,34 +986,6 @@ and some related functions, which use zero-indexing for POSITION. */) return val; } -DEFUN ("read-minibuffer", Fread_minibuffer, Sread_minibuffer, 1, 2, 0, - doc: /* Return a Lisp object read using the minibuffer, unevaluated. -Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS -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'.) */) - (Lisp_Object prompt, Lisp_Object initial_contents) -{ - CHECK_STRING (prompt); - return read_minibuf (Vminibuffer_local_map, initial_contents, - prompt, 1, Qminibuffer_history, - make_number (0), Qnil, 0, 0); -} - -DEFUN ("eval-minibuffer", Feval_minibuffer, Seval_minibuffer, 1, 2, 0, - doc: /* Return value of Lisp expression read using the minibuffer. -Prompt with PROMPT. If non-nil, optional second arg INITIAL-CONTENTS -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'.) */) - (Lisp_Object prompt, Lisp_Object initial_contents) -{ - return Feval (read_minibuf (Vread_expression_map, initial_contents, - prompt, 1, Qread_expression_history, - make_number (0), Qnil, 0, 0), - Qnil); -} - /* Functions that use the minibuffer to read various things. */ DEFUN ("read-string", Fread_string, Sread_string, 1, 5, 0, @@ -2137,15 +2109,9 @@ properties. */); Vminibuffer_prompt_properties = Fcons (intern_c_string ("read-only"), Fcons (Qt, Qnil)); - DEFVAR_LISP ("read-expression-map", Vread_expression_map, - doc: /* Minibuffer keymap used for reading Lisp expressions. */); - Vread_expression_map = Qnil; - defsubr (&Sactive_minibuffer_window); defsubr (&Sset_minibuffer_window); defsubr (&Sread_from_minibuffer); - defsubr (&Seval_minibuffer); - defsubr (&Sread_minibuffer); defsubr (&Sread_string); defsubr (&Sread_command); defsubr (&Sread_variable);