I want a function that can take a utf hexcode from the user, and use it to change the glasses-separator in glasses-mode. When I use completing-read using a list of hexcodes things for well and the separator uses the corresponding symbol associated with the hex code.
I also want the ability for the user to pass whatever hexcode he wants to use (not just being restricted to the list). I use read-string for the user input. The problem is that if a user enters \u21E8, the result is that for that CamelCase gets modified to the string Camel\u21E8Case rather than using the symbol associated with \u21E8 which is an arrow.
(defvar camelsens-actm nil)
(defun camelsens (hexcode)
"Splits CamelCase phrases using separator."
(interactive
(list
(let* ( (optn '("list" "code"))
(option (completing-read "Option: " optn nil t ""))
(cseq '("\u27A4" "\u25BA" "\u2192" "disable")) )
(pcase option
("list" (completing-read "Code: " cseq nil t "disable"))
("code" (read-string "Code: "))) )))
(pcase hexcode
("disable"
(glasses-mode 0)
(setq camelsens-actm nil))
(_
(unless camelsens-actm
(glasses-mode 1)
(setq camelsens-actm t))
(setq glasses-separator hexcode)
(glasses-set-overlay-properties))))
codevariable is supposed to have a string value and sometimes it is supposed to be a single character (those are different types in Emacs Lisp and need conversion). But you seem wedded to writing functions in a particular style that makes it difficult (if not impossible) to know what it is supposed to be in any particular invocation, so you end up having to reason about each case. If you cannot describe what your function does in a sentence or two (with no exceptions), you should rethink it.