简体   繁体   English

Emacs:Ansi-term不是制表符

[英]Emacs: Ansi-term not tab-completing

I have recently installed a few packages so that I can program iOS apps from emacs, but I am having some trouble. 我最近安装了一些软件包,以便我可以从emacs编程iOS应用程序,但我遇到了一些麻烦。 One of the packages (I'm pretty sure it's autocomplete) is preventing tab-completion from working in ansi-term. 其中一个软件包(我很确定它是自动完成的)会阻止标签完成在ansi-term中工作。 Any time I try to tab-complete, I get the error "Wrong type argument: characterp, tab". 每当我尝试Tab-complete时,我都会收到错误“错误的类型参数:characterp,tab”。

Here is my .emacs file: 这是我的.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

Alright, I fixed it. 好吧,我修好了。 The problem was with yasnippets, but the suggestion on the link didn't work. 问题出在yasnippets上,但链接上的建议不起作用。 For some reason setting yas-minor-mode to -1 didn't work. 出于某种原因,将yas-minor-mode设置为-1不起作用。 What I had to do was set yas-dont-activate to something. 我必须做的是设置yas-dont-activate to something。

Suggested fix that did NOT work for me: 建议的解决方案对我不起作用:

(add-hook 'term-mode-hook (lambda()
                (yas-minor-mode -1)))

What DID work for me: DID对我有用:

(add-hook 'term-mode-hook (lambda()
        (setq yas-dont-activate t)))

I'm running emacs 23.4.1 我正在运行emacs 23.4.1

The method provided by user1539179 works by inactiving yasnippets mode while using the shell mode. user1539179提供的方法通过在使用shell模式时不使用yasnippets模式来工作。 There is a small problem that I can no longer use the yasnippet mode after I open ansi-term. 有一个小问题,我打开ansi-term后就不能再使用yasnippet模式了。 For example, if a markdown file is opened after the ansi-term, the yasnippet will not work. 例如,如果在ansi-term之后打开markdown文件,则yasnippet将不起作用。 My solution is not using yasnippet globally, but hook to the mode we want to. 我的解决方案不是全局使用yasnippet,而是挂钩到我们想要的模式。 Here is my emacs configure for yasnippet that I only bind it to prog-mode , ess-mode , and markdown-mode , and the tab-completing works in ansi-term. 这是我为yasnippet配置的emacs,我只将它绑定到prog-modeess-modemarkdown-mode ,而tab-completion在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)  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM