Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

evil-mode text insertion breaks emacs text property inheritance (stickiness of text properties) #1857

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions evil-commands.el
dizzyyogi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ given."
(if force (evil-insert-newline-above) (evil-insert-newline-below))
(evil-set-marker ?\[ (point))
;; `insert' rather than `insert-for-yank' as we want to ignore yank-handlers...
(insert (if (and (< 0 (length text))
(insert-and-inherit (if (and (< 0 (length text))
(eq ?\n (aref text (1- (length text)))))
(substring text 0 (1- (length text)))
text))
Expand Down Expand Up @@ -1696,7 +1696,7 @@ of the block."
(when (or (zerop len) (/= (aref txt (1- len)) ?\n))
(setq txt (concat txt "\n")))
(when (and (eobp) (not (bolp))) (newline)) ; incomplete last line
(insert txt)
(insert-and-inherit txt)
(forward-line -1)))

(evil-define-command evil-move (beg end address)
Expand All @@ -1721,7 +1721,7 @@ of the block."
(when (and (eobp) (not (bolp))) (newline)) ; incomplete last line
(when (evil-visual-state-p)
(move-marker evil-visual-mark (point)))
(insert txt)
(insert-and-inherit txt)
(forward-line -1)
(when (evil-visual-state-p)
(move-marker evil-visual-point (point))))))
Expand Down Expand Up @@ -1774,7 +1774,8 @@ Add (add-hook 'evil-local-mode-hook 'turn-on-undo-tree-mode) to your init file f
(let ((char (following-char)))
(delete-char 1)
(insert-char
(if (eq (upcase char) char) (downcase char) (upcase char))))
(if (eq (upcase char) char) (downcase char) (upcase char))
1 t))
(setq beg (1+ beg))))))

(evil-define-operator evil-invert-char (beg end type)
Expand Down Expand Up @@ -2176,7 +2177,7 @@ The default for width is the value of `fill-column'."
(let ((beg (evil-move-to-column begcol nil t))
(end (evil-move-to-column endcol nil t)))
(delete-region beg end)
(insert (make-string (- endcol begcol) char))))))
(insert-and-inherit (make-string (- endcol begcol) char))))))
beg end char))
(goto-char beg)
(cond
Expand All @@ -2190,7 +2191,7 @@ The default for width is the value of `fill-column'."
(if (eq (char-after) ?\n)
(forward-char)
(delete-char 1)
(insert-char char 1)))
(insert-char char 1 t)))
(goto-char (max beg (1- end))))))))

(evil-define-command evil-paste-before
Expand Down Expand Up @@ -2226,7 +2227,7 @@ The return value is the yanked text."
;; no yank-handler, default
(when (vectorp text)
(setq text (evil-vector-to-string text)))
(set-text-properties 0 (length text) nil text)
;; (set-text-properties 0 (length text) nil text)
(push-mark opoint t)
(dotimes (_ (or count 1))
(insert-for-yank text))
Expand Down Expand Up @@ -2278,7 +2279,7 @@ The return value is the yanked text."
;; no yank-handler, default
(when (vectorp text)
(setq text (evil-vector-to-string text)))
(set-text-properties 0 (length text) nil text)
;; (set-text-properties 0 (length text) nil text)
(unless (eolp) (forward-char))
(push-mark (point) t)
;; TODO: Perhaps it is better to collect a list of all
Expand Down Expand Up @@ -2366,7 +2367,7 @@ leave the cursor just after the new text."
(when (and (eq yank-handler #'evil-yank-line-handler)
(not (memq type '(line block)))
(/= end (point-max)))
(insert "\n"))
(insert-and-inherit "\n"))
(evil-normal-state)
(when kill-ring (current-kill 1)))
;; Effectively memoize `evil-get-register' because it can be
Expand Down Expand Up @@ -2878,7 +2879,7 @@ next VCOUNT - 1 lines below the current one."
insert-prompt (make-overlay opoint (+ chars-to-delete opoint)))
(evil-update-replace-alist opoint count chars-to-delete))
(setq insert-prompt (make-overlay opoint opoint)))
(insert-char (evil-read-digraph-char-with-overlay insert-prompt) count)
(insert-char (evil-read-digraph-char-with-overlay insert-prompt) count t)
(when chars-to-delete (delete-char chars-to-delete))))

(evil-define-command evil-ex-show-digraphs ()
Expand Down Expand Up @@ -3349,19 +3350,19 @@ If no FILE is specified, reload the current buffer from disk."
(when count (goto-char (point-min)))
(when (or (not (zerop (forward-line (or count 1))))
(not (bolp)))
(insert "\n"))
(insert-and-inherit "\n"))
(cond
((/= (aref file 0) ?!)
(when (member file '("#" "%"))
(setq file (evil-ex-replace-special-filenames file)))
(let ((result (insert-file-contents file)))
(save-excursion
(forward-char (cadr result))
(unless (bolp) (insert "\n")))))
(unless (bolp) (insert-and-inherit "\n")))))
(t
(shell-command (evil-ex-replace-special-filenames (substring file 1)) t)
(goto-char (mark))
(unless (bolp) (insert "\n"))
(unless (bolp) (insert-and-inherit "\n"))
(forward-line -1)))))

(evil-define-command evil-show-files ()
Expand Down
20 changes: 10 additions & 10 deletions evil-common.el
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,7 @@ closer if MOVE is non-nil."
with regard to indentation."
(evil-narrow-to-field
(evil-move-beginning-of-line)
(insert (if use-hard-newlines hard-newline "\n"))
(insert-and-inherit (if use-hard-newlines hard-newline "\n"))
(forward-line -1)
(back-to-indentation)))

Expand All @@ -1810,7 +1810,7 @@ with regard to indentation."
with regard to indentation."
(evil-narrow-to-field
(evil-move-end-of-line)
(insert (if use-hard-newlines hard-newline "\n"))
(insert-and-inherit (if use-hard-newlines hard-newline "\n"))
(back-to-indentation)))

;;; Markers
Expand Down Expand Up @@ -2415,7 +2415,7 @@ The tracked insertion is set to `evil-last-insertion'."
((eq this-command 'evil-paste-before)
(evil-move-beginning-of-line)
(let ((beg (point)))
(insert text)
(insert-and-inherit text)
(setq evil-last-paste
(list 'evil-paste-before evil-paste-count opoint beg (point)))
(evil-set-marker ?\[ beg)
Expand All @@ -2425,8 +2425,8 @@ The tracked insertion is set to `evil-last-insertion'."
((eq this-command 'evil-paste-after)
(evil-move-end-of-line)
(let ((beg (point)))
(insert "\n")
(insert text)
(insert-and-inherit "\n")
(insert-and-inherit text)
(delete-char -1) ; delete the last newline
(setq evil-last-paste
(list 'evil-paste-after evil-paste-count opoint beg (point)))
Expand All @@ -2435,7 +2435,7 @@ The tracked insertion is set to `evil-last-insertion'."
(unless evil--cursor-after
(goto-char (1+ beg))))
(back-to-indentation))
(t (insert text)))))
(t (insert-and-inherit text)))))

(defun evil-yank-block-handler (lines)
"Insert the current text as block."
Expand All @@ -2451,7 +2451,7 @@ The tracked insertion is set to `evil-last-insertion'."
(setq first nil)
(when (or (> (forward-line 1) 0)
(and (eobp) (not (bolp))))
(insert "\n")))
(insert-and-inherit "\n")))
;; concat multiple copies according to count
(setq line (apply #'concat (make-list count line)))
;; trim whitespace at beginning and end
Expand All @@ -2466,12 +2466,12 @@ The tracked insertion is set to `evil-last-insertion'."
(if (< (evil-column (line-end-position)) col)
(move-to-column (+ col begextra) t)
(move-to-column col t)
(insert (make-string begextra ?\s)))
(insert-and-inherit (make-string begextra ?\s)))
(evil-remove-yank-excluded-properties text)
(insert text)
(insert-and-inherit text)
(unless (eolp)
;; text follows, so we have to insert spaces
(insert (make-string endextra ?\s))))))
(insert-and-inherit (make-string endextra ?\s))))))
(setq evil-last-paste
(list this-command
evil-paste-count
Expand Down
2 changes: 1 addition & 1 deletion evil-repeat.el
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ where point should be placed after all changes."
(dolist (change changes)
(goto-char (+ point (nth 0 change)))
(delete-char (nth 2 change))
(insert (nth 1 change)))
(insert-and-inherit (nth 1 change)))
(goto-char (+ point rel-point)))))

(defun evil-execute-repeat-info (repeat-info)
Expand Down
2 changes: 1 addition & 1 deletion evil-states.el
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ CORNER defaults to `upper-left'."
(this-command #'evil-replace-backspace))
(when prev
(delete-char 1)
(when char (save-excursion (insert char))))))
(when char (save-excursion (insert-and-inherit char))))))
dizzyyogi marked this conversation as resolved.
Show resolved Hide resolved

(defun evil-update-replace-alist (opoint count chars-to-delete &optional offset)
"Add CHARS-TO-DELETE chars to evil-replace-alist, starting at OPOINT.
Expand Down
Loading