13
votes
Accepted
How to make (make-symbol "foo") (make-symbol "foo") equal?
Do i have a misconception of symbols? Aren't they just strings without double-quotes?
You do indeed have a misconception.
A symbol is a lisp object containing numerous properties (including its name,...
6
votes
How to make (make-symbol "foo") (make-symbol "foo") equal?
You're confusing make-symbol and intern. make-symbol is used specifically when you want such an equality not to hold.
6
votes
Accepted
Set difference for sets of strings
It is for the same reason that:
(eql "foo" "foo")
=> nil
Along with the other cl-lib sequence functions generally, set-difference (aka cl-set-difference) defaults to using eql for its equality ...
3
votes
Accepted
“(equal a b)⇒t” whereas “(equal b a)⇒error”
Great question!
Emacs detects the circularity of a and reports it before it descends far enough into b to discover that they are equal.
The reason for the asymmetry is that Emacs only has to check for ...
3
votes
Accepted
Strange behaviour involving `display` property
I think this is exactly answered by the doc in (elisp) Replacing Specs.
Consecutive text with the same display property is handled as a block, replacing it by the display property.
If a list of ...
3
votes
Accepted
setf + alist-get but with "equal" instead of "eq"?
Is it possible to alter equality predicate of setf in a a declarative way (without tons of elisp)?
See the docstring of alist-get:
alist-get is a compiled Lisp function in ‘subr.el’.
(alist-get KEY ...
2
votes
Why are there multiple ways to test for equality in elisp?
There can be any number of "equality" definitions or determinations or predicates, in any domain (including logic), though they don't always go by the name "equality".
Consider equivalence classes in ...
2
votes
setf + alist-get but with "equal" instead of "eq"?
After reading of emacs/27.1/lisp/emacs-lisp/gv.el:
(gv-define-expander alist-get
(lambda (do key alist &optional default remove testfn)
I came up with:
(let ((al (list (cons "a" 1) (...
2
votes
How to compare an item against others, that's compatible with string-equal?
Your code works fine, for me.
(when (member last-command (list 'foo 'bar 'bob 'baz)) (do-something))
First, last-command is typically a symbol, not a string. There is no reason to use string-...
2
votes
Accepted
Check if buffername is equal to file name
First, you don't want to test string-content equality using eq. Use equal instead. Or you can use string-equal, if you are sure that buffer-file-name will return a string in your context.
See the ...
1
vote
Accepted
If-clause on content of variable
You just need a function that compares strings to see if they are equal:
(setq org-agenda-files
(if (equal user-mail-address "[email protected]")
'(("100-23" . "/...
1
vote
Accepted
How to use markers as keys in a hash map?
I reported this problem to [email protected].
@Stefan Monnier replied that this seems to be fixed in the development version (master) for Emacs 29.
1
vote
Accepted
Function that returns the name of a Greek vowel
Based on comments,
(defun greek-vowel-name (c)
"Return the name of the Greek vowel character C as a symbol.
The same name is returned regardless of case and diacritics.
If the argument is not a ...
1
vote
Why are there multiple ways to test for equality in elisp?
Some of the predicates you list in your post are historical debt inherited by Emacs Lisp from Common Lisp. The reason those predicates existed in Common Lisp is mostly due to the Lisps which predated ...
1
vote
Accepted
Why are there multiple ways to test for equality in elisp?
We should take care to distinguish between equality
and identity. Equality of things exists within an algebraic context: as you point out, two numbers could be equal in the context of arithmetic, even ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
equality × 15string × 4
list × 2
symbols × 2
org-mode × 1
org-export × 1
elisp × 1
regular-expressions × 1
text-properties × 1
unicode × 1
sorting × 1
quote × 1
eval × 1
filenames × 1
hash-tables × 1
alists × 1
setf × 1
marker × 1