江湖救急,Win10下Emacs故障,求教

windows

#1

大家好,最近很少使用Windows 10,今天一进入,就发现Emacs 26.2的daemon模式无法启动了,表现为执行runemacs --daemon之后,任务管理器中的进程cpu占用逐渐升高到24%左右,内存占用升高到70MB左右,然后就被自动结束了。runemacs直接运行Emacs正常,runemacs --debug-init 没有看到什么有用信息。之前daemon模式是能正常运行的,好像也没有做其它什么操作。我想请教一下可能是什么原因,应该怎么排查。 下面是配置文件:

;; .emacs
;; Generated by realasking

(setenv "PATH" (concat "D:\\msys64\\mingw64\\bin;" (getenv "PATH")))

(add-to-list 'load-path "C:/maxima-5.41.0a/share/maxima/5.41.0a_dirty/emacs" )
(setq system-time-locale "C")
(push (expand-file-name "~/.emacs.d/lisp") load-path)

;; maximize window while startup
(add-to-list 'default-frame-alist '(fullscreen . maximized))

(require 'frame)
(defun set-cursor-hook (frame)
(modify-frame-parameters
  frame (list (cons 'cursor-color "grey"))))

(add-hook 'after-make-frame-functions 'set-cursor-hook)

(require 'unicad)

(require 'package)
(setq package-archives
      '(("marmalade"   . "http://mirrors.tuna.tsinghua.edu.cn/elpa/marmalade/")
        ("gnu"   . "http://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
        ("melpa" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")
	("melpa-stable" . "http://stable.melpa.org/pacakges/")))
(package-initialize)

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
  
(require 'use-package)

(when (not package-archive-contents)
  (package-refresh-contents))
(defvar myPackages
  '(better-defaults
    flycheck
    py-autopep8))

(mapc #'(lambda (package)
    (unless (package-installed-p package)
      (package-install package)))
      myPackages)
(setq inhibit-startup-message t) ;; hide the startup message
(global-linum-mode t) ;; enable line numbers globally

 (require 'cmake-mode)

 (autoload 'lammps-mode "lammps-mode.el" "LAMMPS mode." t)
(setq auto-mode-alist (append auto-mode-alist
                              '(("in\\." . lammps-mode))
                              '(("\\.lmp\\'" . lammps-mode))
                              ))

;; Sync View in two windows
;;-------------------------------------

(defun split-and-sync-windows() 
    "Run `some-command' and `some-other-command' in sequence." 
    (interactive) 
    (split-window-horizontally) 
    (follow-mode)) 

(global-set-key (kbd "C-c s") 'split-and-sync-windows)

(defun split-and-sync-turnoff() 
    "Run `some-command' and `some-other-command' in sequence." 
    (interactive) 
    (follow-mode)
    (delete-other-windows)) 

(global-set-key (kbd "C-c t") 'split-and-sync-turnoff)


;; PYTHON CONFIGURATION
;; --------------------------------------
;; Cannot chage to ovitos, because no parameter i in ovitos 
(setq python-shell-interpreter "ipython"
      python-shell-interpreter-args "-i --simple-prompt")
(global-set-key [f6] 'run-python)

;; Latex CONFIGURATION
;; --------------------------------------
(setq latex-run-command "xelatex")

;;PDF tools CONFIGURATION
;; --------------------------------------
(setenv "PATH" (concat "/usr/bin;" (getenv "PATH")))
(pdf-tools-install)
(add-hook 'pdf-view-mode-hook (lambda() (linum-mode -1)));
(add-hook 'pdf-view-mode-hook (lambda ()
				(pdf-view-midnight-minor-mode)))

(setq pdf-view-midnight-colors '( "#2e311f" . "#adc9bb" ))

;; Octave CONFIGURATION
;;--------------------------------------
 (setenv "PATH" (concat "D:\\Octave\\Octave-4.4.1\\bin;" (getenv "PATH")))
 (setq inferior-octave-program "D:/Octave/Octave-4.4.1/bin/octave-cli.exe")
(let ((default-directory (file-name-directory
			  (executable-find inferior-octave-program))))
);;  (run-octave))
(global-set-key [f5] 'run-octave)

;; WordPress CONFIGURATION
;; --------------------------------------
;; Chinese support is not good, and not safe to store password in clear text
(let ((*outline-data* nil))
  (defun org-save-outline-state (&optional arg type)
    (setq *outline-data* (org-outline-overlay-data t)))

  (defun org-restore-outline-state (&optional arg)
    (when *outline-data*
      (org-set-outline-overlay-data *outline-data*)
      (setq *outline-data* nil))))
(use-package org2blog
  :ensure t
  :config
  ;; Experiments
  (require 'auth-source) ;; or nothing if already in the load-path
  (setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
  (let (credentials)
    ;; only required if your auth file is not already in the list of auth-sources
    ;; Always keep config and username/password separated
    (add-to-list 'auth-sources "~/.netrc")
    (setq credentials (auth-source-user-and-password "域名"))
    (setq org2blog/wp-blog-alist
          `(("用户名"
             :url "https://域名/xmlrpc.php"
             :username ,(car credentials)
             :password ,(cadr credentials)
             )))))
(setq org2blog/wp-buffer-template
      "#+ORG2BLOG:
#+DATE: %s
#+OPTIONS: toc:nil num:nil todo:nil pri:nil tags:nil ^:nil
#+CATEGORY: %s
#+TAGS:
#+DESCRIPTION:
#+TITLE: %s
\n
#+BEGIN_EXPORT html
(如果输入Markdown,请保留EXPORT标记,只用输入内容替换本括号内内容及括号,否则请删除)
#+END_EXPORT")

(require 'posframe)

(require 'bing-dict)
(setq bing-dict-show-thesaurus 'both)
(setq bing-dict-vocabulary-save t)
(setq bing-dict-cache-auto-save t)
(global-set-key (kbd "C-c d") 'bing-dict-brief)

;; English Helper
;;----------------------------------------------------------
(add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp/company-english-helper"))
(require 'company-english-helper)
(global-set-key [f7] 'toggle-company-english-helper)


(require 'ido)
(ido-mode t)
(recentf-mode 1)
(setq recentf-max-menu-items 50)
(setq recentf-max-saved-items 50)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)
(run-at-time nil (* 5 60) 'recentf-save-list)

(require 'vlf-setup)

;; Open DirTree, `M-x neotree`
(require 'neotree)
(global-set-key [f8] 'neotree-toggle)


;;Workgroups Settings
;;--------------------------------------
(require 'workgroups)
(setq wg-prefix-key (kbd "C-c w"))
(workgroups-mode 1)
;;Usage:C-c w  Open WGs
;;           Then input:
;;           c    Create new Group
;;           v    Switch Group
;;           C-l  Load a file saved many Groups
;;           C-s Save Groups to a file
;;Group should be defined after the Windows had been splitted.


;;Window Move
;;--------------------------------------
(global-set-key (kbd "C-c <right>") 'windmove-right)
(global-set-key (kbd "C-c <left>") 'windmove-left)
(global-set-key (kbd "C-c <up>") 'windmove-up)
(global-set-key (kbd "C-c <down>") 'windmove-down)

;;Mark Block
;;--------------------------------------
(global-set-key (kbd "C-.") 'set-mark-command)

;; Tabbar
(require 'tabbar)
;; Tabbar settings
(tabbar-mode 1)

(set-face-attribute
 'tabbar-default nil
 :background "gray20"
 :foreground "gray20"
 :box '(:line-width 1 :color "gray20" :style nil))
(set-face-attribute
 'tabbar-unselected nil
 :background "gray30"
 :foreground "white"
 :box '(:line-width 5 :color "gray30" :style nil))
(set-face-attribute
 'tabbar-selected nil
 :background "gray75"
 :foreground "black"
 :box '(:line-width 5 :color "gray75" :style nil))
(set-face-attribute
 'tabbar-highlight nil
 :background "white"
 :foreground "black"
 :underline nil
 :box '(:line-width 5 :color "white" :style nil))
(set-face-attribute
 'tabbar-button nil
 :box '(:line-width 1 :color "gray20" :style nil))
(set-face-attribute
 'tabbar-separator nil
 :background "gray20"
 :height 0.6)

;; Change padding of the tabs
;; we also need to set separator to avoid overlapping tabs by highlighted tabs

;; buffer management
;; kill all buffers
(defun kill-all-buffers ()
  "Kill all buffers"
  (interactive)
  (mapc 'kill-buffer (buffer-list)))
(global-set-key (kbd "C-x C-k a") 'kill-all-buffers)

;; kill buffers execpt the current one
(defun kill-other-buffers ()
   "Kill all other buffers."
   (interactive)
   (mapc 'kill-buffer (delq (current-buffer) (buffer-list))))
(global-set-key (kbd "C-x C-k o") 'kill-all-buffers)

;; adding spaces
(defun tabbar-buffer-tab-label (tab)
  "Return a label for TAB.
That is, a string used to represent it on the tab bar."
  (let ((label  (if tabbar--buffer-show-groups
                    (format "[%s]  " (tabbar-tab-tabset tab))
                  (format "%s  " (tabbar-tab-value tab)))))
    ;; Unless the tab bar auto scrolls to keep the selected tab
    ;; visible, shorten the tab label to keep as many tabs as possible
    ;; in the visible area of the tab bar.
    (if tabbar-auto-scroll-flag
        label
      (tabbar-shorten
       label (max 1 (/ (window-width)
                       (length (tabbar-view
                                (tabbar-current-tabset)))))))))
                                
 (defun tabbar-add-tab (tabset object &optional append)
        "Override tabbar-add-tab, makes new tab open on the right of the current tab"
        (let ((tabs (tabbar-tabs tabset)))
          (if (tabbar-get-tab object tabset)
              tabs
            (let ((tab (tabbar-make-tab object tabset))
                  (previous-tab (tabbar-selected-tab tabset))
                  (other-tabs (list)))
              (tabbar-set-template tabset nil)
              (if append
                  (progn
                    (while (not (string= (format "%s" (car previous-tab)) (format "%s" (car (car tabs)))))
                      (push (car tabs) other-tabs)
                      (setq tabs (cdr tabs)))
                    (push (car tabs) other-tabs)
                    (setq tabs (cdr tabs))
                    (push tab other-tabs)
                    (setq other-tabs (reverse other-tabs))
                    (set tabset (append other-tabs tabs)))
                (set tabset(cons tab tabs)))))))

;; .emacs ends here
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ansi-color-faces-vector
   [default bold shadow italic underline bold bold-italic bold])
 '(ansi-color-names-vector
   (vector "#ffffff" "#f36c60" "#8bc34a" "#fff59d" "#4dd0e1" "#b39ddb" "#81d4fa" "#263238"))
 '(company-quickhelp-color-background "#D0D0D0")
 '(company-quickhelp-color-foreground "#494B53")
 '(custom-enabled-themes (quote (subtle-hacker)))
 '(custom-safe-themes
   (quote
    ("43b219a31db8fddfdc8fdbfdbd97e3d64c09c1c9fdd5dff83f3ffc2ddb8f0ba0" "d9aa334b2011d57c8ce279e076d6884c951e82ebc347adbe8b7ac03c4b2f3d72" "732b807b0543855541743429c9979ebfb363e27ec91e82f463c91e68c772f6e3" "0dd2666921bd4c651c7f8a724b3416e95228a13fca1aa27dc0022f4e023bf197" "abd7719fd9255fcd64f631664390e2eb89768a290ee082a9f0520c5f12a660a8" "a24c5b3c12d147da6cef80938dca1223b7c7f70f2f382b26308eba014dc4833a" "b47946a3a69d091a75b89819983835ac6f7fb94c9b491da38a4907b1185bebe0" default)))
 '(fci-rule-color "#37474f")
 '(hl-sexp-background-color "#1c1f26")
 '(package-selected-packages
   (quote
    (pdf-tools workgroups workgroups2 ## vmd-mode vlf use-package-el-get tabbar session py-autopep8 org2blog one-themes neotree matlab-mode material-theme markdown-toc lush-theme lammps-mode flycheck evil elpy cuda-mode cmake-mode chinese-yasdcv bliss-theme blackboard-theme better-defaults auctex ac-python ac-math ac-clang ac-c-headers)))
 '(tool-bar-mode nil))

(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(default ((t (:family "Courier New" :foundry "outline" :slant normal :weight normal :height 120 :width normal))))
 '(company-preview ((t (:foreground "darkgray" :underline t))))
 '(company-preview-common ((t (:inherit company-preview))))
 '(company-scrollbar-bg ((t (:background "#121212"))))
 '(company-scrollbar-fg ((t (:background "#121212"))))
 '(company-tooltip ((t (:background "#bec2b5" :foreground "black"))))
 '(company-tooltip-common ((((type x)) (:inherit company-tooltip :weight bold)) (t (:inherit company-tooltip))))
 '(company-tooltip-common-selection ((((type x)) (:inherit company-tooltip-selection :weight bold)) (t (:inherit company-tooltip-selection))))
 '(company-tooltip-selection ((t (:background "#98c5a9" :foreground "black")))))

#2

解决了。吃饭前删掉了所有Emacs开始使用之后自动生成的文件,注释掉了recentf,unicad,还有词典,然后关了机,吃饭后再开机就正常了,不知道原因。