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 8 years ago
parent
commit
302fdfd2b0
2 changed files with 8 additions and 1 deletions
  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))))))