Skip to content

Commit

Permalink
Merge pull request #1738 from funk443/main
Browse files Browse the repository at this point in the history
Add an option to control the save of clipboard content before killing.
  • Loading branch information
cxxxr authored Jan 8, 2025
2 parents f0b09a3 + 68678b6 commit 8d4c9be
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
15 changes: 10 additions & 5 deletions src/commands/edit.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,15 @@
"Kill the text of region."
(when (point< end start)
(rotatef start end))
(let ((repeat-command (continue-flag :kill)))
(let ((killed-string (delete-character start (count-characters start end))))
(with-killring-context (:appending repeat-command)
(copy-to-clipboard-with-killring killed-string)))))
(let ((repeat-command (continue-flag :kill))
(killed-string (delete-character start (count-characters start end))))
(with-killring-context (:appending repeat-command)
(when (and (not repeat-command)
(enable-clipboard-p))
(let ((clipboard-string (get-clipboard-data)))
(unless (string= clipboard-string (peek-killring-item (current-killring) 0))
(push-killring-item (current-killring) clipboard-string))))
(copy-to-clipboard-with-killring killed-string))))

(define-command kill-region-to-clipboard (start end) (:region)
"Kill the text of region and copy to the clipboard."
Expand Down Expand Up @@ -215,7 +220,7 @@
(define-command kill-whole-line (&optional (n 1)) (:universal)
"If n is positive, kill n whole lines forward starting at the
beginning of the current line. If n is 0, do nothing. And if n
is negative, kill n lines above without deleting anything on the
is negative, kill n lines above without deleting anything on the
current line."
(cond ((zerop n) nil)
((minusp n) (save-excursion
Expand Down
26 changes: 13 additions & 13 deletions src/ext/line-numbers.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ With a positive universal argument, use relative line numbers. Also obey the glo
(line (line-number-at-point point))
(custom-line (variable-value 'custom-current-line :default buffer)))
(if (= cursor-line line)
(or custom-line line)
(abs (- cursor-line line))))
(line-number-at-point point)))
(values (or custom-line line) t)
(values (abs (- cursor-line line)) nil)))
(let ((line (line-number-at-point point)))
(values line (= (line-number-at-point (buffer-point buffer)) line)))))

(defun get-buffer-num-format (buffer)
(let* ((last-line (lem/buffer/internal::point-linum (buffer-end-point buffer)))
Expand All @@ -72,16 +73,15 @@ With a positive universal argument, use relative line numbers. Also obey the glo

(defmethod lem-core:compute-left-display-area-content ((mode line-numbers-mode) buffer point)
(when (buffer-filename (point-buffer point))
(let* ((computed-line (compute-line buffer point))
(num-format (or (variable-value 'line-number-format :default buffer)
(get-buffer-num-format buffer)))
(string (format nil num-format computed-line))
(attribute (if (eq computed-line
(compute-line buffer (buffer-point buffer)))
`((0 ,(length string) active-line-number-attribute))
`((0 ,(length string) line-numbers-attribute)))))
(lem/buffer/line:make-content :string string
:attributes attribute))))
(multiple-value-bind (computed-line active-line-p) (compute-line buffer point)
(let* ((num-format (or (variable-value 'line-number-format :default buffer)
(get-buffer-num-format buffer)))
(string (format nil num-format computed-line))
(attribute (if active-line-p
`((0 ,(length string) active-line-number-attribute))
`((0 ,(length string) line-numbers-attribute)))))
(lem/buffer/line:make-content :string string
:attributes attribute)))))

(defmethod lem-core:compute-wrap-left-area-content (left-side-width left-side-characters)
(if (< 0 left-side-width)
Expand Down

0 comments on commit 8d4c9be

Please sign in to comment.