From a79a742cbff01b7815cffba806c28ea45a4da63c Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Tue, 12 Jul 2022 15:05:45 +0800 Subject: [PATCH 1/3] Revert "org.el: Improve performance of deletion commands" This reverts commit 46df681336c83c826b367d2803f59560165bdeba. The optimization broke folding fragility checks. --- lisp/org.el | 74 ++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 38 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 3d4de5b4f..d85b5818e 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -16156,19 +16156,18 @@ (defun org-delete-backward-char (N) still be marked for re-alignment if the field did fill the entire column, because, in this case the deletion might narrow the column." (interactive "p") - (org-fold-core-ignore-modifications - (save-match-data - (org-fold-check-before-invisible-edit 'delete-backward) - (if (and (= N 1) - (not overwrite-mode) - (not (org-region-active-p)) - (not (eq (char-before) ?|)) - (save-excursion (skip-chars-backward " \t") (not (bolp))) - (looking-at-p ".*?|") - (org-at-table-p)) - (progn (forward-char -1) (org-delete-char 1)) - (backward-delete-char N) - (org-fix-tags-on-the-fly))))) + (save-match-data + (org-fold-check-before-invisible-edit 'delete-backward) + (if (and (= N 1) + (not overwrite-mode) + (not (org-region-active-p)) + (not (eq (char-before) ?|)) + (save-excursion (skip-chars-backward " \t") (not (bolp))) + (looking-at-p ".*?|") + (org-at-table-p)) + (progn (forward-char -1) (org-delete-char 1)) + (backward-delete-char N) + (org-fix-tags-on-the-fly)))) (defun org-delete-char (N) "Like `delete-char', but insert whitespace at field end in tables. @@ -16177,31 +16176,30 @@ (defun org-delete-char (N) still be marked for re-alignment if the field did fill the entire column, because, in this case the deletion might narrow the column." (interactive "p") - (org-fold-core-ignore-modifications - (save-match-data - (org-fold-check-before-invisible-edit 'delete) - (cond - ((or (/= N 1) - (eq (char-after) ?|) - (save-excursion (skip-chars-backward " \t") (bolp)) - (not (org-at-table-p))) - (delete-char N) - (org-fix-tags-on-the-fly)) - ((looking-at ".\\(.*?\\)|") - (let* ((update? org-table-may-need-update) - (noalign (looking-at-p ".*? |"))) - (delete-char 1) - (org-table-with-shrunk-field - (save-excursion - ;; Last space is `org-table-separator-space', so insert - ;; a regular one before it instead. - (goto-char (- (match-end 0) 2)) - (insert " "))) - ;; If there were two spaces at the end, this field does not - ;; determine the width of the column. - (when noalign (setq org-table-may-need-update update?)))) - (t - (delete-char N)))))) + (save-match-data + (org-fold-check-before-invisible-edit 'delete) + (cond + ((or (/= N 1) + (eq (char-after) ?|) + (save-excursion (skip-chars-backward " \t") (bolp)) + (not (org-at-table-p))) + (delete-char N) + (org-fix-tags-on-the-fly)) + ((looking-at ".\\(.*?\\)|") + (let* ((update? org-table-may-need-update) + (noalign (looking-at-p ".*? |"))) + (delete-char 1) + (org-table-with-shrunk-field + (save-excursion + ;; Last space is `org-table-separator-space', so insert + ;; a regular one before it instead. + (goto-char (- (match-end 0) 2)) + (insert " "))) + ;; If there were two spaces at the end, this field does not + ;; determine the width of the column. + (when noalign (setq org-table-may-need-update update?)))) + (t + (delete-char N))))) ;; Make `delete-selection-mode' work with Org mode and Orgtbl mode (put 'org-self-insert-command 'delete-selection -- 2.35.1