emacs-devel
[Top][All Lists]
Advanced

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

Re: empty-directory predicate, native implementation


From: Michael Albinus
Subject: Re: empty-directory predicate, native implementation
Date: Mon, 19 Oct 2020 10:04:31 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Arthur Miller <arthur.miller@live.com> writes:

Hi Arthur,

>> What's wrong using FIXNATP and XFIXNAT everywhere?
>
> If we return nil for 0 count, then it make sense to return nil for
> negative count too?

*Any* non-nil COUNT, which is not a natural number, is handled as it
were nil. That's what my proposal for the docstring tries to say ("If
COUNT is a natural number ...").

> XFIXNAT will turn it negative num into some big int.
> I thought first it is fine, but after second thought I don't think it is
> best thing to do.
>
> if (FIXNUMP(return_count))
>     {
>       last = XFIXNUM(return_count);
>
>       if (last < 1)
>         return Qnil;
>     }
>
> This works better.

But if you use FIXNATP instead of FIXNUMP, there's no problem at all.

>>> --- a/lisp/net/tramp-adb.el
>>> +++ b/lisp/net/tramp-adb.el
>>> @@ -312,7 +312,7 @@ tramp-adb-handle-directory-files-and-attributes
>>>        (copy-tree
>>>         (with-tramp-file-property
>>>        v localname (format "directory-files-and-attributes-%s-%s-%s-%s"
>>> -                          full match id-format nosort)
>>> +                          full match id-format nosort count)
> I did that first, but then decided to skip count in format and forgot
> to delete the count from the argument list. I didn't know how format was
> used so I didn't want to mess with it; but if it is only for the name,
> then it is maybe useful?

Well, the name is used for caches. If we want to use the cache also for
a non-nil COUNT, we must use it also for the cache entry.

>>> diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
>>> index 6d44ad23ad..a99af70196 100644
>>> --- a/lisp/net/tramp.el
>>> +++ b/lisp/net/tramp.el
>>> +(defun tramp-handle-directory-files (directory &optional full match
>>> +                                               nosort count)
>>
>> This fits into one line (80 chars).
> It is 81 chars so Emacs breaks the line. I can call it num, saves 2 chars.

It's not important. But in my Emacs, the closing parenthesis is at
position 80, IIRC :-)

> Best regards; sorry for giving you so much work!

Best regards, Michael.



reply via email to

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