Browse Source

Fix bug in comment-dwin when at a keyword

* lisp/org.el (org-mode): Set back comment-start-skip so comment-dwin
  can tell a keyword from a comment.
* testing/lisp/test-org.el: Add test.
Nicolas Goaziou 12 năm trước cách đây
mục cha
commit
53334042b5
2 tập tin đã thay đổi với 8 bổ sung1 xóa
  1. 1 0
      lisp/org.el
  2. 7 1
      testing/lisp/test-org.el

+ 1 - 0
lisp/org.el

@@ -5091,6 +5091,7 @@ The following commands are available:
   ;; Comments
   (org-set-local 'comment-use-syntax nil)
   (org-set-local 'comment-start "# ")
+  (org-set-local 'comment-start-skip "^\\s-*#\\(?: \\|$\\)")
   (org-set-local 'comment-insert-comment-function 'org-insert-comment)
   (org-set-local 'comment-region-function 'org-comment-or-uncomment-region)
   (org-set-local 'uncomment-region-function 'org-comment-or-uncomment-region)

+ 7 - 1
testing/lisp/test-org.el

@@ -332,7 +332,13 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
 	      (push-mark (point) t t)
 	      (goto-char (point-max))
 	      (call-interactively 'comment-dwim)
-	      (buffer-string))))))
+	      (buffer-string)))))
+  ;; In front of a keyword without region, insert a new comment.
+  (should
+   (equal "# \n#+KEYWORD: value"
+	  (org-test-with-temp-text "#+KEYWORD: value"
+	    (progn (call-interactively 'comment-dwim)
+		   (buffer-string))))))