emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* small bug in table alignment
@ 2013-03-14  8:43 Eric Abrahamsen
  2013-03-14 11:23 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Abrahamsen @ 2013-03-14  8:43 UTC (permalink / raw)
  To: emacs-orgmode

If you call "C-c C-c" within a table to align it, and point happens to
be on a horizontal rule, it throws an error that originates in
org-element-context.

The let at the top of that function sets "type" to 'table-row, and
"element" to:

(table-row (:type rule :begin XX :end XX :contents-begin nil :contents-end nil etc...))

Then on line 4749 comes:

  (and (memq type '(paragraph table-row verse-block))
       (let ((cbeg (org-element-property
		    :contents-begin element))
	     (cend (org-element-property
		    :contents-end element)))
	 (and (>= origin cbeg)
	      (<= origin cend)
	      (progn (goto-char cbeg) (setq end cend)))))

"cbeg" and "cend" are nil, and strenuously object to being compared
using >= or <=.

I'm not sure what the context of a table rule ought to be, but it will
need to be something with a non-nil :contents-begin value, since that
gets called in `org-ctrl-c-ctrl-c' as well.

Hope that's enough info...

Eric

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: small bug in table alignment
  2013-03-14  8:43 small bug in table alignment Eric Abrahamsen
@ 2013-03-14 11:23 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2013-03-14 11:23 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: emacs-orgmode

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

Hi Eric,

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> If you call "C-c C-c" within a table to align it, and point happens to
> be on a horizontal rule, it throws an error that originates in
> org-element-context.

This is now fixed with the attached patch, thanks for reporting
this bug.

If think `org-element-table-row-parser' is doing the right thing by
not assigning a :contents-begin and a :contents-end to table rules,
as they have no content.  

So the fix should go directly in `org-element-context'.  Just stating
this in case Nicolas wants to double-check.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-element.el-org-element-context-Prevent-an-error-.patch --]
[-- Type: text/x-patch, Size: 1032 bytes --]

From 5046137401779d6be0d68631b448644a868e03fb Mon Sep 17 00:00:00 2001
From: Bastien Guerry <bzg@altern.org>
Date: Thu, 14 Mar 2013 12:19:41 +0100
Subject: [PATCH] org-element.el (org-element-context): Prevent an error when
 getting the context of a table rule

* org-element.el (org-element-context): Prevent an error when
getting the context of a table rule.

Thanks to Eric Abrahamsen for reporting this bug.
---
 lisp/org-element.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 6810b98..ba2461a 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -4751,7 +4751,8 @@ Providing it allows for quicker computation."
 				    :contents-begin element))
 			     (cend (org-element-property
 				    :contents-end element)))
-			 (and (>= origin cbeg)
+			 (and cbeg cend ; cbeg is nil for table rules
+			      (>= origin cbeg)
 			      (<= origin cend)
 			      (progn (goto-char cbeg) (setq end cend)))))
 		  (and (eq type 'keyword)
-- 
1.8.1.4


[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-14 11:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-14  8:43 small bug in table alignment Eric Abrahamsen
2013-03-14 11:23 ` Bastien

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).