Solution proposed by @T.Verron works, nevertheless sadly
singular-interactive-mode do not use
comint. So, here I propose another solution following @lawist suggestion. This code produces a function
brust-math-software-hookfun-to-intangify-prompt, which adds buffer-locally a function to
after-change-functions which properly properties the prompt accordingly to the list
You only need to add such a function to the hook of your mode.
And to add new languages you just need to update the list of buffers-prompts.
'(("*julia*" . "^julia>")
("*singular*" . "^>"))
"List of cons with buffer names runing some math software and a regex for its promp string")
(defun brust-math-software-intangify-buffer-text (-regexp beg end)
"Set cursor-intangible property to all buffer text maching regular expresion `-regexp` between `beg` and `end`"
(while (re-search-forward -regexp end t)
(add-text-properties (1- (match-beginning 0)) (match-end 0) '(cursor-intangible t rear-nonsticky nil))))))
(defun brust-math-software-intangify-cursor-on-prompt (beg end length)
"Set cursor-intangible in math software buffers prompts"
(let ((-prompt (cdr (assoc (buffer-name) brust-math-software-buffers-prompts))))
(brust-math-software-intangify-buffer-text -prompt beg end))))
(defun brust-math-software-hookfun-to-intangify-prompt nil
(add-hook 'after-change-functions #'brust-math-software-intangify-cursor-on-prompt nil t))
I have no idea why, but there is some incompatibility between properties
So, the lines 2113--2124 from @T.Verron answer would be:
(add-text-properties prompt-start (point)
'(cursor-intangible t rear-nonsticky nil read-only t front-sticky (read-only)))))