贴上两个配置的代码,一是custom.el,一是init.el 文件。谢谢你了。
(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.
'(package-selected-packages
(quote
(helm-bibtex counsel zop-to-char zenburn-theme which-key volatile-highlights undo-tree super-save smartrep smartparens operate-on-number move-text magit projectile imenu-anywhere hl-todo guru-mode gitignore-mode gitconfig-mode git-timemachine gist flycheck expand-region epl editorconfig easy-kill diminish diff-hl discover-my-major crux browse-kill-ring beacon anzu ace-window))))
(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.
)
(menu-bar-mode 1)
(scroll-bar-mode 1)
(global-linum-mode t)
(global-company-mode t)
(setq cursor-type 'bar)
(setq ring-bell-function 'ignore)
(defun open-my-custom-file()
(interactive)
(find-file “~/.emacs.d/personal/custom.el”))
(global-set-key (kbd “”) 'open-my-custom-file)
;; Load path
;; Optimize: Force “lisp”" and “site-lisp” at the head to reduce the startup time.
(defun update-load-path (&rest _)
“Update `load-path’.”
(dolist (dir '(“site-lisp” “lisp”))
(push (expand-file-name dir user-emacs-directory) load-path)))
(defun add-subdirs-to-load-path (&rest _)
“Add subdirectories to `load-path’.”
(let ((default-directory (expand-file-name “site-lisp” user-emacs-directory)))
(normal-top-level-add-subdirs-to-load-path)))
(advice-add #'package-initialize :after #'update-load-path)
(advice-add #'package-initialize :after #'add-subdirs-to-load-path)
(update-load-path)
;;; 改五笔输入
;;(autoload 'chinese-wbim-use-package “chinese-wbim” “Another emacs input method”)
;;(setq chinese-wbim-use-tooltip nil)
;;(register-input-method
;; “chinese-wbim” “euc-cn” 'chinese-wbim-use-package
;; “五笔” “汉字五笔输入法” “wb.txt”)
;;; 用 ; 暂时输入英文
;;(require 'chinese-wbim-extra)
;;(global-set-key “;” 'chinese-wbim-insert-ascii)
;;(setq default-input-method 'chinese-wbim)
;;; settings for ebib
;;(setq ebib-citation-commands
;; (quote ((org-mode ((“cite” “\cite{%K}”))))))
;;(require 'mm-url)
;;(defun ebib-import-bibtex (url)
(interactive)
;;
;; (with-temp-buffer
;; (mm-url-insert-file-contents url)
(ebib-import)))
;; settings for org-ref
(setq reftex-default-bibliography '(“~/Reference/Literature.bib”))
;;see org-ref for use of these variables
(setq org-ref-bibliography-notes “~/Reference/ReferenceReadingNotes.org”
org-ref-default-bibliography '(“~/Reference/Reference.bib”)
org-ref-pdf-directory “G:/学术科研/论文”)
(setq bibtex-completion-bibliography “~/Reference/Literature.bib”
bibtex-completion-library-path “G:/学术科研/论文”
bibtex-completion-notes-path “~/Reference/Literature-manuscript.org”)
(setq org-ref-completion-library 'org-ref-ivy-cite)
(setq org-ref-insert-link-key “C-c ]”)
(org-ref-define-citation-link “citez” ?z)
(defun org-ref-cite-link-format (keyword desc format)
(cond
((eq format 'html) (format “(%s)” path))
((eq format 'latex)
(concat “\cite” (when desc (format “[%s]” desc)) “{”
(mapconcat (lambda (key) key) (org-ref-split-and-strip-string keyword) “,”)
“}”))))
(org-add-link-type
“cite”
'org-ref-cite-onclick-minibuffer-menu ;; clicking function
'org-ref-cite-link-format) ;; formatting function
;; Tell org-ref to let helm-bibtex find notes for it
(setq org-ref-notes-function
(lambda (thekey)
(let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
(bibtex-completion-edit-notes
(list (car (org-ref-get-bibtex-key-and-file thekey)))))))
;; open pdf with system pdf viewer (works on mac)
(setq bibtex-completion-pdf-open-function 'org-open-file)
(setq org-latex-pdf-process (list “latexmk -shell-escape -bibtex -f -pdf %f”))
(defun my/org-ref-open-pdf-at-point ()
“Open the pdf for bibtex key under point if it exists.”
(interactive)
(let* ((results (org-ref-get-bibtex-key-and-file))
(key (car results))
(pdf-file (funcall org-ref-get-pdf-filename-function key)))
(if (file-exists-p pdf-file)
(find-file pdf-file)
(message “No PDF found for %s” key))))
(setq org-ref-open-pdf-function 'my/org-ref-open-pdf-at-point)
(require 'org-ref)
(require 'org-id)
(require 'doi-utils)
(require 'org-ref-wos)
(require 'org-ref-scopus)
(require 'org-ref-pdf)
;;(use-package helm-bibtex :ensure t
;; :bind (“” . helm-bibtex)
;; :commands (helm-bibtex)
;; :init
;; (add-hook 'bibtex-completion-edit-notes 'org-ref-open-bibtex-notes)
;; (setq bibtex-completion-open-any 'org-ref-open-bibtex-pdf)
;; :config
;; (setq bibtex-completion-bibliography “~/Reference/Reference.bib”
;; bibtex-completion-library-path “G:/学术科研/论文”
;; bibtex-completion-notes-path “~/Reference/ReferenceReadingNotes.org”)
;; (setq bibtex-completion-display-formats
;; '((t . "{=type=:7} {year:4} {=has-pdf=:1}{=has-note=:1} {author:30} {title:72} ")))
;; (setq bibtex-completion-additional-search-fields '(keywords))
;; (setq bibtex-completion-notes-template-one-file
;; (format “\n** TODO {=key=} - {title}\n :PROPERTIES:\n :Author: {author-or-editor}\n ;;:Journal: {journal}\n \n\n”))
;; (setq bibtex-completion-display-formats
;; '((t . “{author:20} {year:4} {=has-pdf=:3} {=has-note=:1} {=type=:7} {title:90}”)))
;; (setq bibtex-completion-pdf-field “file”)
;; (setq bibtex-completion-pdf-symbol “PDF”)
;; (setq bibtex-completion-notes-symbol “N”)
;; )
;; (setq bibtex-completion-display-formats
;; '((t . “{author:20} {year:4} {=has-pdf=:3} {=has-note=:1} {=type=:7} {title:90}”)))
;; (defun my/org-ref-notes-function (candidates)
;; (let ((key (helm-marked-candidates)))
;; (funcall org-ref-notes-function (car key))))
;; (helm-delete-action-from-source “Edit notes” helm-source-bibtex)
;;; Note that 7 is a magic number of the index where you want to insert the command. You may need to change yours.
;; (helm-add-action-to-source “Edit notes” 'my/org-ref-notes-function helm-source-bibtex 7)
)
;;; init.el — Prelude’s configuration entry point.
;;
;; Copyright (c) 2011-2020 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov [email protected]
;; URL: Redirecting…
;; Version: 1.0.0
;; Keywords: convenience
;; This file is not part of GNU Emacs.
;;; Commentary:
;; This file simply sets up the default load path and requires
;; the various modules defined within Emacs Prelude.
;;; License:
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version 3
;; of the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
;; Added by Package.el. This must come before configurations of
;; installed packages. Don’t delete this line. If you don’t want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
;(package-initialize)
(defvar current-user
(getenv
(if (equal system-type 'windows-nt) “USERNAME” “USER”)))
(message “Prelude is powering up… Be patient, Master %s!” current-user)
(when (version< emacs-version “25.1”)
(error “Prelude requires GNU Emacs 25.1 or newer, but you’re running %s” emacs-version))
;; Always load newest byte code
(setq load-prefer-newer t)
(defvar prelude-dir (file-name-directory load-file-name)
“The root dir of the Emacs Prelude distribution.”)
(defvar prelude-core-dir (expand-file-name “core” prelude-dir)
“The home of Prelude’s core functionality.”)
(defvar prelude-modules-dir (expand-file-name “modules” prelude-dir)
“This directory houses all of the built-in Prelude modules.”)
(defvar prelude-personal-dir (expand-file-name “personal” prelude-dir)
"This directory is for your personal configuration.
Users of Emacs Prelude are encouraged to keep their personal configuration
changes in this directory. All Emacs Lisp files there are loaded automatically
by Prelude.")
(defvar prelude-personal-preload-dir (expand-file-name “preload” prelude-personal-dir)
“This directory is for your personal configuration, that you want loaded before Prelude.”)
(defvar prelude-vendor-dir (expand-file-name “vendor” prelude-dir)
“This directory houses packages that are not yet available in ELPA (or MELPA).”)
(defvar prelude-savefile-dir (expand-file-name “savefile” prelude-dir)
“This folder stores all the automatically generated save/history-files.”)
(defvar prelude-modules-file (expand-file-name “prelude-modules.el” prelude-personal-dir)
“This file contains a list of modules that will be loaded by Prelude.”)
(defvar prelude-deprecated-modules-file
(expand-file-name “prelude-modules.el” prelude-dir)
(format "This file may contain a list of Prelude modules.
This is DEPRECATED, use %s instead." prelude-modules-file))
(unless (file-exists-p prelude-savefile-dir)
(make-directory prelude-savefile-dir))
(defun prelude-add-subfolders-to-load-path (parent-dir)
“Add all level PARENT-DIR subdirs to the `load-path’.”
(dolist (f (directory-files parent-dir))
(let ((name (expand-file-name f parent-dir)))
(when (and (file-directory-p name)
(not (string-prefix-p “.” f)))
(add-to-list 'load-path name)
(prelude-add-subfolders-to-load-path name)))))
;; add Prelude’s directories to Emacs’s `load-path’
(add-to-list 'load-path prelude-core-dir)
(add-to-list 'load-path prelude-modules-dir)
(add-to-list 'load-path prelude-vendor-dir)
(prelude-add-subfolders-to-load-path prelude-vendor-dir)
;; reduce the frequency of garbage collection by making it happen on
;; each 50MB of allocated data (the default is on every 0.76MB)
(setq gc-cons-threshold 50000000)
;; warn when opening files bigger than 100MB
(setq large-file-warning-threshold 100000000)
;; preload the personal settings from `prelude-personal-preload-dir’
(when (file-exists-p prelude-personal-preload-dir)
(message “Loading personal configuration files in %s…” prelude-personal-preload-dir)
(mapc 'load (directory-files prelude-personal-preload-dir 't “^[^#.].*el$”)))
(message “Loading Prelude’s core…”)
;; the core stuff
(require 'prelude-packages)
(require 'prelude-custom) ;; Needs to be loaded before core, editor and ui
(require 'prelude-ui)
(require 'prelude-core)
(require 'prelude-mode)
(require 'prelude-editor)
(require 'prelude-global-keybindings)
;; macOS specific settings
(when (eq system-type 'darwin)
(require 'prelude-macos))
;; Linux specific settings
(when (eq system-type 'gnu/linux)
(require 'prelude-linux))
(message “Loading Prelude’s modules…”)
;; the modules
(if (file-exists-p prelude-modules-file)
(progn
(load prelude-modules-file)
(if (file-exists-p prelude-deprecated-modules-file)
(message “Loading new modules configuration, ignoring DEPRECATED prelude-module.el”)))
(if (file-exists-p prelude-deprecated-modules-file)
(progn
(load prelude-deprecated-modules-file)
(message (format “The use of %s is DEPRECATED! Use %s instead!”
prelude-deprecated-modules-file
prelude-modules-file)))
(message “Missing modules file %s” prelude-modules-file)
(message “You can get started by copying the bundled example file from sample/prelude-modules.el”)))
;; config changes made through the customize UI will be stored here
(setq custom-file (expand-file-name “custom.el” prelude-personal-dir))
;; load the personal settings (this includes `custom-file’)
(when (file-exists-p prelude-personal-dir)
(message “Loading personal configuration files in %s…” prelude-personal-dir)
(mapc 'load (delete
prelude-modules-file
(directory-files prelude-personal-dir 't “^[^#.].*\.el$”))))
(message “Prelude is ready to do thy bidding, Master %s!” current-user)
;; Patch security vulnerability in Emacs versions older than 25.3
(when (version< emacs-version “25.3”)
(with-eval-after-load “enriched”
(defun enriched-decode-display-prop (start end &optional param)
(list start end))))
(prelude-eval-after-init
;; greet the use with some useful tip
(run-at-time 5 nil 'prelude-tip-of-the-day))
;;; init.el ends here