From 3dbf2edb3c6cd7068558f5c453681185f5a40682 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 11 Aug 2023 16:08:16 +0800 Subject: [PATCH] Improve kill-ring-deindent-mode * etc/NEWS: * lisp/simple.el (kill-ring-deindent-buffer-substring-function): (kill-ring-deindent-mode): Deindent by the column number at BEG in lieu of the indentation at BEG. --- etc/NEWS | 4 ++-- lisp/simple.el | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index ffd9632dc05..0388cca97aa 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -148,8 +148,8 @@ right-aligned to is controlled by the new user option --- ** New global minor mode 'kill-ring-deindent-mode'. When enabled, text being saved to the kill ring will be de-indented by -the number of columns its first line is indented. For example, -saving the entire function call within: +the column number at its start. For example, saving the entire +function call within: foo () { diff --git a/lisp/simple.el b/lisp/simple.el index 61e3af07df2..604ab0541bf 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -11150,13 +11150,13 @@ seconds." Maybe delete it if DELETE is non-nil. Before saving the text, indent it leftwards by the number of -columns of indentation at BEG." +columns at BEG." (let ((a beg) (b end)) (setq beg (min a b) end (max a b))) (let ((indentation (save-excursion (goto-char beg) - (current-indentation))) + (current-column))) (text (if delete (delete-and-extract-region beg end) (buffer-substring beg end)))) @@ -11170,8 +11170,8 @@ columns of indentation at BEG." "Toggle removal of indentation from text saved to the kill ring. When this minor mode is enabled, text saved into the kill ring is -indented towards the left by the number of columns the line at -the start of the text being saved is in turn indented." +indented towards the left by the column number at the start of +that text." :global 't :group 'killing (if kill-ring-deindent-mode -- 2.39.2