From 4d178f768707a6ee3e75b838a71c8b5bb978ad1a Mon Sep 17 00:00:00 2001 From: sakurawald Date: Wed, 4 Dec 2024 08:26:45 +0800 Subject: [PATCH 1/2] add: the `:jumps` ex-command for vi-mode. --- extensions/vi-mode/commands.lisp | 6 ++++++ extensions/vi-mode/ex-command.lisp | 16 ++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/extensions/vi-mode/commands.lisp b/extensions/vi-mode/commands.lisp index b6d86e8f7..d3220c4e5 100644 --- a/extensions/vi-mode/commands.lisp +++ b/extensions/vi-mode/commands.lisp @@ -123,6 +123,7 @@ :vi-append-line :vi-open-below :vi-open-above + :vi-jumps :vi-jump-back :vi-jump-next :vi-a-word @@ -1015,6 +1016,11 @@ on the same line or at eol if there are none." (line-start p)))))) (move-to-column (current-point) column t))) +(define-command vi-jumps () () + (line-end (current-point)) + (lem:message (with-output-to-string (s) + (lem-vi-mode/jumplist::print-jumplist (current-jumplist) s)))) + (define-command vi-jump-back (&optional (n 1)) (:universal) (dotimes (i n) (jump-back))) diff --git a/extensions/vi-mode/ex-command.lisp b/extensions/vi-mode/ex-command.lisp index 591bed79a..a93deb6cb 100644 --- a/extensions/vi-mode/ex-command.lisp +++ b/extensions/vi-mode/ex-command.lisp @@ -67,12 +67,12 @@ (ex-write range filename t))) (define-ex-command "^bn$" (range argument) - (declare (ignore range argument)) - (lem:next-buffer)) + (declare (ignore range argument)) + (lem:next-buffer)) (define-ex-command "^bp$" (range argument) - (declare (ignore range argument)) - (lem:previous-buffer)) + (declare (ignore range argument)) + (lem:previous-buffer)) (define-ex-command "^wq$" (range filename) (ex-write-quit range filename nil t)) @@ -190,8 +190,8 @@ (declare (ignore range)) (lem:pipe-command (format nil "~A ~A" - (subseq lem-vi-mode/ex-core:*command* 1) - command))) + (subseq lem-vi-mode/ex-core:*command* 1) + command))) (define-ex-command "^(buffers|ls|files)$" (range argument) (declare (ignore range argument)) @@ -259,3 +259,7 @@ (define-ex-command "^pwd?$" (range argument) (declare (ignore range argument)) (lem:current-directory)) + +(define-ex-command "^jumps?$" (range argument) + (declare (ignore range argument)) + (lem-vi-mode/commands:vi-jumps)) From bec9056e1217f8c18066cafc2132f54a0b45f0ba Mon Sep 17 00:00:00 2001 From: sakurawald Date: Wed, 4 Dec 2024 09:43:40 +0800 Subject: [PATCH 2/2] fix: the `:jumps` should use `message-buffer`, to avoid the `timeout` of `popup message` error, if the mouse focus is on the window. --- extensions/vi-mode/commands.lisp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/extensions/vi-mode/commands.lisp b/extensions/vi-mode/commands.lisp index d3220c4e5..616144186 100644 --- a/extensions/vi-mode/commands.lisp +++ b/extensions/vi-mode/commands.lisp @@ -403,10 +403,10 @@ Move the cursor to the first non-blank character of the line." (max 0 (min (1- (length (line-string (current-point)))) pos)))) (:block - (move-to-line (current-point) (min (line-number-at-point start) - (line-number-at-point end))) - (move-to-column (current-point) (min column-start - column-end)))) + (move-to-line (current-point) (min (line-number-at-point start) + (line-number-at-point end))) + (move-to-column (current-point) (min column-start + column-end)))) ;; After 'dw' or 'dW', move to the first non-blank char (when (and (this-motion-command) (member (command-name (this-motion-command)) @@ -507,10 +507,10 @@ Move the cursor to the first non-blank character of the line." (yank-region start end :type type) (case type (:block - (move-to-line (current-point) (min (line-number-at-point start) - (line-number-at-point end))) - (move-to-column (current-point) (min (point-column start) - (point-column end)))) + (move-to-line (current-point) (min (line-number-at-point start) + (line-number-at-point end))) + (move-to-column (current-point) (min (point-column start) + (point-column end)))) (:line (move-to-column start (point-charpos (current-point))) (move-point (current-point) start)) @@ -798,9 +798,9 @@ on the same line or at eol if there are none." (move-point point p))) (lambda (point regex &optional limit-point) (lem/isearch::search-forward-regexp - point - (ignore-errors (ppcre:create-scanner regex :case-insensitive-mode case-insensitive)) - limit-point)) + point + (ignore-errors (ppcre:create-scanner regex :case-insensitive-mode case-insensitive)) + limit-point)) (lambda (point regex &optional limit-point) (lem/isearch::search-backward-regexp point @@ -925,7 +925,7 @@ on the same line or at eol if there are none." (string c) limit) unless result - do (return nil) + do (return nil) finally (return t)) (character-offset p offset) (move-point (current-point) p))))) @@ -1018,8 +1018,8 @@ on the same line or at eol if there are none." (define-command vi-jumps () () (line-end (current-point)) - (lem:message (with-output-to-string (s) - (lem-vi-mode/jumplist::print-jumplist (current-jumplist) s)))) + (lem:message-buffer (with-output-to-string (s) + (lem-vi-mode/jumplist::print-jumplist (current-jumplist) s)))) (define-command vi-jump-back (&optional (n 1)) (:universal) (dotimes (i n)