summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2012-12-23 12:30:40 +0100
committerBastien Guerry <bzg@altern.org>2012-12-23 12:30:40 +0100
commitc800836d7cc22a3c5d9e3d6d2a992641605e5e29 (patch)
tree567c76976dc1554c3b97a0c229ce4d9a2ca847ba
parent91056e2a8dd7539ac871ee004e6d4a5d8b9718f8 (diff)
downloadorg-mode-c800836d7cc22a3c5d9e3d6d2a992641605e5e29.tar.gz
Save match data in `org-delete-backward-char' and `org-delete-char'
* org.el (org-delete-backward-char, org-delete-char): Save match data (`delete-backward-char' and `delete-char' don't.) (org-enable-table-editor, org-insert-heading) (org-remove-timestamp-with-keyword, org-self-insert-command): Use `delete-backward-char' instead of `backward-delete-char'. * org-table.el (org-table-fedit-lisp-indent) (orgtbl-self-insert-command): Ditto. * org-latex.el (org-export-latex-subcontent): Ditto. * org-clock.el (org-clocktable-write-default): Ditto. * org-ascii.el (org-export-ascii-preprocess): Ditto. Thanks to Vegard Vesterheim for raising this issue and proposing a patch, and to Carsten for pointing at the root of the problem.
-rw-r--r--lisp/org-ascii.el2
-rw-r--r--lisp/org-clock.el2
-rw-r--r--lisp/org-latex.el2
-rw-r--r--lisp/org-table.el4
-rw-r--r--lisp/org.el86
5 files changed, 49 insertions, 47 deletions
diff --git a/lisp/org-ascii.el b/lisp/org-ascii.el
index 67fc4ac..9a8c57f 100644
--- a/lisp/org-ascii.el
+++ b/lisp/org-ascii.el
@@ -567,7 +567,7 @@ publishing directory."
(while (re-search-forward org-verbatim-re nil t)
(org-if-unprotected-at (match-beginning 4)
(goto-char (match-end 2))
- (backward-delete-char 1) (insert "'")
+ (delete-backward-char 1) (insert "'")
(goto-char (match-beginning 2))
(delete-char 1) (insert "`")
(goto-char (match-end 2))))
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index e8ced67..c0aebd8 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -2442,7 +2442,7 @@ from the dynamic block definition."
)))))
;; When exporting subtrees or regions the region might be
;; activated, so let's disable ̀€delete-active-region'
- (let ((delete-active-region nil)) (backward-delete-char 1))
+ (let ((delete-active-region nil)) (delete-backward-char 1))
(if (setq formula (plist-get params :formula))
(cond
((eq formula '%)
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index a53470d..d27adaa 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -1353,7 +1353,7 @@ numbered sections and lower levels as unnumbered sections."
(insert (org-export-latex-content content))
(cond ((stringp subcontent) (insert subcontent))
((listp subcontent)
- (while (org-looking-back "\n\n") (backward-delete-char 1))
+ (while (org-looking-back "\n\n") (delete-backward-char 1))
(org-export-latex-sub subcontent)))
(when (and end (string-match "[^ \t]" end))
(let ((hook (org-get-text-property-any 0 'org-insert-hook end)))
diff --git a/lisp/org-table.el b/lisp/org-table.el
index c7d6176..ff2008b 100644
--- a/lisp/org-table.el
+++ b/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)))
+ (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)
+ (delete-backward-char 1)
(goto-char (match-beginning 0))
(self-insert-command N))
(setq org-table-may-need-update t)
diff --git a/lisp/org.el b/lisp/org.el
index 77886cc..0eb356c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1282,7 +1282,7 @@ do the following:
TAB or RET are pressed to move to another field. With optimization this
happens only if changes to a field might have changed the column width.
Optimization requires replacing the functions `self-insert-command',
-`delete-char', and `backward-delete-char' in Org-mode buffers, with a
+`delete-char', and `delete-backward-char' in Org-mode buffers, with a
slight (in fact: unnoticeable) speed impact for normal typing. Org-mode is
very good at guessing when a re-align will be necessary, but you can always
force one with \\[org-ctrl-c-ctrl-c].
@@ -7156,7 +7156,7 @@ This is important for non-interactive uses of the command."
(insert head) (just-one-space)
(setq pos (point))
(end-of-line 1)
- (unless (= (point) pos) (just-one-space) (backward-delete-char 1))
+ (unless (= (point) pos) (just-one-space) (delete-backward-char 1))
(when (and org-insert-heading-respect-content hide-previous)
(save-excursion
(goto-char previous-pos)
@@ -12313,7 +12313,7 @@ nil."
(replace-match "")
(if (and (string-match "\\S-" (buffer-substring (point-at-bol) (point)))
(equal (char-before) ?\ ))
- (backward-delete-char 1)
+ (delete-backward-char 1)
(if (string-match "^[ \t]*$" (buffer-substring
(point-at-bol) (point-at-eol)))
(delete-region (point-at-bol)
@@ -18221,7 +18221,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)
+ (delete-backward-char 1)
(goto-char (match-beginning 0))
(self-insert-command N)))
(t
@@ -18295,31 +18295,32 @@ The detailed reaction depends on the user option `org-catch-invisible-edits'."
(org-align-tags-here org-tags-column)))
(defun org-delete-backward-char (N)
- "Like `delete-backward-char', insert whitespace at field end in tables.
+ "Like `delete-backward-char', but insert whitespace at field end in tables.
When deleting backwards, in tables this function will insert whitespace in
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))
+ (delete-backward-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)))
+ (delete-backward-char N)
+ (org-fix-tags-on-the-fly))))
(defun org-delete-char (N)
"Like `delete-char', but insert whitespace at field end in tables.
@@ -18329,24 +18330,25 @@ 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
+ (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)