Skip to content
This repository

org-mode source examples #66

Closed
rvf0068 opened this Issue · 10 comments

4 participants

Rafael Villarroel Puneeth Chaganti KwangSeob Kim Thorsten Ott
Rafael Villarroel

When trying to post a source code block containing org-mode code, I get an error: Args out of range.
This with emacs 23.3.1 and latest org and org2blog. I think the problem is related to the commas that
the source code editor adds to escape the org-mode code inside the example, since without them, the
post works fine.

#+POSTID: 145
#+DATE: [2011-11-26 Sat 18:22]
#+OPTIONS: toc:nil num:nil todo:nil pri:nil tags:nil ^:nil TeX:nil
#+CATEGORY: Testing
#+TAGS:
#+DESCRIPTION:
#+TITLE: Hello, World

  • An org mode code example

#+begin_src org
,#+title: Hello

,* This is an example
#+end_src

Puneeth Chaganti
Owner

Rafael, Sorry I haven't been able to reproduce this.

KwangSeob Kim

I got same problem.

When I turn on org2blog/wp-use-sourcecode-shortcode, I get an error: Args out of range. It works well without org2blog/wp-use-sourcecode-shortcode with t.

this is my backtrace log:

replace-match("
[sourcecode language=\"cpp\" light=\"true\"]
testprograms
{
a
}
[/sourcecode]
" nil t)
(progn (re-search-forward src-re nil t 1) (setq pos (point)) (replace-match (concat "
[sourcecode language=\"" lang "\" " ... "]
" code "[/sourcecode]
") nil t))
(unwind-protect (progn (re-search-forward src-re nil t 1) (setq pos ...) (replace-match ... nil t)) (set-match-data save-match-data-internal (quote evaporate)))
(let ((save-match-data-internal ...)) (unwind-protect (progn ... ... ...) (set-match-data save-match-data-internal ...)))
(save-match-data (re-search-forward src-re nil t 1) (setq pos (point)) (replace-match (concat "
[sourcecode language=\"" lang "\" " ... "]
" code "[/sourcecode]
") nil t))
(progn (insert html) (goto-char pos) (save-match-data (re-search-forward src-re nil t 1) (setq pos ...) (replace-match ... nil t)) (setq html (buffer-substring-no-properties ... ...)))
(unwind-protect (progn (insert html) (goto-char pos) (save-match-data ... ... ...) (setq html ...)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
(save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ... ... ... ...) (and ... ...)))
(with-current-buffer temp-buffer (unwind-protect (progn ... ... ... ...) (and ... ...)))
(let ((temp-buffer ...)) (with-current-buffer temp-buffer (unwind-protect ... ...)))
(with-temp-buffer (insert html) (goto-char pos) (save-match-data (re-search-forward src-re nil t 1) (setq pos ...) (replace-match ... nil t)) (setq html (buffer-substring-no-properties ... ...)))
(save-excursion (with-temp-buffer (insert html) (goto-char pos) (save-match-data ... ... ...) (setq html ...)))
(while (re-search-forward org-babel-src-block-regexp nil t 1) (backward-word) (setq info (org-babel-get-src-block-info)) (setq params (nth 2 info)) (setq code (nth 1 info)) (setq lang (nth 0 info)) (unless (member lang org2blog/wp-sourcecode-langs) (setq lang "text")) (setq code-re (regexp-quote ...)) (setq src-re (concat "\[sourcecode\]
" code-re "\(
\)\[/sourcecode\]")) (save-excursion (with-temp-buffer ... ... ... ...)))
(let (pos code lang info params src-re code-re) (with-temp-buffer (insert html) (goto-char ...) (save-match-data ...) (setq html ...)) (goto-char (point-min)) (setq pos 1) (while (re-search-forward org-babel-src-block-regexp nil t 1) (backward-word) (setq info ...) (setq params ...) (setq code ...) (setq lang ...) (unless ... ...) (setq code-re ...) (setq src-re ...) (save-excursion ...)))
(save-excursion (let (pos code lang info params src-re code-re) (with-temp-buffer ... ... ... ...) (goto-char ...) (setq pos 1) (while ... ... ... ... ... ... ... ... ... ...)))
org2blog/wp-replace-pre("

testprograms
{
a
}

$ a=f(x) $

\begin{equation} b = f(f(a)) \end{equation}

Thorsten Ott

I run into the same issue.

Debugger entered--Lisp error: (args-out-of-range 0 13)
  replace-match("\n[sourcecode language=\"text\" light=\"true\"]\n(defun open-in-largest-window()\n  \"Open current buffer in largest window\"\n  (interactive)\n  (let ((oldbuf (current-buffer)))\n  (select-window (get-largest-window))\n  (switch-to-buffer oldbuf))\n)\n(global-set-key (kbd \"C-x 5\") 'open-in-largest-window)[/sourcecode]\n" nil t)
  org2blog/wp-replace-pre("<pre class=\"example\">(defun open-in-largest-window()\n  \"Open current buffer in largest window\"\n  (interactive)\n  (let ((oldbuf (current-buffer)))\n  (select-window (get-largest-window))\n  (switch-to-buffer oldbuf))\n)\n(global-set-key (kbd \"C-x 5\") 'open-in-largest-window)\n</pre>  ")
  org2blog/wp-parse-entry()
  org2blog/wp-post-buffer(nil)
  call-interactively(org2blog/wp-post-buffer nil nil)

#+BEGIN_HTML and #+BEGIN_EXAMPLE work fine. It also works when disabling org2blog/wp-use-sourcecode-shortcode

Puneeth Chaganti
Owner

@tott can you share the post which causes this problem?

Also, which version of org-mode, org2blog and emacs are you using? I would really like to fix this.

Thorsten Ott
#+POSTID: 15918
#+DATE: [2012-02-27 Mon 15:38]
#+OPTIONS: toc:nil num:nil todo:nil pri:nil tags:nil ^:nil TeX:nil
#+CATEGORY: emacs
#+TAGS: .emacs, window, buffer, switch, largest window
#+DESCRIPTION: open current buffer in largest emacs window
#+TITLE: Open current buffer in largest window

#+BEGIN_SRC text :exports code
(defun open-in-largest-window()
  "Open current buffer in largest window"
  (interactive)
  (let ((oldbuf (current-buffer)))
  (select-window (get-largest-window))
  (switch-to-buffer oldbuf))
)
(global-set-key (kbd "C-x 5") 'open-in-largest-window)
#+END_SRC

I'm running org2blog 0.4 with org mode 7.8.03 on a compiled Aquamacs trunk with emacs 24

Puneeth Chaganti
Owner

I haven't been able to reproduce it with the latest version of org2blog and orgmode on emacs 23.3.1
I'll try to get my hands on emacs 24.

Rafael Villarroel

I had not tried this recently, but now I can report that both my original example and tott's work fine for me now.

I get this without errors: http://rvftestblog.wordpress.com/2012/02/27/open-current-buffer-in-largest-window/.

with org pulled like 4 hours ago and updated org2blog with

GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.21.6) of 2010-09-01 on rhenium, modified by Debian

in Ubuntu

Thorsten Ott

Yay! Just tried the current git version. This works. I had the elpa version before which did not work.

Puneeth Chaganti
Owner
Puneeth Chaganti
Owner

Ok, I'm closing this issue and incrementing the version of org2blog, so that package bundles like Marmalade can be updated.

Puneeth Chaganti punchagan referenced this issue in senior/org2blog
Merged

Update the package on Marmalade #1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.