Skip to content

Commit

Permalink
Optionally move visually in `move-to-mode-line-start'
Browse files Browse the repository at this point in the history
In some environments users expect crux's functions to respect visual lines. This
can now be configured through the `crux-should-move-visually' configurable
variable. If set to true, then `move-to-mode-line-start' will use take into
account visual lines. Otherwise (the default behavior), it will work as usual by
moving to the logical beginning of the line.

For functions like `crux-move-beginning-of-line', specifically, the user will
face the following situation when setting `crux-should-move-visually; to true:

1. If the user runs this function in the middle of a visual line, it will go to
   the beginning of said visual line.
2. If the user runs this function again, then it will go to the beginning of the
   real line.
3. If the user runs this function again, then it will go to the first non-space
   character of the line.

Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
  • Loading branch information
mssola committed Aug 3, 2020
1 parent bb5a133 commit e391262
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crux.el
Expand Up @@ -135,6 +135,12 @@ expected name of the shell buffer."
:type 'symbol
:group 'crux)

(defcustom crux-should-move-visually
nil
"Wheter moves should take visual lines into account or not."
:type 'boolean
:group 'crux)

(defun crux-ansi-term (buffer-name)
"Use ansi-term for `crux-visit-term-buffer'"
(ansi-term crux-shell buffer-name))
Expand Down Expand Up @@ -307,7 +313,11 @@ Deletes whitespace at join."
(defun move-to-mode-line-start ()
"Move to the beginning, skipping mode specific line start regex."
(interactive)
(move-beginning-of-line nil)

(if crux-should-move-visually
(beginning-of-visual-line nil)
(move-beginning-of-line nil))

(let ((line-start-regex (cdr (seq-find
(lambda (e) (derived-mode-p (car e)))
crux-line-start-regex-alist
Expand Down

0 comments on commit e391262

Please sign in to comment.