[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Internationalize Emacs's messages (swahili)
From: |
Lars Ingebrigtsen |
Subject: |
Re: Internationalize Emacs's messages (swahili) |
Date: |
Sun, 27 Dec 2020 00:04:05 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
I whipped one up quickly. The slightly interesting thing here is that
we have an opportunity here to make this slightly faster -- since we
have an upper length bound here, we can eschew the tortoise/hare
FOR_EACH_TAIL bit and just follow CDRs, which would be faster. Of
course, if you give it a circular list, then it'll always return Qnil,
and if you give it (expt most-positive-fixnum most-positive-fixnum) on a
circular list, it'll take a while...
diff --git a/src/fns.c b/src/fns.c
index 646c3ed083..2234818e8e 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -145,6 +145,29 @@ DEFUN ("safe-length", Fsafe_length, Ssafe_length, 1, 1, 0,
return make_fixnum (len);
}
+DEFUN ("length<", Flength_less, Slength_less, 2, 2, 0,
+ doc: /* Return non-nil if SEQUENCE is shorter than LENGTH.
+See `length' for allowed values of SEQUENCE. */)
+ (Lisp_Object sequence, Lisp_Object length)
+{
+ CHECK_INTEGER (length);
+ EMACS_INT len = XFIXNUM (length);
+
+ if (CONSP (sequence))
+ {
+ intptr_t i = 0;
+ FOR_EACH_TAIL (sequence)
+ {
+ i++;
+ if (i >= len)
+ return Qnil;
+ }
+ return Qt;
+ }
+ else
+ return XFIXNUM (Flength (sequence)) < len? Qt: Qnil;
+}
+
DEFUN ("proper-list-p", Fproper_list_p, Sproper_list_p, 1, 1, 0,
doc: /* Return OBJECT's length if it is a proper list, nil otherwise.
A proper list is neither circular nor dotted (i.e., its last cdr is nil). */
@@ -5721,6 +5744,7 @@ syms_of_fns (void)
defsubr (&Srandom);
defsubr (&Slength);
defsubr (&Ssafe_length);
+ defsubr (&Slength_less);
defsubr (&Sproper_list_p);
defsubr (&Sstring_bytes);
defsubr (&Sstring_distance);
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- Re: Internationalize Emacs's messages (swahili), (continued)
- Re: Internationalize Emacs's messages (swahili), Lars Ingebrigtsen, 2020/12/26
- Re: Internationalize Emacs's messages (swahili), Lars Ingebrigtsen, 2020/12/26
- Re: Internationalize Emacs's messages (swahili), Stefan Monnier, 2020/12/26
- Re: Internationalize Emacs's messages (swahili), Lars Ingebrigtsen, 2020/12/26
- Re: Internationalize Emacs's messages (swahili), Stefan Monnier, 2020/12/26
- Re: Internationalize Emacs's messages (swahili), Lars Ingebrigtsen, 2020/12/26
- Re: Internationalize Emacs's messages (swahili),
Lars Ingebrigtsen <=
- Re: Internationalize Emacs's messages (swahili), Lars Ingebrigtsen, 2020/12/26
- Re: Internationalize Emacs's messages (swahili), Lars Ingebrigtsen, 2020/12/27
- Re: Internationalize Emacs's messages (swahili), Eli Zaretskii, 2020/12/27
- Re: Internationalize Emacs's messages (swahili), Lars Ingebrigtsen, 2020/12/27
- Re: Internationalize Emacs's messages (swahili), Tomas Hlavaty, 2020/12/27
- Re: Internationalize Emacs's messages (swahili), Alfred M. Szmidt, 2020/12/27
- Re: Internationalize Emacs's messages (swahili), Tomas Hlavaty, 2020/12/27
- lengths and other stuff, Daniel Brooks, 2020/12/27
- Re: lengths and other stuff, Lars Ingebrigtsen, 2020/12/27
- Re: lengths and other stuff, Daniel Brooks, 2020/12/27