Skip to content
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

Beginning line function #45

Merged
merged 5 commits into from Jun 26, 2017
Merged

Beginning line function #45

merged 5 commits into from Jun 26, 2017

Conversation

ghost
Copy link

@ghost ghost commented Jun 24, 2017

Defines crux-smart-line-start, a new function to replace back-to-indentation.

back-to-indentation moves the point to the first non-whitespace character. The new function does that for all major modes, except ansi-term and eshell, where it moves to end of the prompt. More major modes can be added.

By fixing this function, crux-move-beginning-of-line is improved. Prelude issue #998 "C-a broken in eshell" is fixed. There were workarounds posted in that thread, but I thought a better solution was available.

Defines crux-smart-line-start to replace back-to-indentation.

back-to-indentation moves the point to the first non-whitespace
character. The new function does that for all major modes, except
ansiterm and eshell, where it moves to end of the prompt. More major
modes can be added.

By fixing this function, crux-move-beginning-of-line is
improved. prelude issue #998 "C-a broken in eshell" is fixed [1].

[1] - bbatsov/prelude#998
@ghost ghost mentioned this pull request Jun 24, 2017
crux.el Outdated
"Regex to match pre-line text.
Matches whitespace in nearly all major modes. Matches the terminal prompts
in 'ansi-term' and 'eshell.")
(add-hook 'term-mode-hook (lambda () (setq crux-smart-line-start-regex "^[^#$%>\n]*[#$%>] " )))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me it'd be better if those were separate vars/constants and you added a check inside the function for the current mode. Btw, keep in mind that for your variable solution to work this variable has to be buffer-local, not global like it is now.

Remove variable crux-smart-line-start-regex.

Add function that skips line beginning depending on mode.
@ghost
Copy link
Author

ghost commented Jun 25, 2017

I was basing my code off of the emacs function term-bol. It uses term-prompt-regexp to skip forward past the prompt. I couldn't figure out how to override C-a only in specific modes though.

I like allowing the user to configure what move-to-mode-line-start skips because the regex can't match everything.

Right now the term-mode regex matches repl prompts like ghci and nodejs, but not python's ">>> ".

Custom emacs repl buffers can make C-a do the right thing without this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants