From 4c539a7b387874577136190d8e1a413da1d7e240 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 27 May 2014 20:50:44 -0400 Subject: [PATCH] * 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. Fixes: debbugs:17475 --- lisp/ChangeLog | 4 +++- lisp/emacs-lisp/byte-opt.el | 9 --------- lisp/subr.el | 10 +++++++++- src/ChangeLog | 21 +++++++++++++++++---- src/data.c | 21 +-------------------- src/keyboard.c | 25 +++++++++++++------------ 6 files changed, 43 insertions(+), 47 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8845b77b3b7..22e88a453ce 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,10 +1,12 @@ 2014-05-28 Stefan Monnier + * 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. diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index b1e06410da4..90d1dd913e9 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -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 diff --git a/lisp/subr.el b/lisp/subr.el index a72a026f195..8767511f651 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -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)) ;;;; 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)) diff --git a/src/ChangeLog b/src/ChangeLog index f88a1b31dba..b57aec9770e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2014-05-28 Stefan Monnier + + * 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 * 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 - * 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 diff --git a/src/data.c b/src/data.c index bf863aaed79..0c90944f0ad 100644 --- a/src/data.c +++ b/src/data.c @@ -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; -} /* 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); diff --git a/src/keyboard.c b/src/keyboard.c index 26afc02ec23..0308b7106d7 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -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]); } -- 2.39.2