diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2015-09-10 11:11:15 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2015-09-10 11:12:20 +0200 |
commit | 62dc515ae520422fc35409232884ac6d9e3b3d74 (patch) | |
tree | b49607fb23d10a4d5df021ac7f68f62f7873f41c | |
parent | f051d663ab45b8bc26a98768d9287b74827e240f (diff) | |
download | org-mode-62dc515ae520422fc35409232884ac6d9e3b3d74.tar.gz |
ob-tangle: Fix commenting links at column 0
* lisp/ob-tangle.el (org-babel-spec-to-string): Ignore invisible
characters when commenting in destination file.
* testing/lisp/test-ob-tangle.el (ob-tangle/comment-links-at-left-margin):
New test.
Reported-by: Rainer M Krug <Rainer@krugs.de>
<http://permalink.gmane.org/gmane.emacs.orgmode/101002>
-rw-r--r-- | lisp/ob-tangle.el | 14 | ||||
-rw-r--r-- | testing/lisp/test-ob-tangle.el | 17 |
2 files changed, 26 insertions, 5 deletions
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index cf48db3..3852185 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -362,13 +362,17 @@ that the appropriate major-mode is set. SPEC has the form: (when (and comments (not (string= comments "no")) (> (length text) 0)) (if org-babel-tangle-uncomment-comments - ;; just plain comments with no processing + ;; Plain comments: no processing. (insert text) - ;; ensure comments are made to be - ;; comments, and add a trailing newline + ;; Ensure comments are made to be + ;; comments, and add a trailing + ;; newline. Also ignore invisible + ;; characters when commenting. (comment-region - (point) (progn (insert text) (point))) - (end-of-line nil) + (point) + (progn (insert (org-no-properties text)) + (point))) + (end-of-line) (insert "\n")))))) (when comment (funcall insert-comment comment)) (when link-p diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el index 8a8e2be..9367f03 100644 --- a/testing/lisp/test-ob-tangle.el +++ b/testing/lisp/test-ob-tangle.el @@ -77,6 +77,23 @@ (should (string-match (regexp-quote "simple") expanded)) (should (string-match (regexp-quote "length 14") expanded))))) +(ert-deftest ob-tangle/comment-links-at-left-margin () + "Test commenting of links at left margin." + (should + (string-match + (regexp-quote "# [[http://orgmode.org][Org mode]]") + (org-test-with-temp-text-in-file + "[[http://orgmode.org][Org mode]] +#+header: :comments org :tangle \"test-ob-tangle.sh\" +#+begin_src sh +echo 1 +#+end_src" + (unwind-protect + (progn (org-babel-tangle) + (with-temp-buffer (insert-file-contents "test-ob-tangle.sh") + (buffer-string))) + (delete-file "test-ob-tangle.sh")))))) + (provide 'test-ob-tangle) ;;; test-ob-tangle.el ends here |