-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Line operations on lines with read-only segments (Eshell, wdired...) #852
Comments
It's a huge can of worms. I've started doing something along these lines for comint and it broke history in a non-obvious way, so I went back to using REPLs outside Emacs. A general solution seems impossible, the saner alternative is imitating what Emacs modes do in this case and allow to easily remap line changes to a mode-specific command. For example, |
What about implementing some mode specific commands then? I'd be happy to send a PR for wdired and Eshell. |
Eshell caters to that usecase by remapping |
I'm already mapping That does not cover everything though. It would be easy to define new operators from the old ones and just modify |
I don't see why Evil should specifically cater to this, so I'm closing this one. |
Relevant question: Why does this work out-of-the-box in IELM and not in eshell? In IELM, Evil commands like Is Evil doing something special for IELM? |
I figured out why IELM has the decency to put the Evil (by design rather than accident, I hope) respects Emacs fields. Eshell fails to mark its prompt as a field, but luckily we can fix that ourselves! For example, this is my setup (very minimal/plain prompt): (setq eshell-highlight-prompt nil)
(setq eshell-prompt-function (lambda ()
(propertize
(if (= (user-uid) 0) "# " "$ ")
'read-only t 'field 'prompt 'rear-nonsticky '(read-only field))))
(setq eshell-prompt-regexp "^[$#] ") (Note that the If you want to start from the default eshell prompt, just fixed to mark the prompt as a field, you can use this code instead of the above: (setq eshell-highlight-prompt nil)
(setq eshell-prompt-function (lambda ()
(propertize
(concat (abbreviate-file-name (eshell/pwd))
(if (= (user-uid) 0) " # " " $ "))
'read-only t
'font-lock-face 'eshell-prompt
'field 'prompt
'front-sticky '(font-lock-face read-only)
'rear-nonsticky '(font-lock-face read-only field)))) And with that, I suspect that every other buffer would become automatically similarly compatible with Evil out-of-the-box if its mode was patched/wrapped to properly annotate different fields as such. |
Issue type
Environment
Emacs version: 25.2
Operating System: Arch Linux
Evil version: 1.2.12
Evil installation type: MELPA
Graphical/Terminal: Graphical
Terminal multiplexer: n/a
Line operations (
cc
,dd
...) will fail if parts of the line are read-only. This is most noticeable with Eshell's prompt and wdired.The issue was mentioned in #603.
My proposal would be as follow: for every line operation, narrow the operation area to the segment under point. If the segment is not writable, then return an error.
Processing segments allows to handle lines like
where
=
is a read-only charater and_
is a writable character.Further notes
Going to insert mode on read-only areas does not make much sense, and comands such as
evil-insert-line
would greatly benefit from moving the point after the beginning of the read-only part. See Eshell for a good example: pressingI
on the command prompt should move to the point right after the prompt, not to the beginning of line.I am using the following fix at the moment:
What do you think?
The text was updated successfully, but these errors were encountered: