Questions tagged [boolean]
7 questions
24
votes
3 answers
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 should I choose?
I have seen all of these variations…

greduan
- 343
- 2
- 6
10
votes
3 answers
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 logical operators in and, or, not (null) and…

ebpa
- 7,319
- 26
- 53
9
votes
3 answers
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 (not lists or alists). I don't know if that can be…

Kaushal Modi
- 25,203
- 3
- 74
- 179
8
votes
2 answers
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 the difference and should I prefer one form over…

clemera
- 3,401
- 13
- 40
4
votes
2 answers
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 elisp, but it does not take a list of booleans as an…

Linus Arver
- 152
- 1
- 6
0
votes
2 answers
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 (&optional name)
"DOCSTRING"
(if name
…

Dilna
- 1,173
- 3
- 10
0
votes
1 answer
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-match-p "^\\s-*$" (thing-at-point 'line)))
…

smilingbuddha
- 1,131
- 10
- 26