File io 如何阻止自动完成覆盖名称类似的文件

File io 如何阻止自动完成覆盖名称类似的文件,file-io,emacs,autocomplete,save,File Io,Emacs,Autocomplete,Save,我是Emacs的新用户,从我所在领域的某个人那里获得了一个.Emacs文件,该文件向我介绍了这个编程平台。但是,我在尝试保存或创建与现有文件命名相似的新文件时遇到了一些问题。如果我试图创建一个新文件,该文件的名称与现有文件的名称相对类似,即使它位于不同的目录中,也会打开现有文件。当试图用较短或类似的名称保存一个已存在的文件时,Emacs会尝试覆盖该文件,而不是创建一个新文件 例如,我试图保存文件growth\u loglike.tpl,但目录中已经有文件growth\u loglike\u AD

我是Emacs的新用户,从我所在领域的某个人那里获得了一个
.Emacs
文件,该文件向我介绍了这个编程平台。但是,我在尝试保存或创建与现有文件命名相似的新文件时遇到了一些问题。如果我试图创建一个新文件,该文件的名称与现有文件的名称相对类似,即使它位于不同的目录中,也会打开现有文件。当试图用较短或类似的名称保存一个已存在的文件时,Emacs会尝试覆盖该文件,而不是创建一个新文件

例如,我试图保存文件
growth\u loglike.tpl
,但目录中已经有文件
growth\u loglike\u ADMB2\u End.tpl
。当我去保存并写入
growth\u loglike.tpl
时,它会在右侧以绿色显示
[growth\u loglike\u ADMB2\u End.tpl]
。当我点击回车键时,它会询问我是否要覆盖
growth\u loglike\u ADMB2\u End.tpl
。我认为这是
自动完成
插件的问题。有没有办法暂时关闭
自动完成
?查看
auto complete.el
文件,我猜我需要更改此变量,但我不确定更改的内容(或者这是否正确)。这方面的任何帮助都将非常有用

(defcustom ac-use-overriding-local-map nil
"Non-nil means `overriding-local-map' will be used to hack for overriding key events on auto-copletion."
  :type 'boolean
  :group 'auto-complete)
下面是我正在使用的
.emacs
文件

    ;; This emacs configuration file will activate common packages 

and 
;; functionality used in the QFC Reproducable Reseach Workshop.
;; change this path to point to emacs directory in workshop on your computer:
;; (don't forget to include a trailing slash!)
(defvar workshop-root "C:/Users/vince151/Documents/workshop/")

(defvar emacs-root (concat (file-name-as-directory workshop-root) "emacs/"))

;;=============================================================================
;;=============================================================================
;; 1. Misc Plug-ins
;; here are some paths to look for additional scripts and functions:
(add-to-list 'load-path (concat emacs-root "plugins/"))


;;=============================================================================
;; 2. YASnippet
(add-to-list 'load-path  (concat emacs-root "plugins/yasnippet"))
(require 'yasnippet) ;; not yasnippet-bundle
(setq yas-snippet-dirs (concat emacs-root "plugins/yasnippet/snippets"))
(yas-global-mode 1)

;; timestamp used in some yasnippets
(defun now ()
  "Insert string for the current time formatted like '2:34 PM'."
  (interactive)                 ; permit invocation in minibuffer
  (insert (format-time-string "%D %-I:%M %p")))

;;=============================================================================
;; 3. Swap Slashes
;; swap slashes and backslashes in current line -- useful for converting paths to be Windows-readable
;;http://www.xsteve.at/prg/emacs/.emacs.txt
(defun xsteve-exchange-slash-and-backslash ()
  "Exchanges / with \ and in the current line or in the region when a region-mark is active."
  (interactive)
  (save-match-data
    (save-excursion
      (let ((replace-count 0)
            (eol-pos (if mark-active (region-end) (progn (end-of-line) (point))))
            (bol-pos (if mark-active (region-beginning) (progn (beginning-of-line) (point)))))
        (goto-char bol-pos)
        (while (re-search-forward "/\\|\\\\" eol-pos t)
          (setq replace-count (+ replace-count 1))
          (cond ((string-equal (match-string 0) "/") (replace-match "\\\\" nil nil))
                ((string-equal (match-string 0) "\\") (replace-match "/" nil nil)))
          (message (format "%d changes made." replace-count)))))))

(global-set-key (kbd "M-\\") 'xsteve-exchange-slash-and-backslash)


;;==============================================================================
;; 4. Parenthesis highlighting

(require 'highlight-parentheses)
(setq hl-paren-colors '("DodgerBlue1" "IndianRed" "cyan" "ForestGreen" "magenta" "SlateGrey"))
(defun hpm-on ()
 (highlight-parentheses-mode t))
(add-hook 'admb-mode-hook 'hpm-on)
(add-hook 'ess-mode-hook 'hpm-on)
(add-hook 'inferior-ess-mode-hook 'hpm-on)
(add-hook 'latex-mode-hook 'hpm-on)
(add-hook 'LaTeX-mode-hook 'hpm-on)

;;=============================================================================
;; 5. ESS
;; path to current version of R:  (This shouldn't be needed if PATH is correct)
;;(setq-default 
;;   inferior-R-program-name 
;;   "C:/R/R-2.15.0/bin/i386/Rterm.exe")

(load (concat emacs-root "ESS/ess-13.09/lisp/ess-site"))
(setq ess-fancy-comments nil) 
;; make pdflatex the default sweave compiler (removes texi2pdf)
(setq ess-swv-pdflatex-commands '("pdflatex" "xelatex" "make"))


;;=============================================================================
;; 6. ADMB-ide
;; don't forget to edit setADMBpaths.bat to point to your admb installation
(setq admb-init (concat emacs-root "setADMBpaths & "))
;; these commands were cut from admb.el
(load (concat emacs-root "plugins/admb"))
;;  Edit .emacs so that `admb-mode' is autoloaded and assigned to *.tpl files:
(autoload 'admb-mode "admb" "Edit ADMB code." t)
(add-to-list 'auto-mode-alist '("\\.tpl$" . admb-mode))
;;  If you're running Emacs in MS Windows, add a line so *.tpl files are not treated as binary:
(setq file-name-buffer-file-type-alist nil)
;;  You may want to assign a mode that recognizes #comments in *.dat files (perl-mode, conf-space-mode, or R-mode):
(add-to-list 'auto-mode-alist '("\\.dat$" . perl-mode))
;;(add-to-list 'auto-mode-alist '("\\.dat$" . admb-mode))
;;(add-to-list 'auto-mode-alist '("\\.dat$" . easy-admb-hook))

;;added Monday, March 29, 2010 so that we can run models from within dat files
(add-hook 'perl-mode-hook
    (lambda()
    (define-key perl-mode-map [f9] 'admb-run)))

;;these commands were taken from Arni Magnusen's emacs file distributed with ADMB-IDE
(defun easy-admb-hook ()
  (local-set-key [f1]    'admb-help                 ) ; prefix
  (local-set-key [f2]    'admb-mode                 ) ; prefix
  ;;(global-set-key [f3] 'conf-space-mode           ) ; kmacro-start-macro-or-insert-counter
  (local-set-key [f4]    'admb-toggle-window        ) ; kmacro-end-or-call-macro
  (local-set-key [f7]    'admb-tpl2cpp        )
  (local-set-key [f8]    'admb-build          )
  (local-set-key [f9]    'admb-run            )
  (local-set-key [S-f9]  'admb-run-args       )
  (local-set-key [f10]   'admb-rep            ) ; menu-bar-open
  (local-set-key [S-f10] 'admb-cor            )
  (local-set-key [?\C-.] 'admb-toggle-section))
(add-hook 'admb-mode-hook 'easy-admb-hook)
;;----------
;;   C++
;;----------
(defun easy-gdb-hook ()
  (message nil)
  (setq indent-line-function 'gud-gdb-complete-command)
  ;;(setq gdb-show-main t)
  (local-set-key [f5]          'gdb-restore-windows)
  (local-set-key [M-up]        'gdb-io-buffer-off  )
  (local-set-key [M-down]      'gdb-io-buffer-on   )
  (local-set-key [?\C-c ?\C-q] 'comint-quit-subjob )
  (defun gdb-io-buffer-off () "Enable separate IO buffer." (interactive)(gdb-use-separate-io-buffer nil))
  (defun gdb-io-buffer-on () "Disable separate IO buffer." (interactive)(gdb-use-separate-io-buffer t)))
(add-hook 'gdb-mode-hook 'easy-gdb-hook)

;;=================
;; enable YASnippet 
(add-hook 'admb-mode-hook 'yas/minor-mode-on)
(add-hook 'admb-mode-hook
          (let ((original-command (lookup-key admb-mode-map [tab])))
            `(lambda ()
               (setq yas/fallback-behavior '(apply ,original-command))
               (local-set-key [tab] 'yas/expand))))

;;==============================================================================
;; 7. Git
;; path to git executable:  (This shouldn't be needed if PATH is correct)
;; (setq-default 
;;    magit-git-executable
;;    "C:/gnu/git/bin/git.exe")

;;(require 'git)
(add-to-list 'load-path (concat emacs-root "plugins/git/magit"))
(load (concat emacs-root "plugins/git/magit/magit.el"))
(require 'magit)
;; use Ctrl-C G to start Git:
(global-set-key "\C-c\C-g" 'magit-status)

;; from: http://readystate4.com/2011/02/22/emacs-changing-magits-default-diff-colors/
;; change magit diff colors
(eval-after-load 'magit
  '(progn
     (set-face-foreground 'magit-diff-add "green3")
     (set-face-foreground 'magit-diff-del "red3")
     (when (not window-system)
       (set-face-background 'magit-item-highlight "black"))))

;;==============================================================================
;; 8. autocomplete
(require 'auto-complete)
(add-to-list 'ac-dictionary-directories (concat emacs-root "plugins/ac-dict"))
(require 'auto-complete-config)
(ac-config-default)

;;========================================
;; 9. Bibtex database:
(setq reftex-default-bibliography
      '("C:/Users/vince151/Documents/workshop/utils/references.bib"))

(setq reftex-default-bibliography
      (concat workshop-root "utils/references.bib"))

 (defvar reftex-file 
   (concat 
    (file-name-as-directory workshop-root) "utils/references.bib"))
 (setq reftex-default-bibliography reftex-file)


;; Make TeX and RefTex aware of Snw and Rnw files
(setq reftex-file-extensions
      '(("snw" "rnw" "Snw" "Rnw" "nw" "tex" ".tex" ".ltx") ("bib" ".bib")))
(setq TeX-file-extensions
      '("snw" "rnw" "Snw" "Rnw" "nw" "tex" "sty" "cls" "ltx" "texi" "texinfo"))

(add-hook 'latex-mode-hook 'turn-on-reftex)

;;========================================
;; 10. Some functions to run bibtex and latex

(defun ac-run-bibtex ()
   "Run BibTex on the current file."
   (interactive)
   (save-excursion
     (let* ((latex-filename (file-name-sans-extension (buffer-file-name)))
            (tex-buf (get-buffer-create " *ESS-bibtex-output*")))
       (message "Running BibTex on '%s' ..." latex-filename)
       (switch-to-buffer tex-buf)
       (call-process "bibtex" nil tex-buf 1 latex-filename)
       (switch-to-buffer (buffer-name))
       (display-buffer tex-buf)
       (message "Finished running BibTeX" ))))

(defun ac-run-pdflatex ()
   "Run pdflatex on the current file."
   (interactive)
   (save-excursion
       (let* ((namestem (file-name-sans-extension (buffer-file-name)))
            (latex-filename (concat namestem ".tex"))
            (tex-buf (get-buffer-create " *pdflatex-output*")))
       (message "Running pdflatex on '%s' ..." latex-filename)
       (switch-to-buffer tex-buf)
       (call-process "pdflatex" nil tex-buf 1 latex-filename)
       (switch-to-buffer (buffer-name))
       (display-buffer tex-buf)
       (message "Finished running pdflatex" ))))

;; terms associated with base name were added to create index files using makeindex
;; this function impliments the following sequence of calls:
;;  pdflatex -> bibtex -> pdflatex -> makeindex -> pdflatex
(defun ac-run-lbll ()
   "Run LaTeX-BibTex-Latex-Latex on the current file."
   (interactive)
   (save-excursion
       (let* ((namestem (file-name-sans-extension (buffer-file-name)))
            (latex-filename (concat namestem ".tex"))
            (basename (file-name-nondirectory namestem))
            (tex-buf (get-buffer-create " *lbll-output*")))
       (message "Running LaTeX-BibTex-Latex-Latex on '%s' ..." latex-filename)
       (switch-to-buffer tex-buf)
       (call-process "pdflatex" nil tex-buf 1 latex-filename)
       (call-process "bibtex" nil tex-buf 1 namestem)
       (call-process "pdflatex" nil tex-buf 1 latex-filename)
       (call-process "makeindex" nil tex-buf 1 basename)
       (call-process "pdflatex" nil tex-buf 1 latex-filename)
       (switch-to-buffer (buffer-name))
       (display-buffer tex-buf)
       (message "Finished running LaTeX-BibTex-Latex-Latex" ))))


(add-hook 'latex-mode-hook
 (lambda ()
   (define-key latex-mode-map [f9] 'ac-run-pdflatex)
 )
)


;;========================================
;; 10. Other useful functions below this point

;;ispell - super cool spell checker for emacs
(setq-default ispell-program-name (concat emacs-root "aspell/bin/aspell.exe"))
;; get itspell to skip sweave chunks:
(add-to-list 'ispell-skip-region-alist '("^<<.*>>=" . "^@"))

;;=============================================================================
;; use string rectangle for indentng blocks/regions of code
(global-set-key (kbd "C->") 'string-insert-rectangle)

;;=============================================================================
;;ido  (from: http://www.emacswiki.org/emacs/InteractivelyDoThings)
(require 'ido)
(ido-mode t)
(setq ido-enable-flex-matching t) ;; enable fuzzy matching

;;=============================================================================
;; use ibuffer anytime we would have use buffer-list
(defalias 'list-buffers 'ibuffer)

; get rid of prompt that forces you to type full "yes" or "no".
; y or n is enough
(defalias 'yes-or-no-p 'y-or-n-p)

;;==============================================================================
;; from http://www.joegrossberg.com/archives/000182.html
;; enable recent file list - bound to C-x C-r
(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)

;;==============================================================================
;; from http://www.stokebloke.com/wordpress/2008/04/17/emacs-refresh-f5-key/
;; use f3 to refresh file in current buffer
;;(defun refresh-file ()
;;  (interactive)
;;  (revert-buffer t t t)
;;  )
;;(global-set-key [f3] 'refresh-file)
;;
;;==============================================================================
;; copy path of current buffer to kill ring
;; from:http://stackoverflow.com/questions/3669511/
(defun copy-full-path-to-kill-ring ()
  "copy buffer's full path to kill ring"
  (interactive)
  (when buffer-file-name
    (kill-new (file-truename buffer-file-name))))
(global-set-key  "\C-cz" 'copy-full-path-to-kill-ring)

;;==============================================================================
;; keep emacs from cluttering working directories with tilde files by
;; placing them here:(concat emacs-root "tildes") instead of
;; wherever we're working.
(defvar user-temporary-file-directory
  (concat emacs-root   "tildes/"))
(make-directory user-temporary-file-directory t)
(setq backup-by-copying t)
(setq backup-directory-alist
      `(("." . ,user-temporary-file-directory)
        (,tramp-file-name-regexp nil)))
(setq auto-save-list-file-prefix
      (concat user-temporary-file-directory ".auto-saves-"))
(setq auto-save-file-name-transforms
      `((".*" ,user-temporary-file-directory t)))

;;;============================================================================


; try to improve slow performance on windows.
;;Got this from a website that said this would help.
(setq w32-get-true-file-attributes nil)
;;此emacs配置文件将激活通用软件包
及
;; QFC可复制研究车间中使用的功能。
;; 将此路径更改为指向计算机上workshop中的emacs目录:
;; (别忘了在后面加上斜杠!)
(defvar车间根目录“C:/Users/vince151/Documents/workshop/”)
(defvar emacs root(concat(文件名为目录车间根)“emacs/”)
;;=============================================================================
;;=============================================================================
;; 1.其他插件
;; 以下是查找其他脚本和函数的一些路径:
(添加到列表“加载路径(concat emacs root“plugins/”))
;;=============================================================================
;; 2.雅斯尼佩特
(添加到列表“加载路径”(concat emacs root“plugins/yasnippet”))
(要求“yasnippet”);;不是日本包
(setq yas snippet dirs(concat emacs root“plugins/yasnippet/snippets”))
(yas全球模式1)
;; 时间戳在某些应用程序中使用
(现在退出)
“插入当前时间的字符串,格式为'2:34 PM'。”
(交互式);允许在微缓冲区中调用
(插入(格式化时间字符串“%D%-I:%M%p”))
;;=============================================================================
;; 3.互换斜杠
;; 交换当前行中的斜杠和反斜杠--用于将路径转换为Windows可读的路径
;;http://www.xsteve.at/prg/emacs/.emacs.txt
(定义xsteve交换斜杠和反斜杠()
“当区域标记处于活动状态时,在当前行或区域中与\交换/和。”
(互动)
(保存匹配数据
(省去远足
(let((替换计数0)
(下线位置(如果标记激活(区域结束)(程序(行结束)(点)))
(bol位置(如果标记处于活动状态(区域开始)(progn(行开始)(点‘‘‘)’))
(转到char bol位置)
(while(向前搜索“\\\\\\\”下线位置t)
(setq替换计数(+替换计数1))
(cond((字符串相等(匹配字符串0)“/”)(替换匹配“\\\\\\\\\\”nil))
((字符串相等(匹配字符串0)“\\”(替换匹配”/“nil-nil)))
(消息(格式“%d”已更改。“替换计数()()())))
(全局设置键(kbd“M-\\”)的xsteve交换斜杠和反斜杠)
;;==============================================================================
;; 4.括号高亮显示
(需要突出显示括号)
(setq hl paren colors'(“道奇蓝1”“印度红”“青色”“森林绿”“洋红”“石板灰”))
(在()上卸载hpm)
(突出显示括号模式t))
(添加挂钩“admb模式挂钩”hpm on)
(在hpm上添加挂钩“ess模式挂钩”)
(在hpm上添加挂钩“下ess模式挂钩”)
(在hpm上添加挂钩“乳胶模式挂钩”)
(在hpm上添加挂钩“乳胶模式挂钩”)
;;=============================================================================
;; 5.嵌入式安全子系统
;; 当前版本R的路径:(如果路径正确,则不需要此路径)
;;(setq默认值
;次-R-程序名
;;“C:/R/R-2.15.0/bin/i386/Rterm.exe”)
(加载(concat emacs根目录“ESS/ESS-13.09/lisp/ESS站点”))
(setq无)
;; 使pdflatex成为默认的swave编译器(删除texi2pdf)
(setq ess swv pdflatex命令“(“pdflatex”“xelatex”“make”))
;;=============================================================================
;; 6.ADMB ide
;; 不要忘记编辑setADMBpaths.bat以指向您的admb安装
(setq admb init(concat emacs root“setadmbpath&”)
;; 这些命令是从admb.el中删除的
(加载(concat emacs root“plugins/admb”))
;;  编辑.emacs,使“admb模式”自动加载并分配给*.tpl文件:
(自动加载“admb模式”admb“编辑admb代码。”t)
(添加到列表“自动模式列表”(“\\.tpl$”.admb模式))
;;  如果您在MS Windows中运行Emacs,请添加一行,以便*.tpl文件不会被视为二进制文件:
(setq文件名缓冲区文件类型列表nil)
;;  您可能希望分配一种模式,用于识别*.dat文件中的#注释(perl模式、conf空间模式或R模式):
(添加到列表“自动模式列表”(“\\.dat$”.perl模式))
;;(添加到列表“自动模式列表”(“\\.dat$”.admb mode))
;;(添加到列表“自动模式列表”(“\\.dat$”.easy admb hook))
;;添加了2010年3月29日星期一,以便我们可以从dat文件中运行模型
(添加hook的perl模式hook
(lambda()
(定义键perl模式映射[f9]“admb运行”))
;;这些命令取自与ADMB-IDE一起分发的Arni Magnusen的emacs文件
(卸下简易admb挂钩()
(本地设置键[f1]“a