* Non-matching string failing alist search
@ 2022-08-21 23:38 uzibalqa
2022-08-22 14:26 ` [External] : " Drew Adams
0 siblings, 1 reply; 2+ messages in thread
From: uzibalqa @ 2022-08-21 23:38 UTC (permalink / raw)
To: uzibalqa via Users list for the GNU Emacs text editor
I am adding to a list `scrip' but when `word' is not present in the `car' values
of `alist-t1' I get an error.
Debugger entered--Lisp error:
(void-function nil) nil(#("yoor" 0 5 (fontified t)))
replace-regexp-in-string(#("yoor" 0 5 (fontified t)) nil #("yoor" 0 5 (fontified t)))
(add-to-list 'nscrip
What can I do in the case that the string passed to word does not exist in `alist-t1'?
(defconst alist-t1 '( ("year" . "2022") ))
(add-to-list 'nscrip
(replace-regexp-in-string
word (cdr (assoc word alist-t1))
word))
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [External] : Non-matching string failing alist search
2022-08-21 23:38 Non-matching string failing alist search uzibalqa
@ 2022-08-22 14:26 ` Drew Adams
0 siblings, 0 replies; 2+ messages in thread
From: Drew Adams @ 2022-08-22 14:26 UTC (permalink / raw)
To: uzibalqa, uzibalqa via Users list for the GNU Emacs text editor
> What can I do in the case that the string passed
> to word does not exist in `alist-t1'?
>
> (add-to-list
> 'nscrip
> (replace-regexp-in-string
> word (cdr (assoc word alist-t1)) word))
Do nothing? (Depends what _you_ want to do.)
(let ((x (assoc word alist-t1)))
(when x
(add-to-list
'nscrip
(replace-regexp-in-string word (cdr x) word))))
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-22 14:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-21 23:38 Non-matching string failing alist search uzibalqa
2022-08-22 14:26 ` [External] : " Drew Adams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).