[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/crux e3c9714 055/112: Make crux-move-beginning-of-line fun
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/crux e3c9714 055/112: Make crux-move-beginning-of-line function mode aware (#45) |
Date: |
Wed, 11 Aug 2021 09:57:52 -0400 (EDT) |
branch: elpa/crux
commit e3c9714d01b884d3e9b34ed6f008c0b86bdcb7f8
Author: KarlFish <KarlFish@users.noreply.github.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>
Make crux-move-beginning-of-line function mode aware (#45)
This fixes https://github.com/bbatsov/prelude/issues/998
---
crux.el | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/crux.el b/crux.el
index 8050cdf..1eef379 100644
--- a/crux.el
+++ b/crux.el
@@ -156,7 +156,7 @@ Position the cursor at its beginning, according to the
current mode."
(if electric-indent-inhibit
;; We can't use `indent-according-to-mode' in languages like Python,
;; as there are multiple possible indentations with different meanings.
- (let* ((indent-end (progn (back-to-indentation) (point)))
+ (let* ((indent-end (progn (move-to-mode-line-start) (point)))
(indent-start (progn (move-beginning-of-line nil) (point)))
(indent-chars (buffer-substring indent-start indent-end)))
(forward-line -1)
@@ -203,7 +203,7 @@ With a prefix ARG open line above the current line."
Passes ARG to command `kill-whole-line' when provided."
(interactive "p")
(kill-whole-line arg)
- (back-to-indentation))
+ (move-to-mode-line-start))
(defun crux-kill-line-backwards ()
"Kill line backwards and adjust the indentation."
@@ -211,6 +211,29 @@ Passes ARG to command `kill-whole-line' when provided."
(kill-line 0)
(indent-according-to-mode))
+(defvar crux-line-start-regex-term-mode "^[^#$%>\n]*[#$%>] "
+ "Match terminal prompts.
+
+Used by crux functions like crux-move-beginning-of-line to skip over the
prompt")
+
+(defvar crux-line-start-regex-eshell-mode "^[^$\n]*$ " "Match eshell prompt.
+
+Used by crux functions like crux-move-beginning-of-line to skip over the
prompt")
+
+(defvar crux-line-start-regex "^[[:space:]]*" "Match whitespace in from of
line.
+
+Used by crux functions like crux-move-beginning-of-line to skip over
whitespace")
+
+(defun move-to-mode-line-start ()
+ "Move to the beginning, skipping mode specific line start regex."
+ (interactive)
+ (move-beginning-of-line nil)
+ (let ((line-start-regex (cond ((eq major-mode 'term-mode)
crux-line-start-regex-term-mode)
+ ((eq major-mode 'eshell-mode)
crux-line-start-regex-eshell-mode)
+ (t crux-line-start-regex))))
+ (search-forward-regexp line-start-regex)))
+
+
(defun crux-move-beginning-of-line (arg)
"Move point back to indentation of beginning of line.
@@ -230,7 +253,7 @@ point reaches the beginning or end of the buffer, stop
there."
(forward-line (1- arg))))
(let ((orig-point (point)))
- (back-to-indentation)
+ (move-to-mode-line-start)
(when (= orig-point (point))
(move-beginning-of-line 1))))
- [nongnu] elpa/crux 5a7201a 062/112: Fix a docstring, (continued)
- [nongnu] elpa/crux 5a7201a 062/112: Fix a docstring, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 32baf6a 064/112: Bump the development version, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux a71669e 033/112: Merge pull request #17 from jiegec/master, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux cf547b7 037/112: Typo Fix: Missed an s in transpose, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux a6e0a52 043/112: Define a minor mode for crux-reopen-as-root (#28), ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 2cdf266 069/112: Insert literal s-exp instead of printing in crux-eval-and-replace (#50), ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 2b4bf62 074/112: Give crux group to crux-reopen-as-root-mode, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 772123a 081/112: Support using any shell creating function with crux-visit-term-buffer, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux b401f45 050/112: [Fix #35] Replace a deprecated function, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux ad42bcf 053/112: Support make `crux-cleanup-buffer-or-region` support makefiles, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux e3c9714 055/112: Make crux-move-beginning-of-line function mode aware (#45),
ELPA Syncer <=
- [nongnu] elpa/crux 1e591c5 031/112: Merge pull request #16 from jiegec/master, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux ca62859 038/112: Merge pull request #22 from dgtized/fix-tranpose-typo, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux fde9d4b 044/112: Fix malformed header line, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 5b3c815 047/112: Release 0.3, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 3e03d72 049/112: Don't use dash.el function (#34), ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux b60d9f4 051/112: Fix a compilation warning, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 54cc9b8 056/112: Fix typo in crux-top-join-line, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 11096b9 058/112: Fix typo in keybindings (#47), ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux cedec52 063/112: Mark crux-recentf-ido-find-file as obsolete, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 66954bf 022/112: Mention crux-indent-defun, ELPA Syncer, 2021/08/11