我最近安装了一些软件包,以便我可以从emacs编程iOS应用程序,但我遇到了一些问题。其中一个软件包(我很确定它是自动完成的)会阻止标签完成在ansi-term中工作。每当我尝试tab-complete时,我都会收到错误“错误的类型参数:characterp,tab”。
这是我的.emacs文件:
; Add packages
(add-to-list 'load-path "~/.emacs.d/elpa")
(add-to-list 'load-path "~/.emacs.d/packages")
(require 'package)
; Package sources
(add-to-list 'package-archives
'("marmalade" .
"http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives
'("melpa" .
"http://melpa.milkbox.net/packages/") t)
(package-initialize)
; Check packages were loaded
(require 'linum-relative)
(require 'git-gutter-fringe)
(require 'yasnippet)
(require 'auto-complete-config)
; Enable packages
(elscreen-start)
; Config
; Color scheme
(load-file "~/.emacs.d/themes/color-theme-wombat.el")
; Enable snippets
(yas-global-mode 1)
; Copy/paste with the system clipboard
(setq x-select-enable-clipboard t)
; Enable relative line numbers
(global-linum-mode t)
; Enable git gutter
(global-git-gutter-mode t)
(setq git-gutter-fr:side 'left-fringe)
; Darker git gutter colors
(set-face-foreground 'git-gutter-fr:modified "#ccaa8f")
(set-face-foreground 'git-gutter-fr:added "#333366")
(set-face-foreground 'git-gutter-fr:deleted "#e5786d")
; C-x -> arrow changes windows
(global-set-key (kbd "C-x <up>") 'windmove-up)
(global-set-key (kbd "C-x <down>") 'windmove-down)
(global-set-key (kbd "C-x <right>") 'windmove-right)
(global-set-key (kbd "C-x <left>") 'windmove-left)
; Hide everything that isn't text
(tool-bar-mode -1)
(scroll-bar-mode -1)
(menu-bar-mode -1)
; Move backups
(setq backup-directory-alist
`((".*" . ,"~/.emacsbackups")))
(setq auto-save-file-name-transforms
`((".*" ,"~/.emacstemps" t)))
(setq backup-by-copying t)
; Autocomplete settings
;when to use autocomplete (note yasnippits)
(setq-default ac-sources '(ac-source-yasnippet ac-source-abbrev ac-source-dictionary ac-source-words-in-same-mode-buffers))
(global-auto-complete-mode t)
(add-to-list 'ac-modes 'objc-mode) ; For iOS dev
答案 0 :(得分:33)
好吧,我修好了。问题出在yasnippets上,但链接上的建议不起作用。出于某种原因,将yas-minor-mode设置为-1不起作用。我必须做的是将yas-dont-activate设置为某种东西。
对我不起作用的建议修复:
(add-hook 'term-mode-hook (lambda()
(yas-minor-mode -1)))
DID对我有用:
(add-hook 'term-mode-hook (lambda()
(setq yas-dont-activate t)))
我正在运行emacs 23.4.1
答案 1 :(得分:3)
user1539179提供的方法通过在使用shell模式时禁用yasnippets模式来工作。有一个小问题,我打开ansi-term后就不能再使用yasnippet模式了。例如,如果在ansi-term之后打开markdown文件,则yasnippet将不起作用。我的解决方案不是全局使用yasnippet,而是挂钩到我们想要的模式。以下是我为yasnippet配置的emacs,我只将其绑定到prog-mode
,ess-mode
和markdown-mode
,并且完成标签的工作在ansi-term中。
(require 'yasnippet)
(yas-reload-all)
(add-hook 'prog-mode-hook 'yas-minor-mode)
(add-hook 'ess-mode-hook 'yas-minor-mode)
(add-hook 'markdown-mode-hook 'yas-minor-mode)