bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#60666: 30.0.50; [PATCH] Use field properties in Eshell buffers


From: Jim Porter
Subject: bug#60666: 30.0.50; [PATCH] Use field properties in Eshell buffers
Date: Tue, 10 Jan 2023 12:51:14 -0800

On 1/10/2023 12:11 PM, Eli Zaretskii wrote:
That's not what I see in Emacs 29.  C-a moves to the beginning of
input, i.e. it stops at the end of the prompt, whereas HOME goes all
the way to the beginning of screen line, including the prompt.

"C-h c" says that C-a is bound to eshell-bol, but HOME is bound to
move-beginning-of-line.

I'm asking why not let users have this distinction after your change,
with some easy customization?

It sounds like we agree but we're looking at this from different directions. Since my patch adds the 'field' property, a user can't just use 'move-beginning-of-line' to go to the very beginning of the line (instead, it stops at the end of the prompt, where the field property ends).

I agree that an easy customization to restore the old behavior would be nice. The old behavior has been around a long time, so I'm sure some people have come to rely on it.

One option would be to add a new function like 'eshell-really-bol' (with a better name, of course), that calls 'move-beginning-of-line' and ignores fields, like the function I suggested in the NEWS entry. This function wouldn't be used anywhere by default, but it makes it easy for users to restore the behavior. This is probably the simplest, most direct way.

Another option might be to enhance 'move-beginning-of-line'. Maybe we could add an option so that calling it the first time obeys field boundaries, but if you immediately call it again, it ignores them. Then, a user who wants to go to the real beginning of a line can just press <home> (or C-a) twice. That's not exactly the same as the old behavior, but it would be usable outside of Eshell, and it's pretty close to maintaining muscle memory: you just need to press the same key again. Something like this might be sufficient, if we add a defcustom to toggle this behavior:

----------------------------------------

diff --git a/lisp/simple.el b/lisp/simple.el
index 690968ca938..803c5ee07e4 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -8174,6 +8174,9 @@ move-beginning-of-line
         (goto-char (previous-char-property-change (point)))
         (goto-char (line-beginning-position))))

+    (let ((inhibit-field-text-motion
+           (if (eq last-command #'move-beginning-of-line)
+               t inhibit-field-text-motion)))
     ;; Now find first visible char in the line.
     (while (and (< (point) orig) (invisible-p (point)))
       (goto-char (next-char-property-change (point) orig)))
@@ -8189,7 +8192,7 @@ move-beginning-of-line
                 ;; Otherwise, move to START with attention to fields.
                 ;; (It is possible that fields never matter in this case.)
                 (constrain-to-field (point) orig
-                                    (/= arg 1) t nil)))))
+                                    (/= arg 1) t nil))))))


 ;; Many people have said they rarely use this feature, and often type

----------------------------------------

The above is something I've occasionally wished for in other places. As a workaround, I usually press "C-a C-b C-a" (or "<home> <left> <home>"), but being able to press "C-a C-a" (or "<home> <home>") would be easier, and probably more robust.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]