我剛開始在 Windows 7 中使用 emacs,它非常跳躍。似乎無法立即讀取或寫入檔案。當我嘗試使用 Cx Cf 執行此操作並在啟動後幾秒鐘寫入路徑時,迷你緩衝區給了我類似的東西
wrong type argument: stringp, (\, temporary-file-directory)
但如果我等待幾分鐘或繼續嘗試,最終我會加載文件。
到底是怎麼回事?
編輯:
這是我的 init.el 文件,emacs 似乎沒有它也能正常運行
;; ***My load path***
(cd "x:/PyStuff/")
(setenv "PYTHONPATH" "c:/Python27")
(add-to-list 'load-path "c:/Users/dmvianna/.emacs.d")
;; ***server stuff***
(require 'server)
(when (and (= emacs-major-version 23)
(= emacs-minor-version 1)
(equal window-system 'w32))
;; Suppress error "directory ~/.emacs.d/server is unsafe" on Windows.
(defun server-ensure-safe-dir (dir) "Noop" t))
(condition-case nil
(server-start)
(error
(let* ((server-dir (if server-use-tcp server-auth-dir server-socket-dir)))
(when (and server-use-tcp
(not (file-accessible-directory-p server-dir)))
(display-warning
'server (format "Creating %S" server-dir) :warning)
(make-directory server-dir t)
(server-start))))
)
;; ***Miscellaneous inits***
(setq backup-directory-alist
'((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
'((".*" ,temporary-file-directory t)))
(setq delete-by-moving-to-trash t)
(setq inhibit-startup-screen t)
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
;;****Python stuff****
(require 'python-mode)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
;; *Python mode fixes*
(defun python-reinstate-current-directory ()
"When running Python, add the current directory ('') to the head of sys.path.
For reasons unexplained, run-python passes arguments to the
interpreter that explicitly remove '' from sys.path. This means
that, for example, using 'python-send-buffer' in a buffer
visiting a module's code will fail to find other modules in the
same directory.
Adding this function to 'inferior-python-mode-hook' reinstates
the current directory in Python's search path."
(python-send-string "sys.path[0:0] = ['']"))
(add-hook 'inferior-python-mode-hook 'python-reinstate-current-directory)
;;*End Python mode fixes*
(require 'lambda-mode)
(add-hook 'python-mode-hook #'lambda-mode 1)
(require 'ipython)
(require 'anything) (require 'anything-ipython)
(when (require 'anything-show-completion nil t)
(use-anything-show-completion 'anything-ipython-complete
'(length initial-pattern)))
(add-hook 'python-mode-hook #'(lambda ()
(define-key py-mode-map (kbd "M-<tab>") 'anything-ipython-complete)))
(add-hook 'ipython-shell-hook #'(lambda ()
(define-key py-mode-map (kbd "M-<tab>") 'anything-ipython-complete)))
(require 'comint)
(define-key comint-mode-map (kbd "M-") 'comint-next-input)
(define-key comint-mode-map (kbd "M-") 'comint-previous-input)
(define-key comint-mode-map [down] 'comint-next-matching-input-from-input)
(define-key comint-mode-map [up] 'comint-previous-matching-input-from-input)
(require 'python-pep8)
(require 'python-pylint)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(provide 'emacs-init)
答案1
在這段程式碼中:
(setq backup-directory-alist
'((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
'((".*" ,temporary-file-directory t)))
您需要'
用反引號替換 s,如下所示:
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
'x
意味著(quote x)
- 返回x
而不評估它。使用反引號可以選擇性地評估清單元素。在這種情況下,這本質上意味著不將其temporary-file-directory
視為字面意思。
“但如果我等待幾分鐘或繼續嘗試,最終我會加載文件。”
最有可能發生的情況是您最終設法加載文件而不觸發自動保存(從而通過不對損壞的backup-directory-alist
和進行操作來避免錯誤auto-save-file-name-transforms
)。我不完全確定什麼情況會觸發自動儲存。