【问题标题】:emacs latex hooks not runningemacs 乳胶挂钩未运行
【发布时间】:2012-10-09 06:24:02
【问题描述】:

因此,出于某种原因,我在 emacs 中使用 auctex 的乳胶模式的一些钩子拒绝运行,但没有给出错误(至少我在消息缓冲区中看不到任何错误)。这是我的 .emacs 中关于乳胶的大部分内容(除了一些关键字定义等......)。我也在使用最新版本的 auctex 在 Arch Linux 上运行 Emacs24.2。一直在努力解决这个问题,据我所知,这曾经工作得很好,直到今天我注意到flyspell和自动填充没有被自动设置(可能已经以这种速度发生了一段时间,因为我没有'暂时不要使用 auctex)。


(add-to-list 'load-path "~/Dropbox/Emacs/")
(add-to-list 'load-path "~/Dropbox/Emacs/git/")
(add-to-list 'load-path "~/Dropbox/Emacs/magit/")
(add-to-list 'load-path "~/Dropbox/Emacs/GLSL/")

;; auto-complete (require 'auto-complete) (require 'auto-complete-config) (require 'auto-complete-clang) (ac-flyspell-workaround) (add-to-list 'ac-modes 'LaTeX-mode) (ac-config-default) (setq ac-quick-help-delay 0) (define-key ac-mode-map [(control tab)] 'auto-complete) (setq-default ac-sources '(ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers)) (global-auto-complete-mode t) (add-hook 'emacs-lisp-mode-hook (lambda () (add-to-list 'ac-sources 'ac-source-symbols 'ac-source-variables))) (defun add-sources-c-modes () (add-to-list 'ac-sources 'ac-source-semantic 'ac-source-clang)) (add-hook 'c-mode-hook 'add-sources-c-modes) (add-hook 'c++-mode-hook 'add-sources-c-modes) (define-key ac-completing-map "\C-n" 'ac-next) (define-key ac-completing-map "\C-p" 'ac-previous)

;; DocView (setq doc-view-continuous t) (setq doc-view-resolution 300)

;; diff mode colors (eval-after-load 'diff-mode '(progn (set-face-foreground 'diff-added "green") (set-face-foreground 'diff-header "purple") (set-face-foreground 'diff-removed "red")))

;; dired colors (eval-after-load 'dired-mode '(progn (set-face-foreground 'dired-directory "cyan") (set-face-foreground 'dired-flagged "red") (set-face-foreground 'dired-header "purple")))

;; server mode ;; (server-start)

;; GLSL (autoload 'glsl-mode "glsl-mode" nil t) (add-to-list 'auto-mode-alist '("\.vert\'" . glsl-mode)) (add-to-list 'auto-mode-alist '("\.frag\'" . glsl-mode))

;; Git / SVN (require 'git) (require 'git-blame)

;; Emacs Code Browser / CEDET ;; (require 'cedet) ;; (require 'ecb) ;; (setq ecb-options-version "2.40")

;; Close scratch buffer on startup (defun close-scratch-hook () (kill-buffer "scratch")) (add-hook 'emacs-startup-hook 'close-scratch-hook)

;; LaTeX/Auctex settings (require 'ac-math) (defun ac-latex-mode-setup () (add-to-list 'ac-sources 'ac-source-math-unicode 'ac-source-math-latex 'ac-source-latex-commands)) (add-hook 'LaTeX-mode-hook 'latex-math-mode) (add-hook 'LaTeX-mode-hook 'turn-on-reftex) (add-hook 'text-mode-hook 'auto-fill-mode) (add-hook 'LaTeX-mode-hook 'turn-on-flyspell) (add-hook 'LaTeX-mode-hook 'ac-latex-mode-setup) (add-hook 'LaTeX-mode-hook (lambda () (set-face-foreground 'font-latex-sedate-face "cyan"))) (setq reftex-plug-into-AUCTeX t) (setq font-latex-match-slide-title-keywords (quote (("frametitle" "{")))) (setq font-latex-match-warning-keywords (quote ("hline" "pause" "and" "hfill"))) (setq font-latex-match-function-keywords (quote (("titlepage" "") ("maketitle" "") ("frame" "") ("tableofcontents" "") ("noindent" "") ("usetheme" "{") ("usecolortheme" "{") ("institute" "[{") ("includegraphics" "[{") ("title" "[{") ("href" "{{") ("url" "{") ("hypersetup" "{") ("useoutertheme" "{") ("useinnertheme" "{") ("setbeamercolor" "{{") ("setbeamertemplate" "{{") ("setdescription" "{") ("lstset" "{") ("lstinputlisting" "[{") ("textcolor" "{") ("verbatiminput" "{") ("graphicspath" "{") ("fancyhead" "[{") ("fancyfoot" "[{") ("fontsize" "{{") ("doublespacing" ""))))

;; Line numbers (require 'linum) (global-linum-mode t)

;; Disable line numbers in certain buffers (defcustom linum-disabled-modes-list '(eshell-mode wl-summary-mode compilation-mode org-mode dired-mode) "* List of modes disabled when global linum mode is on" :type '(repeat (sexp :tag "Major mode")) :tag " Major modes where linum is disabled: " :group 'linum)

(defcustom linum-disable-starred-buffers 't "* Disable buffers that have stars in them like Gnu Emacs" :type 'boolean :group 'linum)

(defun linum-on () "* When linum is running globally, disable line number in modes defined in `linum-disabled-modes-list'. Changed by linum-off. Also turns off numbering in starred modes like scratch" (unless (or (minibufferp) (member major-mode linum-disabled-modes-list) (and linum-disable-starred-buffers (string-match "*" (buffer-name)))) (linum-mode 1)))

;; Basic emacs settings (setq initial-scratch-buffer nil) (setq inhibit-splash-screen t) (setq inhibit-startup-message t) (setq-default truncate-lines t) (setq backup-inhibited t) (setq auto-save-default nil) (setq compilation-scroll-output t) (if (boundp 'scroll-bar-mode) (scroll-bar-mode -1)) (column-number-mode 1) (setq-default fill-column 80) (setq auto-fill-mode 1) (if (boundp 'tool-bar-mode) (tool-bar-mode 0)) (set-face-attribute 'default nil :height 100) (add-hook 'before-save-hook 'delete-trailing-whitespace) (global-auto-revert-mode t) (setq frame-title-format "%b")

;; cscope (require 'xcscope) (setq cscope-do-not-update-database t)

;; Enable these to speed up compiler output ;; (setq compilation-error-regexp-alist nil) ;; (setq compilation-error-regexp-alist-alist nil)

;; Indentation rules (setq c-default-style "bsd" c-basic-offset 4) (c-set-offset 'case-label '+) (setq sgml-basic-offset 4) (setq python-indent 4) (setq indent-tabs-mode nil) (setq tab-always-indent t) (setq tab-width 4) (setq tab-stop-list (quote (4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120)))

;; highlight matching parentheses (show-paren-mode 1) (setq show-paren-delay 0)

;; highlight current line (global-hl-line-mode 1) (set-face-background 'hl-line "#300")

;; C-Sharp mode ;; (require 'cc-mode) ;; (autoload 'csharp-mode "csharp-mode" "Major mode for editing C# code." t) ;; (add-to-list 'auto-mode-alist '("\.cs$" . csharp-mode))

;; Change the color scheme (require 'color-theme) (color-theme-initialize) (color-theme-midnight)

;; Make ENTER automatically indent in C derived buffers (add-hook 'c-mode-common-hook (lambda () (local-set-key (kbd "RET") 'newline-and-indent)))

;; Enable terminal colors (autoload 'ansi-color-for-comint-mode-on "ansi-color" nil t) (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

;; Hotkeys (global-set-key [f9] 'compile)

;; Emacs IRC (setq erc-auto-query 'buffer)

;; assembly mode (add-hook 'asm-mode-hook (lambda () (local-set-key (kbd "RET") 'newline)))

;; change default Browser (setq browse-url-generic-program (executable-find "chromium") browse-url-browser-function 'browse-url-generic)

;; multi-term (require 'multi-term)

;; yasnippet work around ;; (add-hook 'change-major-mode-hook 'yas/exit-all-snippets)

;; develock (require 'develock)

【问题讨论】:

    标签: emacs latex elisp auctex


    【解决方案1】:

    我的猜测是您在将LaTeX-mode 添加到ac-modes 之前启动auto-complete-mode。

    要确定发生了什么,我们需要查看整个 .emacs 或具有相同问题的最小示例。

    顺便说一句,您的ac-latex-mode-setup 什么都不做,因为当它被调用时,它只定义了一个永远不会使用的lambda(匿名函数)。如果要执行代码,则需要将其更改为以下内容:

    (defun ac-latex-mode-setup ()         ; add ac-sources to default ac-sources
      (setq ac-sources
         (append '(ac-source-math-unicode ac-source-math-latex ac-source-latex-commands)
                   ac-sources))
    )
    

    您使用的progn 也没有任何作用。 progn 允许你链接多条指令并且你只使用一个。为了清楚起见,您可以progn如下:

    (eval-after-load 'LaTeX-mode
      '(set-face-foreground 'font-latex-sedate-face "cyan"))
    

    Stefan 对使用package-install 有意见。这是首选方式,而且效果非常好。另外,您应该永远使用load。 始终使用require 或eval-after-load。

    【讨论】:

    • 我添加了整个 .emacs 文件以供参考,我已经更改并移动了一些东西,我现在唯一的问题是自动完成模式没有自动启动所以 ac-source-latex-commands钩子运行时无效。
    • add-to-list 只能添加一个元素。我修改了我的示例以反映 ac-math 包的文档。
    • 谢谢,我已经从我见过的其他代码中获取了一些添加到列表的内容,但我不知道它只能添加 1 个元素。将其切换为在列表中使用 append 并且它起作用了:) 谢谢
    • 顺便说一句,我已经用progn 更改了示例,但整个表达式什么也没做。 eval-after-load 的第一个元素应该是一个包含文件名的字符串。没有文件名“LaTeX-mode.el”所以这什么都不做。顺便说一句,这不是设置面部颜色的地方,请在主题中进行。
    • 是的,我真的只修改了一张脸,所以我把所有的钩子都移到了一个用于乳胶的钩子函数中,并将其添加到最后。
    【解决方案2】:

    AFAIK,没有auctex.el。在tex-site, IIRC 中为 AUCTeX 加载的文件。您实际上可能更喜欢通过 M-x package-install RET 安装 AUCTeX,它会为您解决这个问题。

    【讨论】:

    • Auctex 工作得很好,我通过 yaourt/pacman 安装了它并且没有遇到任何问题。我现在一切正常,除了由于某种原因自动完成没有自动加载....
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-03
    • 1970-01-01
    • 2011-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-26
    相关资源
    最近更新 更多