GNU Emacs 24.5.1 (i686-pc-mingw32)

Org-mode version 8.2.10 (release_8.2.10 @ e:/emacs/share/emacs/24.5/lisp/org/)

In my org file,

1. one thing
   #+begin_src sh
   ls -la
2. second thing

But when I export html, it shows:

  1. one thing

    ls -la

1 second thing

This happens when I use Yasnippet, some lines can't be indent. For example,

#+begin_src dot :file xx :cmdline -Tpdf :exports none :results silent

The [[file:xx]] can't forcely indent.

Update-2015-12-9 enter image description here

  • Your exports as expected for me, what are your emacs and org versions? Nov 19 '15 at 20:51
  • @biondo GNU Emacs 24.5.1 Org-mode version 8.2.10
    – yuxuan
    Nov 19 '15 at 21:50
  • Does work as expected for me with the same versions (emacs 24.5.1, org-mode 8.2.10). Does your file contain exactly that?
    – JeanPierre
    Nov 22 '15 at 16:41
  • @JeanPierre I repeat my procedure. And I find the reason is that I copy the text #+begin_src sh ls -la #+end_src. So it interrupt the number list. I success only whey I manually type this code. So it obviously different in the format. Then when I encounter the problem that the number list was interrupted. How can I recover that number list?
    – yuxuan
    Nov 22 '15 at 16:53
  • Make sure you indent the lines between the numbered ones.
    – JeanPierre
    Nov 22 '15 at 17:04

This is an org-mode-bug.

The problem is that the case of "Lists" is handled before "Special blocks" in org-indent-line.

If you exchange these cases the tab-indentation behaves better.

The corrected code for org-indent-line in org-mode 8.2.10 is:

(require 'org)
(if (equal (mapcar 'string-to-number (split-string org-version "\\.")) '(8 2 10))
    (defun org-indent-line ()
      "Indent line depending on context."
      (let* ((pos (point))
         (itemp (org-at-item-p))
         (case-fold-search t)
         (org-drawer-regexp (or org-drawer-regexp "\000"))
         (inline-task-p (and (featurep 'org-inlinetask)
         (inline-re (and inline-task-p
    (if (and orgstruct-is-++ (eq pos (point)))
        (let ((indent-line-function (cadadr (assoc 'indent-line-function org-fb-vars))))
      (beginning-of-line 1)
       ;; Headings
       ((looking-at org-outline-regexp) (setq column 0))
       ;; Footnote definition
       ((looking-at org-footnote-definition-re) (setq column 0))
       ;; Literal examples
       ((looking-at "[ \t]*:\\( \\|$\\)")
        (setq column (org-get-indentation))) ; do nothing
       ;; Drawers
       ((and (looking-at "[ \t]*:END:")
         (save-excursion (re-search-backward org-drawer-regexp nil t)))
          (goto-char (1- (match-beginning 1)))
          (setq column (current-column))))
       ;; Special blocks
       ((and (looking-at "[ \t]*#\\+end_\\([a-z]+\\)")
            (concat "^[ \t]*#\\+begin_" (downcase (match-string 1))) nil t)))
        (setq column (org-get-indentation (match-string 0))))
       ((and (not (looking-at "[ \t]*#\\+begin_"))
         (org-between-regexps-p "^[ \t]*#\\+begin_" "[ \t]*#\\+end_"))
          (re-search-backward "^[ \t]*#\\+begin_\\([a-z]+\\)" nil t))
        (setq column
          (cond ((equal (downcase (match-string 1)) "src")
             ;; src blocks: let `org-edit-src-exit' handle them
            ((equal (downcase (match-string 1)) "example")
             (max (org-get-indentation)
                  (org-get-indentation (match-string 0))))
             (org-get-indentation (match-string 0))))))
       ;; Lists
       ((ignore-errors (goto-char (org-in-item-p)))
        (setq column (if itemp
               (org-list-item-body-column (point))))
        (goto-char pos))
       ;; This line has nothing special, look at the previous relevant
       ;; line to compute indentation
        (beginning-of-line 0)
        (while (and (not (bobp))
            (not (looking-at org-table-line-regexp))
            (not (looking-at org-drawer-regexp))
            ;; When point started in an inline task, do not move
            ;; above task starting line.
            (not (and inline-task-p (looking-at inline-re)))
            ;; Skip drawers, blocks, empty lines, verbatim,
            ;; comments, tables, footnotes definitions, lists,
            ;; inline tasks.
            (or (and (looking-at "[ \t]*:END:")
                 (re-search-backward org-drawer-regexp nil t))
                (and (looking-at "[ \t]*#\\+end_")
                 (re-search-backward "[ \t]*#\\+begin_"nil t))
                (looking-at "[ \t]*[\n:#|]")
                (looking-at org-footnote-definition-re)
                (and (not inline-task-p)
                 (featurep 'org-inlinetask)
                 (or (org-inlinetask-goto-beginning) t))))
          (beginning-of-line 0))
         ;; There was a list item above.
         ((ignore-errors (goto-char (org-in-item-p)))
          (goto-char (org-list-get-top-point (org-list-struct)))
          (setq column (org-get-indentation)))
         ;; There was an heading above.
         ((looking-at "\\*+[ \t]+")
          (if (not org-adapt-indentation)
          (setq column 0)
        (goto-char (match-end 0))
        (setq column (current-column))))
         ;; A drawer had started and is unfinished
         ((looking-at org-drawer-regexp)
          (goto-char (1- (match-beginning 1)))
          (setq column (current-column)))
         ;; Else, nothing noticeable found: get indentation and go on.
         (t (setq column (org-get-indentation))))))
      ;; Now apply indentation and move cursor accordingly
      (goto-char pos)
      (if (<= (current-column) (current-indentation))
          (org-indent-line-to column)
        (save-excursion (org-indent-line-to column)))
      ;; Special polishing for properties, see `org-property-format'
      (setq column (current-column))
      (beginning-of-line 1)
      (if (looking-at org-property-re)
          (replace-match (concat (match-string 4)
                     (format org-property-format
                         (match-string 1) (match-string 3)))
                 t t))
      (org-move-to-column column))))
  (error "Bugfix of `org-indent-line' is for org-version 8.2.10 only."))

Note, this source code is not tested thoroughly because of lack of time.

If this is not corrected in higher org-mode versions one should issue a bug-report.

Remark on your Update-2015-12-9: With this fix you still need to add a space in front of [[file:xx]] to get it indented correctly.


You can use [@num] syntax described in Plain lists. Below is an example on how to use it according to your needs.

1. first thing
2. second thing

#+BEGIN_SRC python
print("Insert a block of code")

3. [@3] third thing


10. [@4] fourth thing

5. fifth thing

As you can see, after renumbering the list, what matters is that the number after @.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.