Sentence movement functions use the regexp returned by the (sentence-end)
function to find the end of a sentence. The (sentence-end)
function returns the value of the sentence-end
variable if it is not nil. (The function and variable share the same name).
You can modify the value of the sentence-end
variable to any regexp you want. In order to maintain all other functionallity provided by the defaults for sentence movement, I recommend you set the value of sentence-end
to be a regexp matching either ♥ or the default return value of the (sentence-end)
function.
Below is a function that sets the local value of the sentence-end
variable as described.
(defun my-setup-sentence-end ()
"Modify the local value of the `sentence-end'
variable to be a regexp matching either ♥ or the default
regexp returned by the `sentence-end' function."
(setq-local
sentence-end
(rx (or "♥" (eval (let ((sentence-end nil)) (sentence-end)))))))
Once you have this function you can add it as a hook to any mode you would like.
;; For example, you can add this behavior to `text-mode' like so
(add-hook 'text-mode-hook 'my-setup-sentence-end)
Now you can use (forward-sentence)
, (backward-sentence)
and other text movemnt functions to navigate to ♥ characters. This regexp may not fit your exact use case, but should provide the basic understanding for you to create your own.
Take a look at the paragraph.el source file for more information about the modification of sentence-end
.
.
in the NEWENTRY argument?C-u C-x =
it says that the syntax is "punctuation", so the code works. It's not clear why the OP thinks that there is a problem.C-x C-x =
, which was one of the troubleshooting features I was fishing for by posting this question, but I also get "punctuation" so I don't know why it doesn't seem to be recognized as such.