org-mode export 代码缩进问题

我用org-mode 导出成html,但是org file中的文件代码缩进失效了,变成了这样

应该怎么解决呢?求助

不清楚怎么回事,可能跟你的代码本身缩进有关系,比如同时 TAB 和 Space 缩进的话,可能只有在 Emacs 里看正常的。你可以把你的 Org 文件的相关部分贴出来瞧一瞧。

(use-package org
  :ensure t
  :mode ("\\.org\\'" . org-mode)
  :init (progn
	  (add-hook 'org-src-mode-hook 'samray/disable-flycheck-in-org-src-block)
          (setq org-todo-keyword-faces
                '(
                  ("PROCESSING" . (:foreground "gold" :weight bold))
                  ))
          (setq org-todo-keywords
                '((sequence "TODO" "PROCESSING" "DONE")))
          (setq org-priority-faces '((?A . (:foreground "red" :weight 'bold))
                                     (?B . (:foreground "blue"))
                                     (?C . (:foreground "green"))))
          (defun samray/org-skip-subtree-if-priority (priority)
            "Skip an agenda subtree if it has a priority of PRIORITY.
PRIORITY may be one of the characters ?A, ?B, or ?C."
            (let ((subtree-end (save-excursion (org-end-of-subtree t)))
                  (pri-value (* 1000 (- org-lowest-priority priority)))
                  (pri-current (org-get-priority (thing-at-point 'line t))))
              (if (= pri-value pri-current)
                  subtree-end
                nil)))
	  )
  :config(progn
	   (with-eval-after-load 'org
             (require 'ob-python)
             (org-babel-do-load-languages
              'org-babel-load-languages
              '((clojure . t)
                (lisp . t)
                (org . t)
                (js . t)
                (latex . t)
                (ruby . t)
                (shell . t)
                (python . t)
                (emacs-lisp . t)
                (awk . t)
                (sql . t)
                (sqlite . t)))
	     (setq org-agenda-files '("~/SyncDirectory/Org/agenda.org" "~/SyncDirectory/Org/todo.org"))
	     (setq org-agenda-custom-commands
		   '(("c" "agenda view with alltodo sorted by priorities"
		      ((tags "PRIORITY=\"A\""
			     ((org-agenda-skip-function '(org-agenda-skip-entry-if 'todo 'done))
			      (org-agenda-overriding-header "High-priority unfinished tasks:")))
		       (agenda "")
		       (alltodo ""
				((org-agenda-skip-function
				  '(or (samray/org-skip-subtree-if-priority ?A)
				       (org-agenda-skip-if nil '(scheduled deadline))))))))))
	     ;;each time you turn an entry from a TODO (not-done) state
	     ;;into any of the DONE states, a line ‘CLOSED: [timestamp]’ will
	     ;;be inserted just after the headline
	     (setq org-log-done 'time)
	     (setq org-capture-templates
		   '(("a" "Agenda" entry (file  "~/SyncDirectory/Org/agenda.org" "Agenda")
		      "* TODO %?\n:PROPERTIES:\n\n:END:\nDEADLINE: %^T \n %i\n")
		     ("n" "Note" entry (file+headline "~/SyncDirectory/Org/notes.org" "Notes")
		      "* Note %?\n%T")
		     ("l" "Link" entry (file+headline "~/SyncDirectory/Org/links.org" "Links")
		      "* %? %^L %^g \n%T" :prepend t)
		     ("b" "Blog idea" entry (file+headline "~/SyncDirectory/Org/blog.org" "Blog Topics:")
		      "* %?\n%T" :prepend t)
		     ("t" "To Do Item" entry (file+headline "~/SyncDirectory/Org/todo.org" "To Do Items")
		      "* TODO  %?\n  %i\n" :prepend t)
		     ("j" "Journal" entry (file+datetree "~/SyncDirectory/Org/journal.org")
		      "* %?\nEntered on %U\n  %i\n  %a")
		     ))
	     ;;GUI Emacs could display image.But if the image is too large,
	     ;;it works so weird
	     (setq org-image-actual-width '(500))
	     ;; make sure org-mode syntax highlight source code
	     ;; Make TAB act as if it were issued in a buffer of the
	     ;;language’s major mode.
	     (setq org-src-fontify-natively t
		   org-src-tab-acts-natively t)
             ;; When editing a code snippet,use the current window rather than
	     ;; popping open a new one
	     (setq org-src-window-setup 'current-window)
	     ;; I like seeing a little downward-pointing arrow instead of the
	     ;;usual ellipsis (...) that org displays when there’s stuff under
	     ;; a header.
             (setq org-ellipsis "⤵")
             ;;Its default value is (ascii html icalendar latex)
             (setq org-export-backends '(latex icalendar))
             ;; Show org-edit-special in the other-window
             (setq org-src-window-setup 'other-window)
             ;; use minted to highlight code in latex
             (add-to-list 'org-latex-packages-alist '("" "minted"))
             (setq org-latex-listings 'minted)
             ;; execute code without confirm
             (setq org-confirm-babel-evaluate nil)
             ;; set latex to xelatex
             ;; org-mode 8.0
             (setq org-latex-pdf-process '("xelatex -interaction nonstopmode %f"
                                           "xelatex -interaction nonstopmode %f"))
             ;; export cn character
             (setf org-latex-default-packages-alist
                   (remove '("AUTO" "inputenc" t) org-latex-default-packages-alist))
	     (require 'ox-md nil t)
             (require 'ox-latex )
             )
           )
  )

这是基本配置了

我的意思是 Org 文档本身,因为首先需要知道怎么重现。

嗯嗯,下面是我的org文档

   因为我之前使用Emacs的时候,是使用Spacemacs的配置的,但是后来觉得还是自己的
   配置用的更舒服,所以又切换回自己的配置,但是我还是很想念Spacemacs的一些绑定
   例如shell在底下弹出,或者是关闭,然后找到了[[https://github.com/kyagi/shell-pop-el][Shell-pop]] 这package,就可以用回
   Spacemacs的shell使用习惯。然后我觉得,Ipython shell也可以这样配置,只不过
   我没有发现类似的package,又因为Emacs Lisp的强大,所以我自己写了一段小函数实现
   shell-pop 的功能
   #+BEGIN_SRC emacs-lisp

     (defun samray/python-pop ()
       "Run python and switch to the python buffer.
     similar to shell-pop"
       (interactive)
       (if (get-buffer "*Python*")
           (if (string= (buffer-name) "*Python*")
               (if (not (one-window-p))
                   (progn (bury-buffer)
                          (delete-window))
                 )
             (progn (switch-to-buffer-other-window "*Python*")
                    (end-of-buffer)
                    (evil-insert-state)))
         (progn
           (run-python)
           (switch-to-buffer-other-window "*Python*")
           (end-of-buffer)
           (evil-insert-state))))
   #+END_SRC