From: Ippei FURUHASHI <top.tuna+orgmode@gmail.com>
To: Bastien <bzg@altern.org>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Was: How to apply multiple TBLFM rules?
Date: Sat, 06 Apr 2013 22:07:10 +0900 [thread overview]
Message-ID: <801uanbyf5.fsf@gmail.com> (raw)
In-Reply-To: <878v4y1lyw.fsf@bzg.ath.cx> (Bastien's message of "Thu, 04 Apr 2013 15:09:27 +0200")
[-- Attachment #1: Type: text/plain, Size: 262 bytes --]
Hi Bastien,
Thanks for looking at these patch.
I found a bug introduced at
http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=bd8ff1aade6c46f701f466035ef75ab8ee82c8fe
which I made.
Could you apply this (attached) patch for them please?
Thanks in advance,
IP
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-table.el-Fix-a-bug-of-leaving-the-inserted-TBLFM.patch --]
[-- Type: text/x-patch, Size: 2812 bytes --]
From 24a18f1ffdc38dfd297960d9b06a12f35a256e82 Mon Sep 17 00:00:00 2001
From: Ippei FURUHASHI <top.tuna+orgmode@gmail.com>
Date: Fri, 5 Apr 2013 16:07:00 +0900
Subject: [PATCH] org-table.el: Fix a bug of leaving the inserted TBLFM line
* org-table.el (org-calc-current-TBLFM): Ensure to remove the
currently inserted TBLFM line, when calling `org-table-recalculate'
returns an error and the processing stops.
* testing/lisp/test-org-table.el: Add test.
When you hit =C-c C-c= at the line of "#+TBLFM: $2=$1*2::$2=$1**2" in
| 1 | |
| 2 | |
#+TBLFM: $2=$1*1
#+TBLFM: $2=$1*2::$2=$1**2
you got:
| 1 | |
| 2 | |
#+TBLFM: $2=$1*2::$2=$1**2
#+TBLFM: $2=$1*1
#+TBLFM: $2=$1*2::$2=$1**2
with the error message of:
user-error: Double definition `$2=' in TBLFM line, please fix by hand
In this case, you expected:
| 1 | |
| 2 | |
#+TBLFM: $2=$1*1
#+TBLFM: $2=$1*2::$2=$1**2
---
lisp/org-table.el | 7 ++++---
testing/lisp/test-org-table.el | 25 +++++++++++++++++++++++++
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/lisp/org-table.el b/lisp/org-table.el
index ccd1735..460d249 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -3190,10 +3190,11 @@ (defun org-calc-current-TBLFM (&optional arg)
(beginning-of-line 0) ; move to the inserted line
(skip-chars-backward " \r\n\t")
(if (org-at-table-p)
- (org-call-with-arg 'org-table-recalculate (or arg t)))
+ (unwind-protect
+ (org-call-with-arg 'org-table-recalculate (or arg t))
- ;; Delete the formula inserted temporarily
- (delete-region s e))))
+ ;; delete the formula inserted temporarily
+ (delete-region s e))))))
(defun org-TBLFM-begin ()
"Find the beginning of the TBLFM lines and return its position.
diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el
index dda8561..01adf52 100644
--- a/testing/lisp/test-org-table.el
+++ b/testing/lisp/test-org-table.el
@@ -929,6 +929,31 @@ (defconst references/target-special "
(should (string= got
expect)))))
+(ert-deftest test-org-table/org-calc-current-TBLFM-when-stop-because-of-error ()
+ "org-calc-current-TBLFM should preserve the input as it was."
+ (org-test-with-temp-text-in-file
+ "
+| 1 | 1 |
+| 2 | 2 |
+#+TBLFM: $2=$1*1
+#+TBLFM: $2=$1*2::$2=$1*2
+#+TBLFM: $2=$1*3
+"
+ (let ((expect "
+| 1 | 1 |
+| 2 | 2 |
+#+TBLFM: $2=$1*1
+#+TBLFM: $2=$1*2::$2=$1*2
+#+TBLFM: $2=$1*3
+"))
+ (goto-char (point-min))
+ (forward-line 4)
+ (should-error (org-calc-current-TBLFM))
+ (setq got (buffer-string))
+ (message "%s" got)
+ (should (string= got
+ expect)))))
+
(provide 'test-org-table)
;;; test-org-table.el ends here
--
1.7.9.msysgit.0
[-- Attachment #3: Type: text/plain, Size: 327 bytes --]
Bastien <bzg@altern.org> writes:
>> This patch enables user to applies a temporal TBLFM line where you are in.
>> It is useful when you switch a formula to another.
>> I hope you liked this.
>
> I do! I've applied the patches (with some minor changes) on my local
> branch, it will be available when I push it later today.
next prev parent reply other threads:[~2013-04-06 13:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-07 22:00 How to apply multiple TBLFM rules? Michael Hannon
2012-05-08 1:01 ` Charles
2012-05-08 1:41 ` Michael Hannon
2012-05-08 8:11 ` Bastien
2012-05-08 20:21 ` Michael Hannon
2012-05-10 6:52 ` Bastien
2013-04-02 13:33 ` [PATCH] Was: " Ippei FURUHASHI
2013-04-04 13:09 ` Bastien
2013-04-06 13:07 ` Ippei FURUHASHI [this message]
2013-04-06 13:15 ` Bastien
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=801uanbyf5.fsf@gmail.com \
--to=top.tuna+orgmode@gmail.com \
--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).