emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Bug: org-element-fixed-width-interpreter fails when given an empty s


From: David Beswick
Subject: [O] Bug: org-element-fixed-width-interpreter fails when given an empty string [8.0.1 (release_8.0.1-40-g38051c @ /home/david/git/home-common/emacs/foreign/org-mode/lisp/)]
Date: Thu, 25 Apr 2013 16:30:40 +1000

Hi, I encountered this problem when trying out org-sync with
Redmine. That package uses org-element to create "fixed-width" type
elements to contain the bug descriptions. When a bug had no description,
this problem would occur. In that case, org-element-property returns the
empty string for the ":value" property of the fixed-width element, and
the call to "substring" fails.

I also encountered the problem with org version [7.9.2
(release_7.9.2-1-ge003bd @
/home/david/git/home-common/emacs/foreign/org-mode/lisp/)]

As far as I can see, org-element.el head still has the problem. Here's
a patch for the issue.

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 73d0b46..bfc35a7 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -1834,8 +1834,11 @@ Assume point is at the beginning of the fixed-width area.
 (defun org-element-fixed-width-interpreter (fixed-width contents)
   "Interpret FIXED-WIDTH element as Org syntax.
 CONTENTS is nil."
-  (replace-regexp-in-string
-   "^" ": " (substring (org-element-property :value fixed-width) 0 -1)))
+  (let ((value (org-element-property :value fixed-width)))
+       (if (not (= (length value) 0))
+               (replace-regexp-in-string
+                "^" ": " (substring value 0 -1))
+         ": ")))


 ;;;; Horizontal Rule






Emacs  : GNU Emacs 23.4.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.12)
 of 2012-09-23 on allspice, modified by Debian
Package: Org-mode version 8.0.1 (release_8.0.1-40-g38051c @
/home/david/git/home-common/emacs/foreign/org-mode/lisp/)

current state:
==============
(setq
 org-agenda-clockreport-parameter-plist '(:link nil :maxlevel 3)
 org-speed-command-hook '(org-speed-command-default-hook
org-babel-speed-command-hook)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-clock-heading-function '(lambda nil (concat (buffer-name) " "
(org-clock-heading-function-default)))
 org-after-todo-statistics-hook '(org-summary-todo)
 org-tab-first-hook '(org-hide-block-toggle-maybe
org-src-native-tab-command-maybe
                      org-babel-hide-result-toggle-maybe
org-babel-header-arg-expand)
 org-src-mode-hook '(org-src-babel-configure-edit-buffer
org-src-mode-configure-edit-buffer)
 org-confirm-shell-link-function 'yes-or-no-p
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-babel-pre-tangle-hook '(save-buffer)
 org-cycle-hook '(org-cycle-hide-archived-subtrees
org-cycle-hide-drawers org-cycle-hide-inline-tasks
                  org-cycle-show-empty-lines
org-optimize-window-after-visibility-change)
 org-mode-hook '((lambda nil (local-unset-key (kbd "<C-tab>"))
(org-indent-mode 1) (visual-line-mode 1))
                 #[nil "\300\301\302\303\304$\207"
                   [org-add-hook change-major-mode-hook
org-show-block-all append local] 5]
                 #[nil "\300\301\302\303\304$\207"
                   [org-add-hook change-major-mode-hook
org-babel-show-result-all append local] 5]
                 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point
org-babel-execute-safely-maybe)
 org-confirm-elisp-link-function 'yes-or-no-p
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-occur-hook '(org-first-headline-recenter)
 org-from-is-user-regexp "\\<David\\>"
 org-clock-report-include-clocking-task t
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 )



reply via email to

[Prev in Thread] Current Thread [Next in Thread]