all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Seaching non-existent word in alist gives error
@ 2022-08-21 15:17 uzibalqa
  0 siblings, 0 replies; only message in thread
From: uzibalqa @ 2022-08-21 15:17 UTC (permalink / raw)
  To: uzibalqa via Users list for the GNU Emacs text editor

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))))



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-21 15:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-21 15:17 Seaching non-existent word in alist gives error uzibalqa

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.