Browse Source

`org-toggle-item' working as expected.

* org-list.el (org-list-bullet-string): do not modify match-data.
* org.el (org-toggle-item): now working again when changing list items
  into plain text. Moreover take into consideration
  `org-list-two-spaces-after-bullet-regexp'.
Nicolas Goaziou 15 years ago
parent
commit
80b269d947
2 changed files with 10 additions and 9 deletions
  1. 5 4
      lisp/org-list.el
  2. 5 5
      lisp/org.el

+ 5 - 4
lisp/org-list.el

@@ -991,10 +991,11 @@ form (indentation . bullet).  Assumes cursor in item line."
   "Concatenate BULLET with an appropriate number of whitespaces.
   "Concatenate BULLET with an appropriate number of whitespaces.
 It determines the number of whitespaces to append by looking at
 It determines the number of whitespaces to append by looking at
 `org-list-two-spaces-after-bullet-regexp'."
 `org-list-two-spaces-after-bullet-regexp'."
-  (concat
-   bullet " "
-   ;; Do we need to concat another white space ?
-   (when (string-match org-list-two-spaces-after-bullet-regexp bullet) " ")))
+  (save-match-data
+    (concat
+     bullet " "
+     ;; Do we need to concat another white space ?
+     (when (string-match org-list-two-spaces-after-bullet-regexp bullet) " "))))
 
 
 (defun org-list-replace-bullet (new-bullet)
 (defun org-list-replace-bullet (new-bullet)
   "Replace current item's bullet with NEW-BULLET.
   "Replace current item's bullet with NEW-BULLET.

+ 5 - 5
lisp/org.el

@@ -17335,21 +17335,21 @@ If the first line is normal text, add an item bullet to each line."
 	  ;; We already have items, de-itemize
 	  ;; We already have items, de-itemize
 	  (while (< (setq l (1+ l)) l2)
 	  (while (< (setq l (1+ l)) l2)
 	    (when (org-at-item-p)
 	    (when (org-at-item-p)
-	      (goto-char (match-beginning 2))
-	      (delete-region (match-beginning 2) (match-end 2))
-	      (and (looking-at "[ \t]+") (replace-match "")))
+	      (skip-chars-forward " \t")
+	      (delete-region (point) (match-end 0)))
 	    (beginning-of-line 2))
 	    (beginning-of-line 2))
 	(if (org-on-heading-p)
 	(if (org-on-heading-p)
 	    ;; Headings, convert to items
 	    ;; Headings, convert to items
 	    (while (< (setq l (1+ l)) l2)
 	    (while (< (setq l (1+ l)) l2)
 	      (if (looking-at org-outline-regexp)
 	      (if (looking-at org-outline-regexp)
-		  (replace-match "- " t t))
+		  (replace-match (org-list-bullet-string "-") t t))
 	      (beginning-of-line 2))
 	      (beginning-of-line 2))
 	  ;; normal lines, turn them into items
 	  ;; normal lines, turn them into items
 	  (while (< (setq l (1+ l)) l2)
 	  (while (< (setq l (1+ l)) l2)
 	    (unless (org-at-item-p)
 	    (unless (org-at-item-p)
 	      (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
 	      (if (looking-at "\\([ \t]*\\)\\(\\S-\\)")
-		  (replace-match "\\1- \\2")))
+		  (replace-match
+		   (concat "\\1" (org-list-bullet-string "-") "\\2"))))
 	    (beginning-of-line 2)))))))
 	    (beginning-of-line 2)))))))
 
 
 (defun org-toggle-heading (&optional nstars)
 (defun org-toggle-heading (&optional nstars)