设置.emacs中的默认目录



我真的不知道该说些什么。

我一直在努力自定义我的emacs,我注意到它实际上并没有在启动时加载我的.emacs。根据(http://www.gnu.org/software/emacs/manual/html_node/emacs/find-init.html#find-init),Emacs在Home Directory(~/)中查看初始化文件。。

当我启动Emacs时,我的.emacs文件似乎可以正确读取 - 例如,当我访问.notes文件时,评估了挂钩等。令我惊讶的是:未设置默认目录 - 同一加载文件中的命令。我可以手动评估它,也可以简单地执行(load "~/.emacs"),并且可以正常工作。

我猜这个问题可以总结:如果load命令在手动执行时按预期工作,为什么它不自动在启动上工作?

full(除注释功能外) .emacs文件:

; http://stackoverflow.com/a/13946304/1443496
(defvar auto-minor-mode-alist ()
  "Alist of filename patterns vs correpsonding minor mode functions,
   see `auto-mode-alist'. All elements of this alist are checked,
   meaning you can enable multiple minor modes for the same regexp.")
(defun enable-minor-mode-based-on-extension ()
  "check file name against auto-minor-mode-alist to enable minor modes
the checking happens for all pairs in auto-minor-mode-alist"
  (when buffer-file-name
    (let ((name buffer-file-name)
          (remote-id (file-remote-p buffer-file-name))
          (alist auto-minor-mode-alist))
      ;; Remove backup-suffixes from file name.
      (setq name (file-name-sans-versions name))
      ;; Remove remote file name identification.
      (when (and (stringp remote-id)
                 (string-match-p (regexp-quote remote-id) name))
        (setq name (substring name (match-end 0))))
      (while (and alist (caar alist) (cdar alist))
        (if (string-match (caar alist) name)
            (funcall (cdar alist) 1))
        (setq alist (cdr alist))))))
(add-hook 'find-file-hook 'enable-minor-mode-based-on-extension)

;; the wrapping up of the two loads make sure 
;; auctex is loaded only when editing tex files. 
(eval-after-load "tex-mode" 
  '(progn
     (load "auctex.el"  nil nil t)
     (load "preview-latex.el" nil nil t)
     )
  )
; Sets my default directory to my dropbox (platform-dependent)
(setq default-directory
      (concat
       (if (eq system-type 'windows-nt)
       "t:" "~")
       "/Dropbox/Public/School/TeX/"))

; Set up the .notes extension
(setq auto-mode-alist
      (cons '("\.notes\'" . text-mode)
        auto-mode-alist))
(setq auto-minor-mode-alist
      (cons '("\.notes\'" . auto-fill-mode)
            auto-minor-mode-alist))

;; AUCTeX replaces latex-mode-hook with LaTeX-mode-hook
(add-hook 'LaTeX-mode-hook
      (lambda ()
        (setq TeX-auto-save t)
        (setq TeX-parse-self t)
        ;; (setq-default TeX-master nil)
        (reftex-mode t)
        (TeX-fold-mode t)))

默认目录是buffer local。您的.emacs加载正好;为您打开的每个新缓冲区设置默认目录的值。重新加载.emacs时,它更改了您仅在的缓冲区的默认目录的值。

最新更新