I would like to write a custom elisp function that searches for a few variants of unicode text under a cursor and highlights their occurrences in the currently open file.
For e.g. if my text is helloम्
(it ends with bytes U2350+U2381
) the function should search a modified version of the text helloं
(i.e. hello+U2306
) The unicode bytes are always at the end of the word.
I started with a simple elisp function that would print a message if a text that matches my criteria is found and saving the modified string to be searched into a variable:
(defun c-search ()
"If word under cursor ends with U2350+U2381, search for word+U2306"
(interactive)
(if (string-match-p "म्" (thing-at-point 'word))
(setq z (replace-regexp-in-string "म्$" "ं" (thing-at-point 'word)))
(message "Should search %s" z)))
Nothing gets printed when I evaluate this function. However, the following function that searches and replaces the string works fine:
(defun rrx ()
(interactive)
(setq z (replace-regexp-in-string "म्$" "ं" (thing-at-point 'word)))
(message z))
How can I fix function c-search
to perform a search for the string saved in variable z
?