diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 19decccc9..e245217b4 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -2882,15 +2882,10 @@ contextual information."
(defun org-odt--encode-tabs-and-spaces (line)
(replace-regexp-in-string
- "\\([\t]\\|\\([ ]+\\)\\)"
+ "\\(\t\\| \\{2,\\}\\)"
(lambda (s)
- (cond
- ((string= s "\t") "")
- (t (let ((n (length s)))
- (cond
- ((= n 1) " ")
- ((> n 1) (concat " " (format "" (1- n))))
- (t ""))))))
+ (if (string= s "\t") ""
+ (format " " (1- (length s)))))
line))
(defun org-odt--encode-plain-text (text &optional no-whitespace-filling)
@@ -3673,15 +3668,13 @@ channel."
"Transcode a VERSE-BLOCK element from Org to ODT.
CONTENTS is verse block contents. INFO is a plist holding
contextual information."
- ;; Add line breaks to each line of verse.
- (setq contents (replace-regexp-in-string
- "\\(\\)?[ \t]*\n"
- "" contents))
- ;; Replace tabs and spaces.
- (setq contents (org-odt--encode-tabs-and-spaces contents))
- ;; Surround it in a verse environment.
- (format "\n%s"
- "OrgVerse" contents))
+ (format "\n%s"
+ (replace-regexp-in-string
+ ;; Replace leading tabs and spaces.
+ "^[ \t]+" #'org-odt--encode-tabs-and-spaces
+ ;; Add line breaks to each line of verse.
+ (replace-regexp-in-string
+ "\\(\\)?[ \t]*$" "" contents))))