diff options
| author | Axel Forsman <axelsfor@gmail.com> | 2023-07-12 19:40:46 +0200 |
|---|---|---|
| committer | Axel Forsman <axelsfor@gmail.com> | 2023-07-14 15:33:47 +0200 |
| commit | 4b45f2619258374ebb34b07212806e77bc2997c3 (patch) | |
| tree | 72a4afbb3a744b6b24169105eac7f010a7953791 | |
| parent | 633fa27fb13619f348a282d7f3be70c03a4ca701 (diff) | |
Format Normal mode "!" prompt as ".,.+N!"
| -rw-r--r-- | evil-commands.el | 95 | ||||
| -rw-r--r-- | evil-common.el | 26 | ||||
| -rw-r--r-- | evil-ex.el | 7 | ||||
| -rw-r--r-- | evil-states.el | 21 |
4 files changed, 64 insertions, 85 deletions
diff --git a/evil-commands.el b/evil-commands.el index 0924885..fb8263b 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -577,24 +577,24 @@ and jump to the corresponding one." (evil-next-flyspell-error (- (or count 1)))) (evil-define-motion evil-previous-open-paren (count) - "Go to [count] previous unmatched '('." + "Go to COUNT previous unmatched \"(\"." :type exclusive (evil-up-paren ?\( ?\) (- (or count 1)))) (evil-define-motion evil-next-close-paren (count) - "Go to [count] next unmatched ')'." + "Go to COUNT next unmatched \")\"." :type exclusive (forward-char) (evil-up-paren ?\( ?\) (or count 1)) (backward-char)) (evil-define-motion evil-previous-open-brace (count) - "Go to [count] previous unmatched '{'." + "Go to COUNT previous unmatched \"{\"." :type exclusive (evil-up-paren ?{ ?} (- (or count 1)))) (evil-define-motion evil-next-close-brace (count) - "Go to [count] next unmatched '}'." + "Go to COUNT next unmatched \"}\"." :type exclusive (forward-char) (evil-up-paren ?{ ?} (or count 1)) @@ -631,7 +631,7 @@ Loop back to the top of buffer if the end is reached." (goto-char (marker-position (cdar descending-markers))))))))) (evil-define-motion evil-next-mark (count) - "Go to [count] next lowercase mark." + "Go to COUNT next lowercase mark." :keep-visual t :repeat nil :type exclusive @@ -640,7 +640,7 @@ Loop back to the top of buffer if the end is reached." (evil--next-mark t))) (evil-define-motion evil-next-mark-line (count) - "Go to [count] line of next lowercase mark after current line." + "Go to COUNT line of next lowercase mark after current line." :keep-visual t :repeat nil :type exclusive @@ -653,7 +653,7 @@ Loop back to the top of buffer if the end is reached." (user-error "No marks in this buffer"))) (evil-define-motion evil-previous-mark (count) - "Go to [count] previous lowercase mark." + "Go to COUNT previous lowercase mark." :keep-visual t :repeat nil :type exclusive @@ -662,7 +662,7 @@ Loop back to the top of buffer if the end is reached." (evil--next-mark nil))) (evil-define-motion evil-previous-mark-line (count) - "Go to [count] line of previous lowercase mark before current line." + "Go to COUNT line of previous lowercase mark before current line." :keep-visual t :repeat nil :type exclusive @@ -1719,7 +1719,7 @@ of the block." (forward-line -1))) (evil-define-command evil-move (beg end address) - "Move lines in BEG END below line given by ADDRESS." + "Move lines in BEG .. END below the line given by ADDRESS." :motion evil-line-or-visual-line (interactive "<r><addr>") (unless (= (1+ address) (line-number-at-pos beg)) @@ -1849,25 +1849,19 @@ but doesn't insert or remove any spaces." (evil-define-operator evil-ex-join (beg end &optional count bang) "Join the selected lines with optional COUNT and BANG." (interactive "<r><a><!>") - (if (and count (not (string-match-p "^[1-9][0-9]*$" count))) - (user-error "Invalid count") - (let ((join-fn (if bang 'evil-join-whitespace 'evil-join))) - (cond - ((not count) + (let ((join-fn (if bang 'evil-join-whitespace 'evil-join))) + (if (not count) ;; without count - just join the given region - (funcall join-fn beg end)) - (t - ;; emulate vim's :join when count is given - start from the - ;; end of the region and join COUNT lines from there - (let* ((count-num (string-to-number count)) - (beg-adjusted (save-excursion - (goto-char end) - (forward-line -1) - (point))) - (end-adjusted (save-excursion - (goto-char end) - (line-beginning-position count-num)))) - (funcall join-fn beg-adjusted end-adjusted))))))) + (funcall join-fn beg end) + (unless (string-match-p "^[1-9][0-9]*$" count) + (user-error "Invalid count")) + ;; emulate Vim's :join when count is given - start from the + ;; end of the region and join COUNT lines from there + (save-excursion + (goto-char end) + (let ((beg-adjusted (line-beginning-position 0)) + (end-adjusted (line-beginning-position (string-to-number count)))) + (funcall join-fn beg-adjusted end-adjusted)))))) (defun evil--ex-string-for-print (beg end linump borderline) "Return a string to be printed by :print etc. @@ -2724,7 +2718,7 @@ lines. This is the default behaviour for Visual-state insertion." (current-column) vcount)) evil-insert-skip-empty-lines skip-empty-lines) - (evil-insert-state 1))) + (evil-insert-state))) (defun evil-append (count &optional vcount skip-empty-lines) "Switch to Insert state just after point. @@ -2814,7 +2808,7 @@ The insertion will be repeated COUNT times." (unwind-protect (when evil-auto-indent (indent-according-to-mode)) - (evil-insert-state 1))) + (evil-insert-state))) (evil-define-command evil-open-below (count) "Insert a new line below point and switch to Insert state. @@ -2831,7 +2825,7 @@ The insertion will be repeated COUNT times." (unwind-protect (when evil-auto-indent (indent-according-to-mode)) - (evil-insert-state 1))) + (evil-insert-state))) (defun evil--insert-line (count vcount non-blank-p) "Switch to insert state at the beginning of the current line. @@ -2860,7 +2854,7 @@ in the next VCOUNT - 1 lines below the current one." (list (line-number-at-pos) (if non-blank-p #'evil-first-non-blank #'evil-beginning-of-line) vcount))) - (evil-insert-state 1)) + (evil-insert-state)) (defun evil-insert-line (count &optional vcount) "Switch to insert state at beginning of current line. @@ -2898,7 +2892,7 @@ next VCOUNT - 1 lines below the current one." (list (line-number-at-pos) #'end-of-line vcount))) - (evil-insert-state 1)) + (evil-insert-state)) (evil-define-command evil-insert-digraph (count) "Insert COUNT digraphs." @@ -3562,25 +3556,13 @@ output is displayed in its own buffer. If PREVIOUS is non-nil, the previous shell command is executed instead." (interactive "<R><sh><!>") (if (not (evil-ex-p)) - (let ((evil-ex-initial-input - (if (and beg - (not (evil-visual-state-p)) - (not current-prefix-arg)) - (let ((range (evil-range beg end type))) - (evil-contract-range range) - ;; TODO: this is not exactly the same as Vim, which - ;; uses .,+count as range. However, this is easier - ;; to achieve with the current implementation and - ;; the very inconvenient range interface. - ;; - ;; TODO: the range interface really needs some - ;; rework! - (format - "%d,%d!" - (line-number-at-pos (evil-range-beginning range)) - (line-number-at-pos (evil-range-end range)))) - "!"))) - (call-interactively 'evil-ex)) + (let ((current-prefix-arg + (if (or current-prefix-arg (evil-visual-state-p)) + current-prefix-arg + (goto-char (min beg end)) + (setq current-prefix-arg (count-lines beg end)))) + (evil-ex-initial-input "!")) + (call-interactively #'evil-ex)) (when command (setq command (evil-ex-replace-special-filenames command))) (if (zerop (length command)) @@ -3588,8 +3570,7 @@ the previous shell command is executed instead." (setq evil-previous-shell-command command)) (cond ((zerop (length command)) - (if previous (user-error "No previous shell command") - (user-error "No shell command"))) + (user-error "No%s shell command" (if previous " previous" ""))) (evil-ex-range (if (not evil-display-shell-error-in-message) (shell-command-on-region beg end command nil t) @@ -3608,8 +3589,7 @@ the previous shell command is executed instead." (display-message-or-buffer error-buffer)) (kill-buffer output-buffer) (kill-buffer error-buffer))))) - (t - (shell-command command))))) + (t (shell-command command))))) (evil-define-command evil-make (arg) "Call a build command in the current directory. @@ -3948,8 +3928,9 @@ reveal.el. OPEN-SPOTS is a local version of `reveal-open-spots'." (defun evil--ex-substitute-final-message (nreplaced flags) "Display message according to replacements and flags. -If FLAGS contains `p' or `#' and NREPLACED is more than 0, print the last line -to the echo area. Otherwise, print the number of replacements made or found." +If FLAGS contains \"p\" or \"#\" and NREPLACED is more than 0, print +the last line to the echo area. Otherwise, print the number of +replacements made or found." (let ((replaced-any (< 0 nreplaced))) (cond ((and replaced-any (memq ?p flags)) diff --git a/evil-common.el b/evil-common.el index 145d12a..7e6b568 100644 --- a/evil-common.el +++ b/evil-common.el @@ -2355,7 +2355,7 @@ The tracked insertion is set to `evil-last-insertion'." "Save the characters defined by the region BEG and END in the kill-ring." (let ((text (filter-buffer-substring beg end))) (when yank-handler - (setq text (propertize text 'yank-handler (list yank-handler)))) + (put-text-property 0 (length text) 'yank-handler (list yank-handler) text)) (when register (evil-set-register register text)) (when evil-was-yanked-without-register @@ -2365,17 +2365,16 @@ The tracked insertion is set to `evil-last-insertion'." (defun evil-yank-lines (beg end &optional register yank-handler) "Save the lines in the region BEG and END into the kill-ring." - (let* ((text (filter-buffer-substring beg end)) - (yank-handler (list (or yank-handler - #'evil-yank-line-handler) - nil - t))) + (let ((text (filter-buffer-substring beg end)) + (yank-handler (list (or yank-handler #'evil-yank-line-handler) + nil + t))) ;; Ensure the text ends with a newline. This is required ;; if the deleted lines were the last lines in the buffer. (when (or (zerop (length text)) (/= (aref text (1- (length text))) ?\n)) (setq text (concat text "\n"))) - (setq text (propertize text 'yank-handler yank-handler)) + (put-text-property 0 (length text) 'yank-handler yank-handler text) (when register (evil-set-register register text)) (when evil-was-yanked-without-register @@ -2393,13 +2392,12 @@ The tracked insertion is set to `evil-last-insertion'." (setq lines (nreverse (cdr lines))) ;; `text' is used as default insert text when pasting this rectangle ;; in another program, e.g., using the X clipboard. - (let* ((yank-handler (list (or yank-handler - #'evil-yank-block-handler) - lines - t - 'evil-delete-yanked-rectangle)) - (text (propertize (mapconcat #'identity lines "\n") - 'yank-handler yank-handler))) + (let ((yank-handler (list (or yank-handler #'evil-yank-block-handler) + lines + t + #'evil-delete-yanked-rectangle)) + (text (mapconcat #'identity lines "\n"))) + (put-text-property 0 (length text) 'yank-handler yank-handler text) (when register (evil-set-register register text)) (when evil-was-yanked-without-register @@ -138,7 +138,7 @@ of the syntax.") Given e.g. $4, return 4." (when (symbolp obj) (let ((str (symbol-name obj))) - (when (string-match "\\$\\([0-9]+\\)" str) + (when (string-match "\\`\\$\\([0-9]+\\)\\'" str) (string-to-number (match-string 1 str)))))) (defmacro evil-parser (grammar &rest entrypoints) @@ -360,10 +360,9 @@ is appended to the line." (let ((arg (prefix-numeric-value current-prefix-arg))) (cond ((< arg 0) (setq arg (1+ arg))) ((> arg 0) (setq arg (1- arg)))) - (if (= arg 0) "." - (format ".,.%+d" arg))))) + (if (= arg 0) "." (format ".,.%+d" arg))))) evil-ex-initial-input))) - (list (when (> (length s) 0) s)))) + (list (unless (string= s "") s)))) (let ((evil-ex-current-buffer (current-buffer)) (evil-ex-previous-command (unless initial-input (car evil-ex-history))) diff --git a/evil-states.el b/evil-states.el index 9c824ab..450ad2b 100644 --- a/evil-states.el +++ b/evil-states.el @@ -150,12 +150,12 @@ Handles the repeat-count of the insertion command." (indent-according-to-mode))) (evil-execute-repeat-info (cdr evil-insert-repeat-info)))) (when evil-insert-vcount - (let ((buffer-invisibility-spec buffer-invisibility-spec)) - ;; make all lines hidden by hideshow temporarily visible - (when (listp buffer-invisibility-spec) - (setq buffer-invisibility-spec - (cl-remove-if (lambda (x) (eq (or (car-safe x) x) 'hs)) - buffer-invisibility-spec))) + (let ((buffer-invisibility-spec + (if (listp buffer-invisibility-spec) + ;; make all lines hidden by hideshow temporarily visible + (cl-remove-if (lambda (x) (eq (or (car-safe x) x) 'hs)) + buffer-invisibility-spec) + buffer-invisibility-spec))) (cl-destructuring-bind (line col vcount) evil-insert-vcount (save-excursion (dotimes (v (1- vcount)) @@ -796,14 +796,15 @@ CORNER defaults to `upper-left'." (let* ((point (or point (point))) (mark (or mark (mark t))) (corner (or corner - (when (overlayp evil-visual-overlay) + (when evil-visual-overlay (overlay-get evil-visual-overlay :corner)) 'upper-left)) (point-col (evil-column point)) (mark-col (evil-column mark)) - (upperp (if (= (line-number-at-pos point) (line-number-at-pos mark)) - (memq corner '(upper-left upper-right)) - (< point mark))) + (upperp (if (save-excursion (goto-char (min point mark)) + (search-forward "\n" (max point mark) t)) + (< point mark) + (memq corner '(upper-left upper-right)))) (leftp (if (= point-col mark-col) (memq corner '(upper-left lower-left)) (< point-col mark-col)))) |
