From: uzibalqa <uzibalqa@proton.me>
To: uzibalqa via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org>
Subject: Seaching non-existent word in alist gives error
Date: Sun, 21 Aug 2022 15:17:35 +0000 [thread overview]
Message-ID: <QQ3GvNT05qf6Jb8MSYT6kSiwOSoXO6Bv1CJwsG1oocUzgw3KM0-sn2jx7VBQ8WP08Gpn0cZlub0IwbGI3-2me5gAIJKwgGUDYWP9AJsMQ78=@proton.me> (raw)
I have the function `shorten-word' that is supposed to shorten a word by looking at `alist-tablet-1'.
But when the word at point does not exist, I get a Lisp error
(void-function nil) nil(#("owell" 0 5 (fontified t)))
replace-regexp-in-string(#("owell" 0 5 (fontified t)) nil #("owell" 0 5 (fontified t)))
(add-to-list 'nscrip
What can I do to solve this problem?
(defconst alist-tablet-1
'( ("all" . "l") ("as" . "as") ("can" . "k")
("do" . "do") ("for" . "f") ("in" . "n")
("is" . "s") ("it" . "t") ("know" . "no")
("like" . "lk") ("little" . "ll") ("more" . "mo")
("other" . "O") ("some" . "so") ("than" . "n")
("that" . "ta") ("there" . "tr") ("this" . "th")
("time" . "ti") ("to" . "to") ("we" . "w")
("well" . "l") ("will" . "l") ("work" . "wk")
("you" . "u") ))
(defun shorten-word ()
"Shorten word at point using alist-tablet-1."
(interactive)
(let* ( (bounds (bounds-of-thing-at-point 'word))
(word (buffer-substring (car bounds) (cdr bounds))) )
(goto-char (car bounds))
(add-to-list 'nscrip
(replace-regexp-in-string word (cdr (assoc word alist-tablet-1)) word))))
reply other threads:[~2022-08-21 15:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='QQ3GvNT05qf6Jb8MSYT6kSiwOSoXO6Bv1CJwsG1oocUzgw3KM0-sn2jx7VBQ8WP08Gpn0cZlub0IwbGI3-2me5gAIJKwgGUDYWP9AJsMQ78=@proton.me' \
--to=uzibalqa@proton.me \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.