0

Say I have text:

This read only text ends here>*********************|

The This read only text ends here> is read only while the asterisks are are not. When the (move-to-read-only-end) is called, I want the cursor to move right after the >. Like this:

This read only text ends here>|*********************

How can the (move-to-read-only-end) be written?

EDIT: Adding comment here per advice,

"In eshell, the prompt is read only but when you write commands those are not. So, I want to be able to move at the end of the prompt and the start of the commands."

3
  • You first need to tell us what makes that text read-only. Is it that the buffer characters have text-property read-only? Or is there an overlay on those buffer positions that has overlay property read-only? – Drew Oct 14 '20 at 17:44
  • In eshell, the prompt is read only but when you write commands those are not. So, I want to be able to move at the end of the prompt and the start of the commands. Does that make sense? – scribe Oct 14 '20 at 18:46
  • OK, please specify that in your question. Comments can be deleted at any time. If you put your cursor within the prompt (e.g. using the mouse) and do C-u C-x = you'll see that it says that there is a read-only text property there (which answers my question to you). – Drew Oct 14 '20 at 22:11
1

Since you're asking about eshell specifically, you should be able to use the command eshell-bol, which is bound to C-a by default. It moves the cursor to the end of the prompt on the current line.

0

Maybe something like this:

(defun move-to-read-only-end ()
  "..."
  (interactive)
  (goto-char (or (next-single-property-change (point) 'read-only)
                 (line-end-position))))

Here, function next-single-property-change gives you the first position where property read-only changes its value. Or it gives you nil, in which case you go to the end of the line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.