@@ -468,6 +468,19 @@ This command supports `meow-selection-command-fallback'."
468
468
; ; (insert "\n"))
469
469
(indent-according-to-mode )))
470
470
471
+ (defun meow-open-above-visual ()
472
+ " Open a newline above and switch to INSERT state."
473
+ (interactive )
474
+ (if meow--temp-normal
475
+ (progn
476
+ (message " Quit temporary normal mode " )
477
+ (meow--switch-state 'motion ))
478
+ (meow--switch-state 'insert )
479
+ (goto-char (meow--visual-line-beginning-position))
480
+ (save-mark-and-excursion
481
+ (newline ))
482
+ (indent-according-to-mode )))
483
+
471
484
(defun meow-open-below ()
472
485
" Open a newline below and switch to INSERT state."
473
486
(interactive )
@@ -479,6 +492,17 @@ This command supports `meow-selection-command-fallback'."
479
492
(goto-char (line-end-position ))
480
493
(meow--execute-kbd-macro " RET" )))
481
494
495
+ (defun meow-open-below-visual ()
496
+ " Open a newline below and switch to INSERT state."
497
+ (interactive )
498
+ (if meow--temp-normal
499
+ (progn
500
+ (message " Quit temporary normal mode " )
501
+ (meow--switch-state 'motion ))
502
+ (meow--switch-state 'insert )
503
+ (goto-char (meow--visual-line-end-position))
504
+ (meow--execute-kbd-macro " RET" )))
505
+
482
506
(defun meow-change ()
483
507
" Kill current selection and switch to INSERT state.
484
508
@@ -944,6 +968,87 @@ This command will expand line selection."
944
968
(meow--select (> orig-p beg)))
945
969
(recenter )))
946
970
971
+ ; ; visual line versions
972
+ (defun meow--visual-line-beginning-position ()
973
+ (save-excursion
974
+ (beginning-of-visual-line )
975
+ (point )))
976
+
977
+ (defun meow--visual-line-end-position ()
978
+ (save-excursion
979
+ (end-of-visual-line )
980
+ (point )))
981
+
982
+ (defun meow--forward-visual-line-1 ()
983
+ (let ((orig (point )))
984
+ (line-move-visual 1 )
985
+ (if meow--expanding-p
986
+ (progn
987
+ (goto-char (meow--visual-line-end-position))
988
+ (meow--visual-line-end-position))
989
+ (when (< orig (meow--visual-line-beginning-position))
990
+ (meow--visual-line-beginning-position)))))
991
+
992
+ (defun meow--backward-visual-line-1 ()
993
+ (line-move-visual -1 )
994
+ (meow--visual-line-beginning-position))
995
+
996
+ (defun meow-visual-line (n &optional expand )
997
+ " Select the current visual line, eol is not included.
998
+
999
+ Create selection with type (expand . line).
1000
+ For the selection with type (expand . line), expand it by line.
1001
+ For the selection with other types, cancel it.
1002
+
1003
+ Prefix:
1004
+ numeric, repeat times.
1005
+ "
1006
+ (interactive " p" )
1007
+ (unless (or expand (equal '(expand . line) (meow--selection-type)))
1008
+ (meow--cancel-selection))
1009
+ (let* ((orig (mark t ))
1010
+ (n (if (meow--direction-backward-p)
1011
+ (- n)
1012
+ n))
1013
+ (forward (> n 0 )))
1014
+ (cond
1015
+ ((region-active-p )
1016
+ (let (p)
1017
+ (save-mark-and-excursion
1018
+ (line-move-visual n)
1019
+ (goto-char
1020
+ (if forward
1021
+ (setq p (meow--visual-line-end-position))
1022
+ (setq p (meow--visual-line-beginning-position)))))
1023
+ (thread-first
1024
+ (meow--make-selection '(expand . line) orig p expand)
1025
+ (meow--select))
1026
+ (meow--maybe-highlight-num-positions '(meow--backward-visual-line-1 . meow--forward-visual-line-1))))
1027
+ (t
1028
+ (let ((m (if forward
1029
+ (meow--visual-line-beginning-position)
1030
+ (meow--visual-line-end-position)))
1031
+ (p (save-mark-and-excursion
1032
+ (if forward
1033
+ (progn
1034
+ (line-move-visual (1- n))
1035
+ (meow--visual-line-end-position))
1036
+ (progn
1037
+ (line-move-visual (1+ n))
1038
+ (when (meow--empty-line-p)
1039
+ (backward-char 1 ))
1040
+ (meow--visual-line-beginning-position))))))
1041
+ (thread-first
1042
+ (meow--make-selection '(expand . line) m p expand)
1043
+ (meow--select))
1044
+ (meow--maybe-highlight-num-positions '(meow--backward-visual-line-1 . meow--forward-visual-line-1)))))))
1045
+
1046
+ (defun meow-visual-line-expand (n )
1047
+ " Like `meow-line' , but always expand."
1048
+ (interactive " p" )
1049
+ (meow-visual-line n t ))
1050
+
1051
+
947
1052
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
948
1053
; ;; BLOCK
949
1054
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
0 commit comments