emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Le Wang <l26wang@gmail.com>
To: Bastien <bzg@altern.org>
Cc: Bernt Hansen <bernt@norang.ca>, emacs-orgmode@gnu.org
Subject: Re: bug#12905: 24.2.50; org: edit source block causes data loss
Date: Fri, 14 Dec 2012 00:06:34 +0800	[thread overview]
Message-ID: <CAM=K+iq=x557g5VeUFRr4_ZdHznD=KTNGsy1O0JuCGrLZT8eRw@mail.gmail.com> (raw)
In-Reply-To: <87wqwm0yoi.fsf@bzg.ath.cx>

[-- Attachment #1: Type: text/plain, Size: 1289 bytes --]

On Thu, Dec 13, 2012 at 11:17 PM, Bastien <bzg@altern.org> wrote:
> Hi Le,
>
> No we don't.  If anyone knows how to set this up for our needs,
> please share.

I've only done this for projects hosted on github, others may have
more experience.  But having a continuous integration service is
definitely helpful.  For example, there were 10 failures when I ran
tests against master just now:

10 unexpected results:
   FAILED  ob-exp/exports-inline
   FAILED  ob-exp/noweb-strip-export-ensure-strips
   FAILED  test-ob/org-babel-remove-result--results-default
   FAILED  test-ob/org-babel-results-indented-wrap
   FAILED  test-org-babel/combining-scalar-and-raw-result-types
   FAILED  test-org-babel/inline-src-blocks
   FAILED  test-org-babel/inline-src_blk-default-results-replace-line-1
   FAILED  test-org-babel/just-one-results-block
   FAILED  test-org-babel/nested-code-block
   FAILED  test-org-babel/partial-nested-code-block

I haven't investigated further though.

> Whatever works -- we first need to make sure this fixes it and try
> to understand why ;)

I can confirm that copy-marker does not work as I've used it on Emacs 23.3.1.

> Thanks for taking care of this,

You're welcome.

I've attached 3 patches to fix this and another bug I found while writing tests.

-- 
Le

[-- Attachment #2: 0001-don-t-use-copy-marker-nil-t-for-Emacs-23-compat.patch --]
[-- Type: application/octet-stream, Size: 879 bytes --]

From 5b3e628b3bc8afd0c082faef059126b30d174d29 Mon Sep 17 00:00:00 2001
From: Le Wang <le.wang@agworld.com.au>
Date: Thu, 13 Dec 2012 23:40:59 +0800
Subject: [PATCH 1/3] don't use (copy-marker nil t) for Emacs 23 compat

---
 lisp/org-src.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index f91da19..6515987 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -230,7 +230,9 @@ buffer."
 	 (beg (make-marker))
 	 ;; Move marker with inserted text for case when src block is
 	 ;; just one empty line, i.e. beg == end.
-	 (end (copy-marker nil t))
+	 (end (let ((marker (make-marker)))
+		(set-marker-insertion-type marker t)
+		marker))
 	 (allow-write-back-p (null code))
 	 block-nindent total-nindent ovl lang lang-f single lfmt buffer msg
 	 begline markline markcol line col transmitted-variables)
-- 
1.7.11.4


[-- Attachment #3: 0002-fix-org-edit-src-code-invoked-outside-src-block.patch --]
[-- Type: application/octet-stream, Size: 1027 bytes --]

From 2e6dd57930dcb5b57d567855d0834df50de7e89e Mon Sep 17 00:00:00 2001
From: Le Wang <le.wang@agworld.com.au>
Date: Thu, 13 Dec 2012 23:46:00 +0800
Subject: [PATCH 2/3] fix org-edit-src-code invoked outside src block

---
 lisp/org-src.el | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 6515987..97f473a 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -221,10 +221,13 @@ buffer."
 	  (let* ((temp (org-edit-src-find-region-and-lang))
 		 (beg (nth 0 temp))
 		 (end (nth 1 temp)))
-	    (if (>= end beg) temp
-	      (goto-char beg)
-	      (insert "\n")
-	      (org-edit-src-find-region-and-lang))))
+	    (if (and beg end)
+		(if (>= end beg)
+		    temp
+		  (goto-char beg)
+		  (insert "\n")
+		  (org-edit-src-find-region-and-lang))
+	      (error "Point not in src block."))))
 	 (full-info (org-babel-get-src-block-info 'light))
 	 (org-mode-p (derived-mode-p 'org-mode)) ;; derived-mode-p is reflexive
 	 (beg (make-marker))
-- 
1.7.11.4


[-- Attachment #4: 0003-add-tests-for-org-src-edit.patch --]
[-- Type: application/octet-stream, Size: 2964 bytes --]

From 3299e5ce8cac9f3a0cbd912020955fc502d5ada7 Mon Sep 17 00:00:00 2001
From: Le Wang <le.wang@agworld.com.au>
Date: Thu, 13 Dec 2012 23:46:40 +0800
Subject: [PATCH 3/3] add tests for org-src-edit

---
 testing/lisp/test-org-src.el | 98 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 testing/lisp/test-org-src.el

diff --git a/testing/lisp/test-org-src.el b/testing/lisp/test-org-src.el
new file mode 100644
index 0000000..42b0f9e
--- /dev/null
+++ b/testing/lisp/test-org-src.el
@@ -0,0 +1,98 @@
+;;; test-org-src.el --- Tests for org-src.el
+
+;; Copyright (C) 2012  Le Wang
+
+;; Author: Le Wang <l26wang at gmail dot com>
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+(require 'org-test)
+
+\f
+
+(ert-deftest test-org-src/basic ()
+  "Editing regular block works. with point on
+
+#+begin_src line
+"
+  (org-test-with-temp-text
+   "
+#+begin_src emacs-lisp
+  (message hello)
+#+end_src
+"
+   (goto-line 2)
+   (org-edit-special)
+   (insert "blah")
+   (org-edit-src-exit)
+   (should (equal (buffer-string) "
+#+begin_src emacs-lisp
+  blah(message hello)
+#+end_src
+"))
+   (should (equal (word-at-point) "blah"))))
+
+(ert-deftest test-org-src/point-outside-block ()
+  "Editing with point before/after block signals expected error."
+  (org-test-with-temp-text
+      "
+#+begin_src emacs-lisp
+  (message hello)
+#+end_src
+"
+    (goto-line 1)
+    (should-error (org-edit-special))
+    (goto-char (point-max))
+    (should-error (org-edit-special))))
+
+(ert-deftest test-org-src/empty-block ()
+  "Editing empty block."
+  (org-test-with-temp-text
+      "
+#+begin_src emacs-lisp
+#+end_src
+"
+    (goto-line 2)
+    (org-edit-special)
+    (insert "blah")
+    (org-edit-src-exit)
+    (should (equal (buffer-string) "
+#+begin_src emacs-lisp
+  blah
+#+end_src
+"))
+    (should (equal (word-at-point) "blah"))))
+
+(ert-deftest test-org-src/blank-line-block ()
+  "Editing block with just a blank line."
+  (org-test-with-temp-text
+      "
+#+begin_src emacs-lisp
+
+#+end_src
+"
+    (goto-line 3)
+    (org-edit-special)
+    (insert "blah")
+    (org-edit-src-exit)
+    (should (equal (buffer-string) "
+#+begin_src emacs-lisp
+  blah
+#+end_src
+"))
+    (should (equal (word-at-point) "blah"))))
+
+(provide 'test-org-src)
+;;; test-org-src.el ends here
-- 
1.7.11.4


  reply	other threads:[~2012-12-13 16:06 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <50A62865.8010904@gmail.com>
2012-12-07 15:36 ` bug#12905: 24.2.50; org: edit source block causes data loss Chong Yidong
     [not found] ` <87sj7han8a.fsf__16482.9143243425$1354894646$gmane$org@gnu.org>
2012-12-12 16:55   ` Bastien
2012-12-12 21:05     ` Bernt Hansen
2012-12-12 21:34       ` Jonathan Leech-Pepin
2012-12-12 21:51         ` Bernt Hansen
2012-12-12 23:18       ` Bastien
2012-12-13  3:27         ` Bernt Hansen
2012-12-13  3:37           ` Bernt Hansen
2012-12-13  4:50             ` Nick Dokos
2012-12-13 12:45               ` Bernt Hansen
2012-12-13 13:41                 ` Bernt Hansen
2012-12-13 10:36             ` Bastien
2012-12-13 13:42               ` Bernt Hansen
2012-12-13 14:36                 ` Le Wang
2012-12-13 15:17                   ` Bastien
2012-12-13 16:06                     ` Le Wang [this message]
2012-12-13 16:25                       ` Bastien
2012-12-13 23:40                         ` Le Wang
2012-12-13 23:50                           ` Le Wang
2012-12-14  9:38                           ` Bastien
2012-12-14  9:39                           ` Bastien
2012-12-16 14:39                             ` Le Wang
2012-12-14  9:40                           ` Bastien
2012-12-13 13:48               ` Bernt Hansen
2012-12-13 16:05                 ` Bastien
2012-12-14  0:04                   ` Bernt Hansen
2012-12-14  9:35                     ` Bastien
2012-12-14  9:57                     ` Le Wang
     [not found]   ` <87wqwnyzud.fsf@bzg.ath.cx>
2012-12-12 17:39     ` Andy Moreton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAM=K+iq=x557g5VeUFRr4_ZdHznD=KTNGsy1O0JuCGrLZT8eRw@mail.gmail.com' \
    --to=l26wang@gmail.com \
    --cc=bernt@norang.ca \
    --cc=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).