diff options
-rw-r--r-- | lisp/km-magit.el | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lisp/km-magit.el b/lisp/km-magit.el index 11584c1..91c03b8 100644 --- a/lisp/km-magit.el +++ b/lisp/km-magit.el @@ -988,9 +988,10 @@ COMMIT." (t (concat (car msg-lines) "[...]")))))) (defun km/magit-copy-commit-message (&optional _) - (when (magit-section-match 'message) - (let ((msg (buffer-substring-no-properties (oref it start) - (oref it end)))) + (when (magit-section-match 'commit-message) + (let* ((section (magit-current-section)) + (msg (buffer-substring-no-properties (oref section start) + (oref section end)))) (kill-new msg) (km/magit-copy--truncated-message msg)))) @@ -1008,11 +1009,12 @@ COMMIT." (defun km/magit-copy-hunk (&optional _) (when (magit-section-match 'hunk) - (kill-new (buffer-substring-no-properties - (save-excursion (goto-char (oref it start)) - (1+ (point-at-eol))) - (oref it end))) - (message "Copied hunk: %s" (oref it value)))) + (let ((section (magit-current-section))) + (kill-new (buffer-substring-no-properties + (save-excursion (goto-char (oref section start)) + (1+ (point-at-eol))) + (oref section end))) + (message "Copied hunk: %s" (oref section value))))) (defun km/magit-copy-as-kill () "Try `km/magit-copy-functions' before calling `magit-copy-section-value'. |