diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/dispnew.c | 102 |
1 files changed, 50 insertions, 52 deletions
diff --git a/src/dispnew.c b/src/dispnew.c index ad3fbbffe58..d061f2ce9f1 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -1793,29 +1793,43 @@ bitch_at_user () | |||
| 1793 | } | 1793 | } |
| 1794 | 1794 | ||
| 1795 | DEFUN ("sleep-for", Fsleep_for, Ssleep_for, 1, 2, 0, | 1795 | DEFUN ("sleep-for", Fsleep_for, Ssleep_for, 1, 2, 0, |
| 1796 | "Pause, without updating display, for ARG seconds.\n\ | 1796 | "Pause, without updating display, for SECONDS seconds.\n\ |
| 1797 | Optional second arg non-nil means ARG is measured in milliseconds.\n\ | 1797 | Optional second arg MILLISECONDS specifies an additional wait period,\n\ |
| 1798 | in milliseconds.\n\ | ||
| 1798 | \(Not all operating systems support milliseconds.)") | 1799 | \(Not all operating systems support milliseconds.)") |
| 1799 | (arg, millisec) | 1800 | (seconds, milliseconds) |
| 1800 | Lisp_Object arg, millisec; | 1801 | Lisp_Object seconds, milliseconds; |
| 1801 | { | 1802 | { |
| 1802 | int usec = 0; | 1803 | int sec, usec; |
| 1803 | int sec; | ||
| 1804 | 1804 | ||
| 1805 | CHECK_NUMBER (arg, 0); | 1805 | CHECK_NUMBER (seconds, 0); |
| 1806 | sec = XINT (arg); | 1806 | sec = XINT (seconds); |
| 1807 | if (sec <= 0) | 1807 | |
| 1808 | return Qnil; | 1808 | if (NILP (milliseconds)) |
| 1809 | XSET (milliseconds, Lisp_Int, 0); | ||
| 1810 | else | ||
| 1811 | CHECK_NUMBER (milliseconds, 1); | ||
| 1812 | usec = XINT (milliseconds); | ||
| 1809 | 1813 | ||
| 1810 | if (!NILP (millisec)) | ||
| 1811 | { | ||
| 1812 | #ifndef EMACS_HAS_USECS | 1814 | #ifndef EMACS_HAS_USECS |
| 1813 | error ("millisecond `sleep-for' not supported on %s", SYSTEM_TYPE); | 1815 | if (sec == 0 && usec != 0) |
| 1814 | #else | 1816 | error ("millisecond `sleep-for' not supported on %s", SYSTEM_TYPE); |
| 1815 | usec = sec % 1000 * 1000; | ||
| 1816 | sec /= 1000; | ||
| 1817 | #endif | 1817 | #endif |
| 1818 | |||
| 1819 | /* Assure that 0 <= usec < 1000000. */ | ||
| 1820 | if (usec < 0) | ||
| 1821 | { | ||
| 1822 | /* We can't rely on the rounding being correct if user is negative. */ | ||
| 1823 | if (-1000000 < usec) | ||
| 1824 | sec--, usec += 1000000; | ||
| 1825 | else | ||
| 1826 | sec -= -usec / 1000000, usec = 1000000 - (-usec % 1000000); | ||
| 1818 | } | 1827 | } |
| 1828 | else | ||
| 1829 | sec += usec / 1000000, usec %= 1000000; | ||
| 1830 | |||
| 1831 | if (sec <= 0) | ||
| 1832 | return Qnil; | ||
| 1819 | 1833 | ||
| 1820 | { | 1834 | { |
| 1821 | Lisp_Object zero; | 1835 | Lisp_Object zero; |
| @@ -1824,7 +1838,10 @@ Optional second arg non-nil means ARG is measured in milliseconds.\n\ | |||
| 1824 | wait_reading_process_input (sec, usec, zero, 0); | 1838 | wait_reading_process_input (sec, usec, zero, 0); |
| 1825 | } | 1839 | } |
| 1826 | 1840 | ||
| 1827 | #if 0 /* No wait_reading_process_input */ | 1841 | /* We should always have wait_reading_process_input; we have a dummy |
| 1842 | implementation for systems which don't support subprocesses. */ | ||
| 1843 | #if 0 | ||
| 1844 | /* No wait_reading_process_input */ | ||
| 1828 | immediate_quit = 1; | 1845 | immediate_quit = 1; |
| 1829 | QUIT; | 1846 | QUIT; |
| 1830 | 1847 | ||
| @@ -1916,53 +1933,34 @@ sit_for (sec, usec, reading, display) | |||
| 1916 | } | 1933 | } |
| 1917 | 1934 | ||
| 1918 | DEFUN ("sit-for", Fsit_for, Ssit_for, 1, 3, 0, | 1935 | DEFUN ("sit-for", Fsit_for, Ssit_for, 1, 3, 0, |
| 1919 | "Perform redisplay, then wait for ARG seconds or until input is available.\n\ | 1936 | "Perform redisplay, then wait for SECONDS seconds or until input is available.\n\ |
| 1920 | Optional second arg non-nil means ARG counts in milliseconds.\n\ | 1937 | Optional second arg MILLISECONDS specifies an additional wait period, in\n\ |
| 1938 | milliseconds.\n\ | ||
| 1921 | Optional third arg non-nil means don't redisplay, just wait for input.\n\ | 1939 | Optional third arg non-nil means don't redisplay, just wait for input.\n\ |
| 1922 | Redisplay is preempted as always if input arrives, and does not happen\n\ | 1940 | Redisplay is preempted as always if input arrives, and does not happen\n\ |
| 1923 | if input is available before it starts.\n\ | 1941 | if input is available before it starts.\n\ |
| 1924 | Value is t if waited the full time with no input arriving.") | 1942 | Value is t if waited the full time with no input arriving.") |
| 1925 | (arg, millisec, nodisp) | 1943 | (seconds, milliseconds, nodisp) |
| 1926 | Lisp_Object arg, millisec, nodisp; | 1944 | Lisp_Object seconds, milliseconds, nodisp; |
| 1927 | { | 1945 | { |
| 1928 | int usec = 0; | 1946 | int sec, usec; |
| 1929 | int sec; | ||
| 1930 | 1947 | ||
| 1931 | CHECK_NUMBER (arg, 0); | 1948 | CHECK_NUMBER (seconds, 0); |
| 1932 | sec = XINT (arg); | 1949 | sec = XINT (seconds); |
| 1950 | |||
| 1951 | if (NILP (milliseconds)) | ||
| 1952 | XSET (milliseconds, Lisp_Int, 0); | ||
| 1953 | else | ||
| 1954 | CHECK_NUMBER (milliseconds, 1); | ||
| 1955 | usec = XINT (milliseconds); | ||
| 1933 | 1956 | ||
| 1934 | if (!NILP (millisec)) | ||
| 1935 | { | ||
| 1936 | #ifndef EMACS_HAS_USECS | 1957 | #ifndef EMACS_HAS_USECS |
| 1937 | error ("millisecond `sit-for' not supported on %s", SYSTEM_TYPE); | 1958 | if (usec != 0 && sec == 0) |
| 1938 | #else | 1959 | error ("millisecond `sit-for' not supported on %s", SYSTEM_TYPE); |
| 1939 | usec = (sec % 1000) * 1000; | ||
| 1940 | sec /= 1000; | ||
| 1941 | #endif | 1960 | #endif |
| 1942 | } | ||
| 1943 | 1961 | ||
| 1944 | return sit_for (sec, usec, 0, NILP (nodisp)); | 1962 | return sit_for (sec, usec, 0, NILP (nodisp)); |
| 1945 | } | 1963 | } |
| 1946 | |||
| 1947 | DEFUN ("sleep-for-millisecs", Fsleep_for_millisecs, Ssleep_for_millisecs, | ||
| 1948 | 1, 1, 0, | ||
| 1949 | "Pause, without updating display, for ARG milliseconds.") | ||
| 1950 | (arg) | ||
| 1951 | Lisp_Object arg; | ||
| 1952 | { | ||
| 1953 | Lisp_Object zero; | ||
| 1954 | |||
| 1955 | #ifndef EMACS_HAS_USECS | ||
| 1956 | error ("sleep-for-millisecs not supported on %s", SYSTEM_TYPE); | ||
| 1957 | #else | ||
| 1958 | CHECK_NUMBER (arg, 0); | ||
| 1959 | |||
| 1960 | XFASTINT (zero) = 0; | ||
| 1961 | wait_reading_process_input (XINT (arg) / 1000, XINT (arg) % 1000 * 1000, | ||
| 1962 | zero, 0); | ||
| 1963 | return Qnil; | ||
| 1964 | #endif /* EMACS_HAS_USECS */ | ||
| 1965 | } | ||
| 1966 | 1964 | ||
| 1967 | char *terminal_type; | 1965 | char *terminal_type; |
| 1968 | 1966 | ||