Browse Source

org-table.el: Use `org-delete-backward-char' which doesn't modify match data anymore

* org-table.el (org-table-fedit-lisp-indent)
(orgtbl-self-insert-command): Use `org-delete-backward-char'
instead of `backward-delete-char'.

* org.el (org-delete-backward-char, org-delete-char): Save
match data.
Bastien Guerry 12 năm trước cách đây
mục cha
commit
f0a64ab3b5
2 tập tin đã thay đổi với 42 bổ sung40 xóa
  1. 2 2
      lisp/org-table.el
  2. 40 38
      lisp/org.el

+ 2 - 2
lisp/org-table.el

@@ -3580,7 +3580,7 @@ With prefix ARG, apply the new formulas to the table."
 	    (beginning-of-line 1)
 	    (insert ind))
 	  (goto-char (point-max))
-	  (backward-delete-char 1)))
+	  (org-delete-backward-char 1)))
       (goto-char beg))
      (t nil))))
 
@@ -4235,7 +4235,7 @@ overwritten, and the table is not marked as requiring realignment."
 	   (looking-at "[^|\n]*  +|"))
       (let (org-table-may-need-update)
 	(goto-char (1- (match-end 0)))
-	(backward-delete-char 1)
+	(org-delete-backward-char 1)
 	(goto-char (match-beginning 0))
 	(self-insert-command N))
     (setq org-table-may-need-update t)

+ 40 - 38
lisp/org.el

@@ -18301,25 +18301,26 @@ front of the next \"|\" separator, to keep the table aligned.  The table will
 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-check-before-invisible-edit 'delete-backward)
-  (if (and (org-table-p)
-	   (eq N 1)
-	   (string-match "|" (buffer-substring (point-at-bol) (point)))
-	   (looking-at ".*?|"))
-      (let ((pos (point))
-	    (noalign (looking-at "[^|\n\r]*  |"))
-	    (c org-table-may-need-update))
-	(backward-delete-char N)
-	(if (not overwrite-mode)
-	    (progn
-	      (skip-chars-forward "^|")
-	      (insert " ")
-	      (goto-char (1- pos))))
-	;; noalign: if there were two spaces at the end, this field
-	;; does not determine the width of the column.
-	(if noalign (setq org-table-may-need-update c)))
-    (backward-delete-char N)
-    (org-fix-tags-on-the-fly)))
+  (save-match-data
+    (org-check-before-invisible-edit 'delete-backward)
+    (if (and (org-table-p)
+	     (eq N 1)
+	     (string-match "|" (buffer-substring (point-at-bol) (point)))
+	     (looking-at ".*?|"))
+	(let ((pos (point))
+	      (noalign (looking-at "[^|\n\r]*  |"))
+	      (c org-table-may-need-update))
+	  (backward-delete-char N)
+	  (if (not overwrite-mode)
+	      (progn
+		(skip-chars-forward "^|")
+		(insert " ")
+		(goto-char (1- pos))))
+	  ;; noalign: if there were two spaces at the end, this field
+	  ;; does not determine the width of the column.
+	  (if noalign (setq org-table-may-need-update c)))
+      (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.
@@ -18328,25 +18329,26 @@ front of the next \"|\" separator, to keep the table aligned.  The table will
 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-check-before-invisible-edit 'delete)
-  (if (and (org-table-p)
-	   (not (bolp))
-	   (not (= (char-after) ?|))
-	   (eq N 1))
-      (if (looking-at ".*?|")
-	  (let ((pos (point))
-		(noalign (looking-at "[^|\n\r]*  |"))
-		(c org-table-may-need-update))
-	    (replace-match (concat
-			    (substring (match-string 0) 1 -1)
-			    " |"))
-	    (goto-char pos)
-	    ;; noalign: if there were two spaces at the end, this field
-	    ;; does not determine the width of the column.
-	    (if noalign (setq org-table-may-need-update c)))
-	(delete-char N))
-    (delete-char N)
-    (org-fix-tags-on-the-fly)))
+  (save-match-data
+    (org-check-before-invisible-edit 'delete)
+    (if (and (org-table-p)
+	     (not (bolp))
+	     (not (= (char-after) ?|))
+	     (eq N 1))
+	(if (looking-at ".*?|")
+	    (let ((pos (point))
+		  (noalign (looking-at "[^|\n\r]*  |"))
+		  (c org-table-may-need-update))
+	      (replace-match (concat
+			      (substring (match-string 0) 1 -1)
+			      " |"))
+	      (goto-char pos)
+	      ;; noalign: if there were two spaces at the end, this field
+	      ;; does not determine the width of the column.
+	      (if noalign (setq org-table-may-need-update c)))
+	  (delete-char N))
+      (delete-char N)
+      (org-fix-tags-on-the-fly))))
 
 ;; Make `delete-selection-mode' work with org-mode and orgtbl-mode
 (put 'org-self-insert-command 'delete-selection t)