Hongyi Zhao <[email protected]> writes:

> On Mon, Jul 12, 2021 at 3:46 PM Tassilo Horn <[email protected]> wrote:
>>
>> Hongyi Zhao <[email protected]> writes:
>> >> (delq nil (mapcar (lambda (buf)
>> >>                     (with-current-buffer buf
>> >>                       (when (eq major-mode 'LaTeX-mode)
>> >>                         (cons (buffer-file-name buf)
>> >>                               (TeX-master-file "pdf")))))
>> >>                   (buffer-list)))
>> >> nil
>> >
>> > This is just out of the curiosity about the behavior of the `delq'
>> > built-in function used above. According to the built-in document:
>>
>> (delq nil '(nil 1 nil)) ;=> (1)
>> (delq nil '(nil nil nil)) ;=> nil, aka, the empty list ()
>> (eq nil '()) ;=> t
>
> Got it. The `nil' shown in my example just means the empty result list
> (). The `nil' in itself can be used in different context, when it's
> used as boolean variable, it means false. But it can also be used to
> represent an empty list ().

Yes, see also (info "(elisp) nil and t"):

https://www.gnu.org/software/emacs/manual//html_node/elisp/nil-and-t.html

Just be careful not to follow Tassilo's correct example too literally in
real code, as passing a quoted list literal such as '(1 2 3) to delq can
lead to unexpected side-effects.  In practice you should use delq only
when you know for certain that the list is safe to modify, and otherwise
use remq instead.  See (info "(elisp) Self-Evaluating Forms") and
(info "(elisp) Mutability"):

https://www.gnu.org/software/emacs/manual/html_node/elisp/Self_002dEvaluating-Forms.html
https://www.gnu.org/software/emacs/manual/html_node/elisp/Mutability.html

HTH,

-- 
Basil

Reply via email to