Is there a build-in variable which saves the current character at which the cursor is positioned on?
1 Answer
You can use the char-after
or following-char
function to know what's the character under the cursor (or after the point).
More on Examing Text Under Point
Remember that point is always between characters, and the cursor normally appears over the character following point.
-
Based on your suggestion I wrote a function to determine if the current character is "i" or not but it doesn't work. (defun test-i () (interactive) ;; Check whether the current character is "i" or not. (if (equal (char-after) 'i) (message "yes" )(message "no") ) )– NameCommented Jan 25, 2015 at 15:09
-
1
'i
means symbol i. What you need is?i
which returns the decimal ASCII value of the character 'i'. Commented Jan 25, 2015 at 15:26 -
1Here's what I found on learning about elisp symbols from a quick google search: stackoverflow.com/a/1780984/1219634 Commented Jan 25, 2015 at 15:30
-
1On a side note, I prefer using the
looking-at
function that checks if the current character matches my provided regexp. Here is an example of how I use this function to check if the current character is a space character or a comment-start character: emacs.stackexchange.com/q/7519/115 For you example use case you can do(looking-at "i")
. Commented Jan 25, 2015 at 15:47 -
*Correction:
looking-at
checks regexp match with current character onwards. Commented Jan 25, 2015 at 16:26