1

何と言ったらいいのかわからない。

私はemacsのカスタマイズに取り組んできましたが、.emacs起動時に実際にロードされていないことに気付きました。(http://www.gnu.org/software/emacs/manual/html_node/emacs/Find-Init.html#Find-Init)によると、emacsは~/最初にホームディレクトリ()で初期化ファイルを探します...

emacsを起動すると、.emacsファイルが正しく読み取られているよう.notesに見えます。たとえば、ファイルにアクセスすると、フックが評価されます。驚いたことに、default-directoryが設定されていません。同じロードファイル内のコマンドです。手動で評価することも、単に実行することもできますが、正常(load "~/.emacs")に機能します。

質問を要約できると思います。load手動で実行したときにコマンドが期待どおりに機能する場合、なぜ自動的に起動しないのですか?

完全な(コメントアウトされた関数を除く).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)))
4

1 に答える 1

6

デフォルト ディレクトリはバッファ ローカルです。あなたの .emacs は問題なくロードされています。default-directory の値は、開いた新しいバッファごとに (再) 設定されます。.emacs を再ロードすると、現在のバッファーのみの default-directory の値が変更されます。

于 2012-12-19T18:10:40.663 に答える