Questions tagged [boolean]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
24 votes
3 answers
4k views

How to choose between nil and 0, or t and 1 when setting variables or enabling modes

I understand that nil, 0 and/or -1 are used for disabling some features and t, 1 and/or +1 are used for enabling some features. When assigning variables or enabling/disabling minor modes, which ...
  • 343
10 votes
3 answers
3k views

What Emacs Lisp boolean/logical convenience functions exist?

What boolean/logical convenience functions / macros are available for Emacs Lisp in either the core set of functions or external packages? I'm interested in just about anything other than the built-in ...
  • 7,004
9 votes
3 answers
2k views

Quick way to toggle a variable

It would be nice to have a quick way to toggle a variable. Here's something that I have in mind. Call a "toggle var" function. The completing-read should list only variables that have single values (...
  • 24.6k
8 votes
2 answers
633 views

Understanding elisp idiom(boolean values vs. quoted arguments)?

I have some basic questions about elisp. I often see something like (search-forward "something" nil 'noerror) And sometimes I see something like (search-forward "something" nil :noerror) What is ...
  • 3,311
4 votes
2 answers
127 views

How do I splat the arguments to the `or` function?

I would like to evaluate a list of booleans like (nil nil t) into a single boolean, such that if any element is true, then the expression evaluates to true. I first looked at the (or) function in ...
0 votes
1 answer
156 views

why does this function return integers instead of `t` or `nil`

Why does this function print non-zero integers on non-empty lines? ;; taken from https://emacs.stackexchange.com/a/16826/10896 (defun current-line-empty-p () (interactive) (setq answer (string-...
0 votes
2 answers
18 views

Checking optional function argument

If I have an optional function argument, how can I determine if name has been supplied. And if it has been supplied, how can I test its validity (not nil or not empty string). (defun myfunc (&...
  • 385