我正在写一些法语,我需要在一个单词中加几个字母粗体,突出一个特定的音节或两个非常相似的单词之间的区别,所以我遵循了这个线程"如何使一个单词在组织模式中粗体化“的指示。我在我的.emacs文件底部添加了以下行(我在Windows732位中)
(setcar org-emphasis-regexp-components " \t('\"{[:alpha:]")
(setcar (nthcdr 1 org-emphasis-regexp-components) "[:alpha:]- \t.,:!?;'\")}\\")
(org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)我保存并重新启动了系统,但现在,当我打开.org文件时,emacs不识别它为.org文件,也不应用任何样式或格式。它将其视为一个LaTeX文件,不允许我用C-c C-e导出内容。我是否必须将这些行按任何特定的顺序排列,才能与组织模式一起工作呢?我不是专家,我只是一个复制粘贴配置代码的需要-一个需要的情况。
请看下面的图片。打字都是白色的,我怎么能让它有反应呢?我是否应该将这些新代码行移到我的.emacs文件中?

当前.emacs文件
;;; Schlosser's .emacs
(server-start)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
;;; a key for tilde symbol
(define-key key-translation-map (kbd "M-2") (kbd "~"))
;;; a key for backtick symbol
(define-key key-translation-map (kbd "M-6") "")
(define-key key-translation-map (kbd "M-9") (kbd "`"))
;; visual line word wrapping
(global-visual-line-mode t)
;; ;;; Brent.Longborough's .emacs
(setq inhibit-splash-screen t); Disable splash screen
(setq visible-bell t); Flashes on error
(show-paren-mode 1); Matches parentheses and such in every mode
;;; AUCTeX
;; Customary Customization, p. 1 and 16 in the manual, and http://www.emacswiki.org/emacs/AUCTeX#toc2
(setq TeX-parse-self t); Enable parse on load.
(setq TeX-auto-save t); Enable parse on save.
(setq-default TeX-master nil)
(setq TeX-PDF-mode t); PDF mode (rather than DVI-mode)
;activate Aspell, for all modes(?), not just TeX;
(add-to-list 'exec-path "C:/Program Files/Aspell/bin/")
(setq-default ispell-program-name "C:/Program Files/Aspell/bin/aspell.exe"); M-x ispell-change-dictionary RET to change dictionary
(setq ispell-dictionary "italiano"); Default dictionary. To change do M-x ispell-change-dictionary RET.
(require 'ispell) ;turn on dictionary check
;; (add-hook 'TeX-mode-hook 'flyspell-mode); Enable Flyspell mode for TeX modes such as AUCTeX. Highlights all misspelled words.
;; (add-hook 'emacs-lisp-mode-hook 'flyspell-prog-mode); Enable Flyspell program mode for emacs lisp mode, which highlights all misspelled words in comments and strings.
(add-hook 'TeX-mode-hook
(lambda () (TeX-fold-mode 1))); Automatically activate TeX-fold-mode.
;; (setq LaTeX-babel-hyphen nil); Disable language-specific hyphen insertion.
;; " expands into csquotes macros (for this to work babel must be loaded after csquotes).
;; (setq LaTeX-csquotes-close-quote "}"
;; LaTeX-csquotes-open-quote "\\enquote{")
;from StackExchange question "AUCTeX preview font size too small"
(set-default 'preview-scale-function 1.2)
;; LaTeX-math-mode http://www.gnu.org/s/auctex/manual/auctex/Mathematics.html
(add-hook 'TeX-mode-hook 'LaTeX-math-mode)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-faces-vector
[default default default italic underline success warning error])
'(custom-enabled-themes (quote (tango-dark)))
'(org-format-latex-options
(quote
(:foreground default :background default :scale 1.2 :html-foreground "Black" :html-background "Transparent" :html-scale 1.0 :matchers
("begin" "$1" "$" "$$" "\\(" "\\["))))
'(org-startup-with-latex-preview nil)
'(preview-default-document-pt 10)
'(show-paren-mode t)
'(transient-mark-mode (quote (only . t))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; yasnippet
(add-to-list 'load-path "~/.emacs.d/elpa/yasnippet-0.8.0")
(require 'yasnippet)
(setq yas-snippet-dirs '("~/.emacs.d/elpa/yasnippet-0.8.0/snippets"))
;(setq-default mode-require-final-newline nil)
(yas-global-mode 1)
(defun disable-final-newline () (interactive) (set (make-local-variable 'require-final-newline) nil))
;; solving yasnippet and org-mode conflict as per manual
(defun yas/org-very-safe-expand ()
(let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
(add-hook 'org-mode-hook
(lambda ()
(make-variable-buffer-local 'yas/trigger-key)
(setq yas/trigger-key [tab])
(add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
(define-key yas/keymap [tab] 'yas/next-field)))
;;emacs and SumatraPDF sync as per StackOverflow question "sync emacs auctex with SumatraPDF"
(setq TeX-PDF-mode t)
(setq TeX-source-correlate-mode t)
(setq TeX-source-correlate-method 'synctex)
(setq TeX-view-program-list
'(("Sumatra PDF" ("\"C:/Program Files/SumatraPDF/SumatraPDF.exe\" -reuse-instance" (mode-io-correlate " -forward-search %b %n ") " %o"))))
(eval-after-load 'tex
'(progn
(assq-delete-all 'output-pdf TeX-view-program-selection)
(add-to-list 'TeX-view-program-selection '(output-pdf "Sumatra PDF"))))
;code taken from SX "Cleveref: AUCTeX and RefTeX set-up"
(eval-after-load
"latex"
'(TeX-add-style-hook
"cleveref"
(lambda ()
(if (boundp 'reftex-ref-style-alist)
(add-to-list
'reftex-ref-style-alist
'("Cleveref" "cleveref"
(("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
(reftex-ref-style-activate "Cleveref")
(TeX-add-symbols
'("cref" TeX-arg-ref)
'("Cref" TeX-arg-ref)
'("cpageref" TeX-arg-ref)
'("Cpageref" TeX-arg-ref)))))
;; Org mode and Beamer export
(require 'ox-beamer)
(setq org-latex-to-pdf-process
'("pdflatex --shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex --shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex --shell-escape -interaction nonstopmode -output-directory %o %f"))
(defun my-beamer-bold (contents backend info)
(when (eq backend 'beamer)
(replace-regexp-in-string "\\`\\\\[A-Za-z0-9]+" "\\\\textbf" contents)))
(add-to-list 'org-export-filter-bold-functions 'my-beamer-bold)
(setq org-src-fontify-natively t)
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)
(latex . t)))
(setq org-confirm-babel-evaluate nil)
(setq org-babel-python-command "ipython --pylab --pdb --nosep --classic --no-banner --no-confirm-exit")
(setq org-latex-listings 'minted)
(setq org-latex-minted-options
'(("fontsize" "\\footnotesize")("bgcolor" "black")("obeytabs" "true")))
(require 'ox-latex)
(setq org-src-fontify-natively t)
(setq org-latex-pdf-process
'("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
(setq org-src-preserve-indentation t)
;Python
(setq python-shell-interpreter "C:\Python27")
; allow bold or italics for parts of a word, from StakOverflow discussion "How to make part of a word bold in org-mode?"
(setcar org-emphasis-regexp-components " \t('\"{[:alpha:]")
(setcar (nthcdr 1 org-emphasis-regexp-components) "[:alpha:]- \t.,:!?;'\")}\\")
(org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)

新截图
我所做的就是用操作模式写和编辑一些法语笔记。当我完成了一套课程之后,用vocab.org文件导出C-c C-e,选择只导出Body (C-b),并将其转换为vocab.tex和l l。一旦生成了vocab-main.tex,我就在vocab-main.tex中键入\input{vocab},这是我以前准备的,其中包含了所有的页面和字体格式(在LaTeX中)。最后,我用pdfLaTeX编译了vocab main.tex并得到了pdf!
我不知道这是否是产生一个好看的pdf最好的方式,我是开放的建议。无论如何,如您所见,在vocab.org的底部,有允许vocab.tex作为主文件使用vocab.tex的LaTeX“标记”。

发布于 2015-12-29 19:25:05
编辑:看起来我对org-reload的建议错了。真对不起。
“局部变量列表未正确终止”错误表明,它与最后一个LaTeX块中的局部变量块有关。因此,没有您的自定义,我创建了一个带有.org后缀和以下文本的文件:
#+BEGIN_LATEX
%%% Local Variables:
%%% mode: latex
%%% End:
#+END_LATEX我看到了您报告的完全相同的行为,使用的是latex-mode而不是org-mode。因此,Emacs看到的是局部变量块,即使您只希望它应用于导出的文件,并且重写基于文件后缀的主模式的通常确定。有关详细信息,请参阅手册(这里和这里)。
作为解决办法,我可以在这个块后面添加一个表单提要(^L),使Emacs忽略这个块(因为它只会搜索文件的最后一页),但我不知道这将如何影响导出。或者,由于导出应该生成一个.tex文件,所以这里可能不需要mode行。TeX-master行在任何情况下都不是问题。
当然,所有这些都不能解释您的实际错误,因为我没有得到这个错误,在我看来,所有这些看起来都是一个非常好的局部变量块。也许还有别的事情发生。
结束编辑
我不认为这会导致您所看到的行为,但我确实注意到,org-emphasis-regexp-components在其文档中说:
您需要重新加载Org或重新启动Emacs后,自定义这一点。
我在我自己的init文件中有一些代码修改org-emphasis-alist,它具有相同的警告,并且我发现我确实需要在进行更改之后调用org-reload,以使一切正常工作。(有一天,我打算查看源代码,看看每次重启Emacs时是否可以避免两次加载Org模式,但我还没有开始这么做。)我认为用定制工具可以避免这类事情,但是当您想要对一个变量进行相对于其默认值的更改时,它就不能很好地工作了,如下所示。
我将尝试在您的更改之后插入(org-reload),并查看是否修复了它。如果不是,Tim的建议是好的,我还建议您仔细查看消息缓冲区,看看是否有任何错误报告可能会给您提供一个起点。
发布于 2015-12-29 04:23:08
您添加的代码不应该因为将*.org文件解释为组织模式文件而更改emacs。我怀疑您的.emacs init中有其他东西坏了。
https://stackoverflow.com/questions/34499238
复制相似问题