diff options
| author | Asher Copeland | 2025-04-02 10:55:06 -0700 |
|---|---|---|
| committer | Eli Zaretskii | 2025-04-13 11:24:31 +0300 |
| commit | 5665b446b7a5b2f6ff4d4e7ea9b2c91e0e733c92 (patch) | |
| tree | de9d4656b9da184a21c5b21b37da51717ab986a9 | |
| parent | d9ad0c953be1da33c2a7df0d5cae3358bf2b7b1a (diff) | |
| download | emacs-5665b446b7a5b2f6ff4d4e7ea9b2c91e0e733c92.tar.gz emacs-5665b446b7a5b2f6ff4d4e7ea9b2c91e0e733c92.zip | |
Fix 'backward-delete-char-untabify'
* lisp/simple.el (backward-delete-char-untabify): Fix
behavior when there's an active region. (Bug#75042)
Copyright-paperwork-exempt: yes
| -rw-r--r-- | lisp/simple.el | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 7037158df8d..ee09a6f1b19 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -6601,30 +6601,36 @@ To disable this, set option `delete-active-region' to nil. | |||
| 6601 | Interactively, ARG is the prefix arg (default 1) | 6601 | Interactively, ARG is the prefix arg (default 1) |
| 6602 | and KILLP is t if a prefix arg was specified." | 6602 | and KILLP is t if a prefix arg was specified." |
| 6603 | (interactive "*p\nP") | 6603 | (interactive "*p\nP") |
| 6604 | (when (eq backward-delete-char-untabify-method 'untabify) | 6604 | (if (and (use-region-p) |
| 6605 | (let ((count arg)) | 6605 | delete-active-region |
| 6606 | (save-excursion | 6606 | (= arg 1)) |
| 6607 | (while (and (> count 0) (not (bobp))) | 6607 | ;; Delete the text of the region and deactivate the mark, in the |
| 6608 | (if (= (preceding-char) ?\t) | 6608 | ;; same way that `delete-backward-char' does. |
| 6609 | (let ((col (current-column))) | 6609 | (with-no-warnings (delete-backward-char 1 killp)) |
| 6610 | (forward-char -1) | 6610 | (when (eq backward-delete-char-untabify-method 'untabify) |
| 6611 | (setq col (- col (current-column))) | 6611 | (let ((count arg)) |
| 6612 | (insert-char ?\s col) | 6612 | (save-excursion |
| 6613 | (delete-char 1))) | 6613 | (while (and (> count 0) (not (bobp))) |
| 6614 | (forward-char -1) | 6614 | (if (= (preceding-char) ?\t) |
| 6615 | (setq count (1- count)))))) | 6615 | (let ((col (current-column))) |
| 6616 | (let* ((skip (cond ((eq backward-delete-char-untabify-method 'hungry) " \t") | 6616 | (forward-char -1) |
| 6617 | ((eq backward-delete-char-untabify-method 'all) | 6617 | (setq col (- col (current-column))) |
| 6618 | " \t\n\r"))) | 6618 | (insert-char ?\s col) |
| 6619 | (n (if skip | 6619 | (delete-char 1))) |
| 6620 | (let* ((oldpt (point)) | 6620 | (forward-char -1) |
| 6621 | (wh (- oldpt (save-excursion | 6621 | (setq count (1- count)))))) |
| 6622 | (skip-chars-backward skip) | 6622 | (let* ((skip (cond ((eq backward-delete-char-untabify-method 'hungry) " \t") |
| 6623 | (constrain-to-field nil oldpt))))) | 6623 | ((eq backward-delete-char-untabify-method 'all) |
| 6624 | (+ arg (if (zerop wh) 0 (1- wh)))) | 6624 | " \t\n\r"))) |
| 6625 | arg))) | 6625 | (n (if skip |
| 6626 | ;; Avoid warning about delete-backward-char | 6626 | (let* ((oldpt (point)) |
| 6627 | (with-no-warnings (delete-backward-char n killp)))) | 6627 | (wh (- oldpt (save-excursion |
| 6628 | (skip-chars-backward skip) | ||
| 6629 | (constrain-to-field nil oldpt))))) | ||
| 6630 | (+ arg (if (zerop wh) 0 (1- wh)))) | ||
| 6631 | arg))) | ||
| 6632 | ;; Avoid warning about delete-backward-char | ||
| 6633 | (with-no-warnings (delete-backward-char n killp))))) | ||
| 6628 | 6634 | ||
| 6629 | (defun char-uppercase-p (char) | 6635 | (defun char-uppercase-p (char) |
| 6630 | "Return non-nil if CHAR is an upper-case character. | 6636 | "Return non-nil if CHAR is an upper-case character. |