Skip to main content
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,...
phils's user avatar
  • 52.4k
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.
Stefan's user avatar
  • 26.6k
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 ...
phils's user avatar
  • 52.4k
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 ...
sds's user avatar
  • 6,174
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 ...
Drew's user avatar
  • 78.5k
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 ...
Basil's user avatar
  • 12.5k
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 ...
Drew's user avatar
  • 78.5k
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) (...
gavenkoa's user avatar
  • 3,502
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-...
Drew's user avatar
  • 78.5k
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 ...
Drew's user avatar
  • 78.5k
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" . "/...
db48x's user avatar
  • 18.8k
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.
Drew's user avatar
  • 78.5k
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 ...
Toothrot's user avatar
  • 3,284
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 ...
wvxvw's user avatar
  • 11.4k
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 ...
ate's user avatar
  • 214

Only top scored, non community-wiki answers of a minimum length are eligible