emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/crux 2e16b82 087/112: Rework `move-to-mode-line-start` to


From: ELPA Syncer
Subject: [nongnu] elpa/crux 2e16b82 087/112: Rework `move-to-mode-line-start` to add extensibility (#71)
Date: Wed, 11 Aug 2021 09:57:59 -0400 (EDT)

branch: elpa/crux
commit 2e16b828910c9b8acba37e712d21b517d2cf78cc
Author: Matthew Newton <matt@mnewton.com>
Commit: GitHub <noreply@github.com>

    Rework `move-to-mode-line-start` to add extensibility (#71)
---
 crux.el | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/crux.el b/crux.el
index 19ed53c..fa9259c 100644
--- a/crux.el
+++ b/crux.el
@@ -58,6 +58,23 @@
   :type 'list
   :group 'crux)
 
+(defcustom crux-line-start-regex-alist
+  '((term-mode . "^[^#$%>\n]*[#$%>] ")
+    (eshell-mode . "^[^$\n]*$ ")
+    (org-mode . "^\\(\*\\|[[:space:]]*\\)* ")
+    (default . "^[[:space:]]*"))
+  "Alist of major modes and line starts.
+
+The key is a major mode.  The value is a regular expression
+matching the characters to be skipped over.  If no major mode is
+found, use the regex specified by the default key.
+
+Used by crux functions like `crux-move-beginning-of-line' to skip
+over whitespace, prompts, and markup at the beginning of the line."
+  :type 'list
+  :group 'crux)
+
+
 (defcustom crux-shell (getenv "SHELL")
   "The default shell to run with `crux-ansi-term'."
   :type 'string
@@ -277,26 +294,14 @@ 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))))
+  (let ((line-start-regex (cdr (seq-find
+                                (lambda (e) (derived-mode-p (car e)))
+                                crux-line-start-regex-alist
+                                (assoc 'default 
crux-line-start-regex-alist)))))
     (search-forward-regexp line-start-regex (line-end-position) t)))
 
 ;;;###autoload



reply via email to

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