]> code.delx.au - gnu-emacs/commitdiff
* lisp/subr.el (zerop): Move from C. Add compiler-macro.
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 28 May 2014 00:50:44 +0000 (20:50 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 28 May 2014 00:50:44 +0000 (20:50 -0400)
* lisp/emacs-lisp/byte-opt.el (byte-optimize-zerop): Remove.
* src/data.c (Fzerop): Move to Elisp.
(syms_of_data): Don't defsubr it.
* src/keyboard.c (echo_keystrokes_p): New function.
(read_char, record_menu_key, read_key_sequence): Use it.

Fixes: debbugs:17475
lisp/ChangeLog
lisp/emacs-lisp/byte-opt.el
lisp/subr.el
src/ChangeLog
src/data.c
src/keyboard.c

index 8845b77b3b7e0d75bc24325f55445b9fd096e10d..22e88a453ce994f22f38ab01592738a0ccdf0e48 100644 (file)
@@ -1,10 +1,12 @@
 2014-05-28  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * subr.el (zerop): Move from C.  Add compiler-macro (bug#17475).
+       * emacs-lisp/byte-opt.el (byte-optimize-zerop): Remove.
+
        * subr.el (internal--funcall-interactively): New.
        (internal--call-interactively): Remove.
        (called-interactively-p): Detect funcall-interactively instead of
        call-interactively.
-
        * simple.el (repeat-complex-command): Use funcall-interactively.
        (repeat-complex-command--called-interactively-skip): Remove.
 
index b1e06410da44a53fc0f01d47949291f51d8828c9..90d1dd913e9e4956b4bedf31adda142dd519865e 100644 (file)
       form
     (nth 1 form)))
 
-(defun byte-optimize-zerop (form)
-  (cond ((numberp (nth 1 form))
-        (eval form))
-       (byte-compile-delete-errors
-        (list '= (nth 1 form) 0))
-       (form)))
-
-(put 'zerop 'byte-optimizer 'byte-optimize-zerop)
-
 (defun byte-optimize-and (form)
   ;; Simplify if less than 2 args.
   ;; if there is a literal nil in the args to `and', throw it and following
index a72a026f1955bd45134eb9943f04eb7875368766..8767511f6512c20b5c0ffe63b3d6660109ea0e33 100644 (file)
@@ -334,6 +334,13 @@ Any list whose car is `frame-configuration' is assumed to be a frame
 configuration."
   (and (consp object)
        (eq (car object) 'frame-configuration)))
+
+(defun zerop (number)
+  "Return t if NUMBER is zero."
+  ;; Used to be in C, but it's pointless since (= 0 n) is faster anyway because
+  ;; = has a byte-code.
+  (declare (compiler-macro (lambda (_) `(= 0 ,number))))
+  (= 0 number))
 \f
 ;;;; List functions.
 
@@ -3845,7 +3852,8 @@ This function is called directly from the C code."
            (byte-compile-log-warning msg))
        (run-with-timer 0 nil
                        (lambda (msg)
-                         (message "%s" msg)) msg))))
+                         (message "%s" msg))
+                        msg))))
 
   ;; Finally, run any other hook.
   (run-hook-with-args 'after-load-functions abs-file))
index f88a1b31dbab43a07f82d0207f1f8d0795aeb7df..b57aec9770ec0103f28a9b8cf857134e7dcb69ab 100644 (file)
@@ -1,3 +1,16 @@
+2014-05-28  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * data.c (Fzerop): Move to Elisp.
+       (syms_of_data): Don't defsubr it.
+       * keyboard.c (echo_keystrokes_p): New function.
+       (read_char, record_menu_key, read_key_sequence): Use it.
+
+       * callint.c (Qfuncall_interactively): New var.
+       (Qcall_interactively): Remove.
+       (Ffuncall_interactively): New function.
+       (Fcall_interactively): Use it.
+       (syms_of_callint): Defsubr it.
+
 2014-05-27  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * bytecode.c (FETCH) [BYTE_CODE_SAFE]: Check the bytecode wasn't
 
        * term.c (tty_menu_display): Move the cursor to the active menu item.
        (tty_menu_activate): Return the cursor to the active menu item
-       after displaying the menu and after displaying help-echo.  See
-       http://lists.gnu.org/archive/html/emacs-devel/2014-04/msg00402.html
+       after displaying the menu and after displaying help-echo.
+       See http://lists.gnu.org/archive/html/emacs-devel/2014-04/msg00402.html
        for the details of why this is needed by screen readers and
        Braille displays.
 
 
 2014-04-17  Daniel Colascione  <dancol@dancol.org>
 
-       * term.c (Qtty_mode_set_strings, Qtty_mode_reset_strings): New
-       symbols.
+       * term.c (Qtty_mode_set_strings, Qtty_mode_reset_strings):
+       New symbols.
        (tty_send_additional_strings): New function.
        (tty_set_terminal_modes, tty_reset_terminal_modes): Use it.
        (syms_of_term): Intern tty-mode-set-strings and
index bf863aaed79a903f12cb555725fec8cb85e86c33..0c90944f0ad4fda16ab0c5aed2eacf68845b13f3 100644 (file)
@@ -2332,7 +2332,7 @@ arithcompare_driver (ptrdiff_t nargs, Lisp_Object *args,
   ptrdiff_t argnum;
   for (argnum = 1; argnum < nargs; ++argnum)
     {
-      if (EQ (Qnil, arithcompare (args[argnum-1], args[argnum], comparison)))
+      if (EQ (Qnil, arithcompare (args[argnum - 1], args[argnum], comparison)))
         return Qnil;
     }
   return Qt;
@@ -2386,24 +2386,6 @@ DEFUN ("/=", Fneq, Sneq, 2, 2, 0,
 {
   return arithcompare (num1, num2, ARITH_NOTEQUAL);
 }
-
-DEFUN ("zerop", Fzerop, Szerop, 1, 1, 0,
-       doc: /* Return t if NUMBER is zero.  */)
-  (register Lisp_Object number)
-{
-  CHECK_NUMBER_OR_FLOAT (number);
-
-  if (FLOATP (number))
-    {
-      if (XFLOAT_DATA (number) == 0.0)
-       return Qt;
-      return Qnil;
-    }
-
-  if (!XINT (number))
-    return Qt;
-  return Qnil;
-}
 \f
 /* Convert the cons-of-integers, integer, or float value C to an
    unsigned value with maximum value MAX.  Signal an error if C does not
@@ -3650,7 +3632,6 @@ syms_of_data (void)
   defsubr (&Sleq);
   defsubr (&Sgeq);
   defsubr (&Sneq);
-  defsubr (&Szerop);
   defsubr (&Splus);
   defsubr (&Sminus);
   defsubr (&Stimes);
index 26afc02ec23e419fddbe806a53c6927e4cfa0ba0..0308b7106d7818dbd0fc5102b190578fed7f0c40 100644 (file)
@@ -2376,6 +2376,13 @@ read_decoded_event_from_main_queue (struct timespec *end_time,
     }
 }
 
+static bool
+echo_keystrokes_p (void)
+{
+  return (FLOATP (Vecho_keystrokes) ? XFLOAT_DATA (Vecho_keystrokes) > 0.0
+         : INTEGERP (Vecho_keystrokes) ? XINT (Vecho_keystrokes) > 0 : false);
+}
+
 /* Read a character from the keyboard; call the redisplay if needed.  */
 /* commandflag 0 means do not autosave, but do redisplay.
    -1 means do not redisplay, but do autosave.
@@ -2711,8 +2718,7 @@ read_char (int commandflag, Lisp_Object map,
       && !current_kboard->immediate_echo
       && this_command_key_count > 0
       && ! noninteractive
-      && (FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
-      && NILP (Fzerop (Vecho_keystrokes))
+      && echo_keystrokes_p ()
       && (/* No message.  */
          NILP (echo_area_buffer[0])
          /* Or empty message.  */
@@ -3173,8 +3179,7 @@ read_char (int commandflag, Lisp_Object map,
     {
 
       /* Don't echo mouse motion events.  */
-      if ((FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
-         && NILP (Fzerop (Vecho_keystrokes))
+      if (echo_keystrokes_p ()
          && ! (EVENT_HAS_PARAMETERS (c)
                && EQ (EVENT_HEAD_KIND (EVENT_HEAD (c)), Qmouse_movement)))
        {
@@ -3250,8 +3255,7 @@ record_menu_key (Lisp_Object c)
 #endif
 
   /* Don't echo mouse motion events.  */
-  if ((FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
-      && NILP (Fzerop (Vecho_keystrokes)))
+  if (echo_keystrokes_p ())
     {
       echo_char (c);
 
@@ -8931,8 +8935,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
          echo_now ();
        }
       else if (cursor_in_echo_area
-              && (FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
-              && NILP (Fzerop (Vecho_keystrokes)))
+              && echo_keystrokes_p ())
        /* This doesn't put in a dash if the echo buffer is empty, so
           you don't always see a dash hanging out in the minibuffer.  */
        echo_dash ();
@@ -9064,8 +9067,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
        {
          key = keybuf[t];
          add_command_key (key);
-         if ((FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
-             && NILP (Fzerop (Vecho_keystrokes))
+         if (echo_keystrokes_p ()
              && current_kboard->immediate_echo)
            {
              echo_add_key (key);
@@ -9729,8 +9731,7 @@ read_key_sequence (Lisp_Object *keybuf, int bufsize, Lisp_Object prompt,
      Better ideas?  */
   for (; t < mock_input; t++)
     {
-      if ((FLOATP (Vecho_keystrokes) || INTEGERP (Vecho_keystrokes))
-         && NILP (Fzerop (Vecho_keystrokes)))
+      if (echo_keystrokes_p ())
        echo_char (keybuf[t]);
       add_command_key (keybuf[t]);
     }