Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

org-mode source examples #66

Closed
rvf0068 opened this Issue Nov 27, 2011 · 10 comments

Comments

Projects
None yet
4 participants

rvf0068 commented Nov 27, 2011

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

Collaborator

punchagan commented Dec 6, 2011

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

ummae commented Feb 19, 2012

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("<pre class="example">testprograms
{
a
}

$ a=f(x) $

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

")
(setq html-text (org2blog/wp-replace-pre html-text))
(progn (setq html-text (org2blog/wp-replace-pre html-text)))
(if sourcecode-shortcode (progn (setq html-text ...)))
(when sourcecode-shortcode (setq html-text (org2blog/wp-replace-pre html-text)))
(save-excursion (if (not org2blog/wp-mode) (org-save-outline-visibility ... ...) (org-save-outline-visibility ... ...) (org2blog/wp-mode t)) (setq narrow-p (not ...)) (if narrow-p (progn ... ... ... ... ... ... ... ... ...) (setq post-title ...) (setq excerpt ...) (setq permalink ...) (setq post-id ...) (setq post-par ...) (setq post-date ...) (setq tags ...) (setq tags ...) (setq categories ...) (setq categories ...)) (setq cur-time (format-time-string ... ...)) (setq post-date (format-time-string "%Y%m%dT%T%z" ... t)) (if (if ... ... org2blog/wp-use-tags-as-categories) (setq categories tags tags nil)) (save-excursion (if ... ... ...) (setq html-text ...)) (setq html-text (org2blog/wp-upload-files-replace-urls html-text)) (unless keep-new-lines (setq html-text ...)) (when sourcecode-shortcode (setq html-text ...)) (when wp-latex (setq html-text ...)))
(save-restriction (save-excursion (if ... ... ... ...) (setq narrow-p ...) (if narrow-p ... ... ... ... ... ... ... ... ... ... ...) (setq cur-time ...) (setq post-date ...) (if ... ...) (save-excursion ... ...) (setq html-text ...) (unless keep-new-lines ...) (when sourcecode-shortcode ...) (when wp-latex ...)))
(let
((keep-new-lines ...) (wp-latex ...) (sourcecode-shortcode ...) html-text post-title post-id post-date tags categories narrow-p cur-time post-par) (save-restriction (save-excursion ... ... ... ... ... ... ... ... ... ... ...)) (list (cons "point" ...) (cons "subtree" narrow-p) (cons "date" post-date) (cons "title" ...) (cons "tags" tags) (cons "categories" categories) (cons "post-id" post-id) (cons "parent" post-par) (cons "excerpt" ...) (cons "permalink" ...) (cons "description" html-text)))
org2blog/wp-parse-entry()
(let ((post ...) (confirm ...) (show ...) post-id) (org2blog/wp-create-categories (cdr ...)) (setq post-id (cdr ...)) (when confirm (if ... ...)) (if post-id (metaweblog-edit-post org2blog/wp-server-xmlrpc-url org2blog/wp-server-userid org2blog/wp-server-pass post-id post publish) (setq post-id ...) (if ... ... ... ...)) (org2blog/wp-save-details post post-id publish) (message (if publish "Published (%s): %s" "Draft (%s): %s") post-id (cdr ...)) (when (or ... ...) (if ... ... ...)))
(save-restriction (let (... ... ... post-id) (org2blog/wp-create-categories ...) (setq post-id ...) (when confirm ...) (if post-id ... ... ...) (org2blog/wp-save-details post post-id publish) (message ... post-id ...) (when ... ...)))
(save-excursion (save-restriction (let ... ... ... ... ... ... ... ...)))
org2blog/wp-post-buffer(nil)
call-interactively(org2blog/wp-post-buffer nil nil)

any idea?

tott commented Feb 27, 2012

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

Collaborator

punchagan commented Feb 27, 2012

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

tott commented Feb 27, 2012


#+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

Collaborator

punchagan commented Feb 27, 2012

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.

rvf0068 commented Feb 27, 2012

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

tott commented Feb 27, 2012

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

Collaborator

punchagan commented Feb 27, 2012

Oh great! Need to get it updated. Wonder who maintains it...
On Feb 27, 2012 11:51 PM, "tott" <
reply@reply.github.com>
wrote:

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


Reply to this email directly or view it on GitHub:
punchagan#66 (comment)

Collaborator

punchagan commented Feb 28, 2012

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

@punchagan punchagan closed this Feb 28, 2012

@punchagan punchagan referenced this issue in senior/org2blog Feb 28, 2012

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