emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r117171: * lisp/subr.el (zerop): Move from C. Add co


From: Stefan Monnier
Subject: [Emacs-diffs] trunk r117171: * lisp/subr.el (zerop): Move from C. Add compiler-macro.
Date: Wed, 28 May 2014 00:50:56 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117171
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17475
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Tue 2014-05-27 20:50:44 -0400
message:
  * lisp/subr.el (zerop): Move from C.  Add compiler-macro.
  * 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.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/emacs-lisp/byte-opt.el    byteopt.el-20091113204419-o5vbwnq5f7feedwu-491
  lisp/subr.el                   subr.el-20091113204419-o5vbwnq5f7feedwu-151
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/data.c                     data.c-20091113204419-o5vbwnq5f7feedwu-251
  src/keyboard.c                 keyboard.c-20091113204419-o5vbwnq5f7feedwu-449
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-05-28 00:09:14 +0000
+++ b/lisp/ChangeLog    2014-05-28 00:50:44 +0000
@@ -1,10 +1,12 @@
 2014-05-28  Stefan Monnier  <address@hidden>
 
+       * 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.
 

=== modified file 'lisp/emacs-lisp/byte-opt.el'
--- a/lisp/emacs-lisp/byte-opt.el       2014-02-10 01:34:22 +0000
+++ b/lisp/emacs-lisp/byte-opt.el       2014-05-28 00:50:44 +0000
@@ -942,15 +942,6 @@
       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

=== modified file 'lisp/subr.el'
--- a/lisp/subr.el      2014-05-28 00:09:14 +0000
+++ b/lisp/subr.el      2014-05-28 00:50:44 +0000
@@ -334,6 +334,13 @@
 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))
 
 ;;;; List functions.
 
@@ -3845,7 +3852,8 @@
            (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))

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-05-27 23:48:35 +0000
+++ b/src/ChangeLog     2014-05-28 00:50:44 +0000
@@ -1,3 +1,16 @@
+2014-05-28  Stefan Monnier  <address@hidden>
+
+       * 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  <address@hidden>
 
        * bytecode.c (FETCH) [BYTE_CODE_SAFE]: Check the bytecode wasn't
@@ -360,8 +373,8 @@
 
        * 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.
 
@@ -480,8 +493,8 @@
 
 2014-04-17  Daniel Colascione  <address@hidden>
 
-       * 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

=== modified file 'src/data.c'
--- a/src/data.c        2014-05-19 19:19:05 +0000
+++ b/src/data.c        2014-05-28 00:50:44 +0000
@@ -2332,7 +2332,7 @@
   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 @@
 {
   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;
-}
 
 /* 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 @@
   defsubr (&Sleq);
   defsubr (&Sgeq);
   defsubr (&Sneq);
-  defsubr (&Szerop);
   defsubr (&Splus);
   defsubr (&Sminus);
   defsubr (&Stimes);

=== modified file 'src/keyboard.c'
--- a/src/keyboard.c    2014-05-13 22:59:36 +0000
+++ b/src/keyboard.c    2014-05-28 00:50:44 +0000
@@ -2376,6 +2376,13 @@
     }
 }
 
+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 @@
       && !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 @@
     {
 
       /* 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 @@
 #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 @@
          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 @@
        {
          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 @@
      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]);
     }


reply via email to

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