diff --git a/src/commands/edit.lisp b/src/commands/edit.lisp index 716d831fc..bf5ef87da 100644 --- a/src/commands/edit.lisp +++ b/src/commands/edit.lisp @@ -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." @@ -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 diff --git a/src/ext/line-numbers.lisp b/src/ext/line-numbers.lisp index 7c2f2893c..7a8704fb7 100644 --- a/src/ext/line-numbers.lisp +++ b/src/ext/line-numbers.lisp @@ -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))) @@ -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)