emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r112448: * lisp/simple.el (read-expre


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112448: * lisp/simple.el (read-expression-map): Use completion-at-point.
Date: Sat, 04 May 2013 15:27:41 -0400
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112448
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14255
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Sat 2013-05-04 15:27:41 -0400
message:
  * 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.
modified:
  lisp/ChangeLog
  lisp/simple.el
  src/ChangeLog
  src/callint.c
  src/lread.c
  src/minibuf.c
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-05-03 07:52:17 +0000
+++ b/lisp/ChangeLog    2013-05-04 19:27:41 +0000
@@ -1,9 +1,16 @@
+2013-05-04  Stefan Monnier  <address@hidden>
+
+       * 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  <address@hidden>
 
        * 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  <address@hidden>
 
-       * 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  <address@hidden>
 
@@ -75,8 +82,8 @@
 2013-04-30  Alan Mackenzie  <address@hidden>
 
        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  <address@hidden>  (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  <address@hidden>

=== modified file 'lisp/simple.el'
--- a/lisp/simple.el    2013-04-18 13:15:08 +0000
+++ b/lisp/simple.el    2013-05-04 19:27:41 +0000
@@ -1236,13 +1236,35 @@
                   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 @@
 (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)

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-05-04 10:19:13 +0000
+++ b/src/ChangeLog     2013-05-04 19:27:41 +0000
@@ -1,8 +1,15 @@
+2013-05-04  Stefan Monnier  <address@hidden>
+
+       * 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  <address@hidden>
 
        * 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)

=== modified file 'src/callint.c'
--- a/src/callint.c     2013-04-27 21:12:17 +0000
+++ b/src/callint.c     2013-05-04 19:27:41 +0000
@@ -733,12 +733,12 @@
          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;
 

=== modified file 'src/lread.c'
--- a/src/lread.c       2013-04-02 01:54:56 +0000
+++ b/src/lread.c       2013-05-04 19:27:41 +0000
@@ -1976,7 +1976,9 @@
   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);
 }

=== modified file 'src/minibuf.c'
--- a/src/minibuf.c     2013-04-16 02:39:47 +0000
+++ b/src/minibuf.c     2013-05-04 19:27:41 +0000
@@ -986,34 +986,6 @@
   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 @@
   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);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]