From 73a5c27cc1751721344886e7518f20ff382265b5 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 5 Nov 2015 23:07:18 +0100 Subject: [PATCH] Fix table editing with an active region * lisp/org.el (org-self-insert-command): Do not call `backward-delete-char' since it possibly deletes active region. Simplify code. This fixes bug#21838. --- lisp/org.el | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index b216702f0..d5551c965 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -20174,23 +20174,23 @@ overwritten, and the table is not marked as requiring realignment." ((and (org-table-p) (progn - ;; check if we blank the field, and if that triggers align + ;; Check if we blank the field, and if that triggers align. (and (featurep 'org-table) org-table-auto-blank-field (memq last-command '(org-cycle org-return org-shifttab org-ctrl-c-ctrl-c)) - (if (or (equal (char-after) ?\ ) (looking-at "[^|\n]* |")) - ;; got extra space, this field does not determine column width + (if (or (eq (char-after) ?\s) (looking-at "[^|\n]* |")) + ;; Got extra space, this field does not determine + ;; column width. (let (org-table-may-need-update) (org-table-blank-field)) - ;; no extra space, this field may determine column width + ;; No extra space, this field may determine column + ;; width. (org-table-blank-field))) t) (eq N 1) - (looking-at "[^|\n]* |")) - (let (org-table-may-need-update) - (goto-char (1- (match-end 0))) - (backward-delete-char 1) - (goto-char (match-beginning 0)) - (self-insert-command N))) + (looking-at "[^|\n]* \\( \\)|")) + ;; There is room for insertion without re-aligning the table. + (delete-region (match-beginning 1) (match-end 1)) + (self-insert-command N)) (t (setq org-table-may-need-update t) (self-insert-command N)