emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eike <eike@eknet.org>
To: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: [PATCH] ob-core: check argument to goto-char
Date: Sat, 30 Apr 2016 13:05:40 +0200	[thread overview]
Message-ID: <87d1p79x17.fsf@eknet.org> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 546 bytes --]


Hi,

I have some code that uses `org-babel-insert-result' and I've found that
evaluating for example

   (org-babel-insert-result "a")

results in an error. The reason is that `goto-char' is called with a nil
argument. I simply put the snippet in a `when' clause, but since the
function is quite large I'm not so sure if it's now doing always the
correct thing. At least my org files seem still to work….

I've added the patch in case it is ok to be applied. Maybe someone can
have a look at it.

Thanks and regards
Eike



[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 212 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-core-check-argument-to-goto-char.patch --]
[-- Type: text/x-patch, Size: 1031 bytes --]

From fd2182dd3edfb4887cb272a5c93c72660eac0efe Mon Sep 17 00:00:00 2001
From: Eike Kettner <eike.kettner@posteo.de>
Date: Sat, 30 Apr 2016 12:59:41 +0200
Subject: [PATCH] ob-core: check argument to `goto-char'

The argument to `goto-char' must not be nil, which occurs if
`org-element-property' is called with nil element argument.
---
 lisp/ob-core.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 71c7aea..088f744 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2210,8 +2210,10 @@ INFO may provide the values of these header arguments (in the
 	      (progn
 		(when outside-scope (widen))
 		(if existing-result (goto-char existing-result)
-		  (goto-char (org-element-property :end inline))
-		  (skip-chars-backward " \t"))
+		  (let ((end (org-element-property :end inline)))
+		    (when end
+		      (goto-char end)
+		      (skip-chars-backward " \t"))))
 		(unless inline
 		  (setq indent (org-get-indentation))
 		  (forward-line 1))
-- 
2.7.4


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


-- 
gpg: AD7AC35E
finger print: 137F BB0B 1639 D25F DC5D E59C B412 C5F5 AD7A C35E

             reply	other threads:[~2016-04-30 11:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-30 11:05 Eike [this message]
2016-04-30 17:38 ` [PATCH] ob-core: check argument to goto-char Charles C. Berry
2016-04-30 18:47   ` Eike
2016-04-30 21:15     ` Charles C. Berry
2016-04-30 21:24       ` Nicolas Goaziou
2016-04-30 23:08         ` Eike
2016-04-30 21:40       ` Eike

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=87d1p79x17.fsf@eknet.org \
    --to=eike@eknet.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).