我是一个Emacs新手,每次启动Spacemacs的时候总会重新compile很多然后显示
Found 1 orphan package(s) to delete...
--> deleting el-get... [1/1]
我发现如果我不用 ob-tangle
, i.e.
(require 'ob-tangle)
(org-babel-load-file
(expand-file-name “ruiconfig.org”
dotspacemacs-directory))
那么每次就不会编译很多然后删除deleting el-get…
然后我又尝试把 expand-file “ruiconfig.org” 里面的内容都删除,但是问题依然存在,求各位高手指教
以下是我的.spacemacs.d/init.el
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
dotspacemacs-distribution 'spacemacs
dotspacemacs-enable-lazy-installation 'unused
dotspacemacs-ask-for-lazy-installation t
dotspacemacs-configuration-layer-path '()
dotspacemacs-configuration-layers
'(
html
better-defaults
helm
;; ---completion---
(auto-completion :variables
auto-completion-return-key-behavior 'complete
auto-completion-tab-key-behavior 'cycle
auto-completion-complete-with-key-sequence nil
auto-completion-complete-with-key-sequence-delay 0.1
auto-completion-private-snippets-directory t
auto-completion-enable-snippets-in-popup t
auto-completion-enable-help-tooltip t
auto-completion-enable-sort-by-usage t
:disabled-for org markdown)
git
(org :variables
org-enable-github-support t
org-enable-bootstrap-support t
org-enable-reveal-js t
org-want-todo-bindings t)
spell-checking
syntax-checking
ranger ;; ranger file manager
(ibuffer :variables ibuffer-group-buffers-by nil)
;; ---IRC---
erc
;; ---lang---
bibtex
(c-c++ :variables
c-c++-default-mode-for-headers 'c++-mode
c-c++-enable-clang-support t
c-c++-enable-clang-format-on-save t
c-c++-enable-rtags-support t
c-c++-enable-google-style t
c-c++-enable-auto-newline t)
emacs-lisp
(ess :variables ess-disable-underscore-assign t)
graphviz
ipython-notebook
(latex :variables latex-enable-auto-fill t)
(markdown :variables markdown-mmm-auto-modes '("c" "c++" "python" "scala" ("elisp" "emacs-lisp")))
plantuml
(python :variables
python-backend 'anaconda
python-test-runner '(pytest)
;; python-enable-yapf-format-on-save t
)
csv
;; ivy
;; version-control
)
dotspacemacs-additional-packages '(
req-package
editorconfig
cdlatex
auctex
company-math
org-edit-latex
embrace
evil-embrace
ov
ob-ipython
)
;; A list of packages that cannot be updated.
dotspacemacs-frozen-packages '()
;; A list of packages that will not be installed and loaded.
dotspacemacs-excluded-packages '(magit-gh-pulls
magit-gitflow
evil-mc
skewer-mode
vi-tilde-fringe
coffee-mode
ace-jump-helm-line
evil-tutor
eyebrowse
stickyfunc-enhance
org-repo-todo
chinese-wbim
chinese-pyim
pyim
srefactor
org-download
org-timer
org-plus-contrib
org-tree-slide
git-gutter
git-gutter-fringe
spaceline
;; i prefer iedit
multiple-cursors
;; disable it for lispy-mode
;;https://github.com/abo-abo/lispy/issues/137
evil-escape
;; neotree
leuven-theme
gh-md
evil-lisp-state
spray
doc-view
lorem-ipsum
)
dotspacemacs-install-packages 'used-only))
(defun dotspacemacs/init ()
"Initialization function.
This function is called at the very startup of Spacemacs initialization
before layers configuration.
You should not put any user code in there besides modifying the variable
values."
(setq-default
dotspacemacs-elpa-https t
dotspacemacs-elpa-timeout 5
dotspacemacs-check-for-update nil
dotspacemacs-elpa-subdirectory nil
dotspacemacs-editing-style 'vim
dotspacemacs-verbose-loading nil
dotspacemacs-startup-banner nil
dotspacemacs-startup-lists '((recents . 5)
bookmarks
(projects . 7))
dotspacemacs-startup-buffer-responsive t
dotspacemacs-scratch-mode 'text-mode
dotspacemacs-themes '(monokai
spacemacs-light
spacemacs-dark)
dotspacemacs-colorize-cursor-according-to-state t
dotspacemacs-default-font '("Source Code Pro"
;; "Mono"
:size 24
:weight normal
:width normal
:powerline-scale 1.1)
;; The leader key
dotspacemacs-leader-key "SPC"
dotspacemacs-emacs-command-key "SPC"
dotspacemacs-ex-command-key ":"
dotspacemacs-emacs-leader-key "M-m"
dotspacemacs-major-mode-leader-key ","
dotspacemacs-major-mode-emacs-leader-key "C-M-m"
dotspacemacs-distinguish-gui-tab nil
dotspacemacs-remap-Y-to-y$ t
dotspacemacs-retain-visual-state-on-shift t
dotspacemacs-visual-line-move-text nil
dotspacemacs-ex-substitute-global nil
dotspacemacs-default-layout-name "Default"
dotspacemacs-display-default-layout nil
dotspacemacs-auto-resume-layouts nil
dotspacemacs-large-file-size 1
dotspacemacs-auto-save-file-location 'cache
dotspacemacs-max-rollback-slots 5
dotspacemacs-helm-resize nil
dotspacemacs-helm-no-header nil
dotspacemacs-helm-position 'bottom
dotspacemacs-helm-use-fuzzy 'always
dotspacemacs-enable-paste-transient-state nil
dotspacemacs-which-key-delay 0.4
dotspacemacs-which-key-position 'bottom
dotspacemacs-loading-progress-bar t
dotspacemacs-fullscreen-at-startup nil
dotspacemacs-fullscreen-use-non-native nil
dotspacemacs-maximized-at-startup nil
dotspacemacs-active-transparency 90
dotspacemacs-inactive-transparency 90
dotspacemacs-show-transient-state-title t
dotspacemacs-show-transient-state-color-guide t
dotspacemacs-mode-line-unicode-symbols nil
dotspacemacs-smooth-scrolling t
dotspacemacs-line-numbers t
dotspacemacs-folding-method 'evil
dotspacemacs-smartparens-strict-mode nil
dotspacemacs-smart-closing-parenthesis nil
dotspacemacs-highlight-delimiters 'all
dotspacemacs-persistent-server nil
dotspacemacs-search-tools '("ag" "pt" "ack" "grep")
dotspacemacs-default-package-repository nil
dotspacemacs-whitespace-cleanup nil
))
(defun dotspacemacs/user-init ()
"Initialization function for user code.
It is called immediately after `dotspacemacs/init', before layer configuration
executes.
This function is mostly useful for variables that need to be set
before packages are loaded. If you are unsure, you should try in setting them in
`dotspacemacs/user-config' first."
)
(defun dotspacemacs/user-config ()
"Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration.
This is the place where most of your configurations should be done. Unless it is
explicitly specified that a variable should be set before a package is loaded,
you should place your code here."
(require 'ob-tangle)
(org-babel-load-file
(expand-file-name "ruiconfig.org"
dotspacemacs-directory))
)
(setq custom-file (expand-file-name "custom.el" dotspacemacs-directory))
(load custom-file 'no-error 'no-message)
然后是我的 expand-file “ruiconfig.org”
* Beginning of configuration
** Initialize Package
#+BEGIN_SRC emacs-lisp
(require 'req-package)
#+END_SRC
* Spacemacs better defaults
Include the configuration of spacemacs itself layers and better use of its defaults layers.
** Buffer default coding system
#+BEGIN_SRC emacs-lisp
(setq system-time-locale "en_US")
(set-language-environment "UTF-8")
(setq-default default-buffer-file-coding-system 'utf-8)
;; (setq coding-system-for-write 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(setq locale-coding-system 'utf-8)
(prefer-coding-system 'gb18030)
(prefer-coding-system 'utf-8)
#+END_SRC
** Semantic
#+BEGIN_SRC emacs-lisp
(use-package semantic
:config
(setq-mode-local emacs-lisp-mode
semanticdb-find-default-throttle
(default-value 'semanticdb-find-default-throttle)))
#+END_SRC
* Basic setup
Some basic customizaton
In emacs, we can use =M-x= to execute interactive commands, I
implement some of them to make my emacs more easy to use.
** Add auto format paste code
#+BEGIN_SRC emacs-lisp
(dolist (command '(yank yank-pop))
(eval
`(defadvice ,command (after indent-region activate)
(and (not current-prefix-arg)
(member major-mode
'(emacs-lisp-mode
ess-mode
lisp-mode
clojure-mode
scheme-mode
haskell-mode
ruby-mode
rspec-mode
python-mode
c-mode
c++-mode
objc-mode
latex-mode
js-mode
plain-tex-mode))
(let ((mark-even-if-inactive transient-mark-mode))
(indent-region (region-beginning) (region-end) nil))))))
#+END_SRC
** Large file handle
#+BEGIN_SRC emacs-lisp
(setq large-file-warning-threshold 300000000)
(defun spacemacs/check-large-file ()
(when (> (buffer-size) 50000000)
(progn (fundamental-mode)
(hl-line-mode -1)))
(if (and (executable-find "wc")
(> (string-to-number (shell-command-to-string (format "wc -l %s" (buffer-file-name))))
5000))
(linum-mode -1)))
(add-hook 'find-file-hook 'spacemacs/check-large-file)
#+END_SRC
* Org-mode configuration
This part is the customization to org-mode.
** Org Latex Config
#+BEGIN_SRC emacs-lisp
;; Evilification
(with-eval-after-load 'haskell-interactive-mode
(evilified-state-evilify-map haskell-error-mode-map
:mode haskell-error-mode))
(with-eval-after-load 'proced
(evilified-state-evilify-map proced-mode-map
:mode proced-mode))
;; Org-latex
(require 'org)
(setq org-latex-create-formula-image-program 'dvisvgm)
(plist-put org-format-latex-options :scale 2)
;;######################### Org-Auto-Preview-Latex ################################
(defvar kk/org-latex-fragment-last nil
"Holds last fragment/environment you were on.")
(defun kk/org-in-latex-fragment-p ()
"Return the point where the latex fragment begins, if inside
a latex fragment. Else return false"
(let* ((el (org-element-context))
(el-type (car el)))
(and (or (eq 'latex-fragment el-type) (eq 'latex-environment el-type))
(org-element-property :begin el))))
(defun kk/org-latex-fragment-toggle ()
"Toggle a latex fragment image "
(and (eq 'org-mode major-mode)
(let ((begin (kk/org-in-latex-fragment-p)))
(cond
;; were on a fragment and now on a new fragment
((and
;; fragment we were on
kk/org-latex-fragment-last
;; and are on a fragment now
begin
;; but not on the last one this is a little tricky. as you edit the
;; fragment, it is not equal to the last one. We use the begin
;; property which is less likely to change for the comparison.
(not (and kk/org-latex-fragment-last
(= begin
kk/org-latex-fragment-last))))
;; go back to last one and put image back, provided there is still a fragment there
(save-excursion
(goto-char kk/org-latex-fragment-last)
(when (kk/org-in-latex-fragment-p) (org-preview-latex-fragment))
;; now remove current image
(goto-char begin)
(let ((ov (loop for ov in (org--list-latex-overlays)
if
(and
(<= (overlay-start ov) (point))
(>= (overlay-end ov) (point)))
return ov)))
(when ov
(delete-overlay ov)))
;; and save new fragment
(setq kk/org-latex-fragment-last begin)))
;; were on a fragment and now are not on a fragment
((and
;; not on a fragment now
(not begin)
;; but we were on one
kk/org-latex-fragment-last)
;; put image back on, provided that there is still a fragment here.
(save-excursion
(goto-char kk/org-latex-fragment-last)
(when (kk/org-in-latex-fragment-p) (org-preview-latex-fragment)))
;; unset last fragment
(setq kk/org-latex-fragment-last nil))
;; were not on a fragment, and now are
((and
;; we were not one one
(not kk/org-latex-fragment-last)
;; but now we are
begin)
;; remove image
(save-excursion
(goto-char begin)
(let ((ov (loop for ov in (org--list-latex-overlays)
if
(and
(<= (overlay-start ov) (point))
(>= (overlay-end ov) (point)))
return ov)))
(when ov
(delete-overlay ov))))
(setq kk/org-latex-fragment-last begin))))))
;; Add above to org-mode-hook
(add-hook 'post-command-hook 'kk/org-latex-fragment-toggle t)
#+END_SRC
** Org-mode auto complete
#+BEGIN_SRC emacs-lisp
(use-package company-math
:ensure t)
(use-package company-auctex
:ensure t
:config (progn
(defun company-auctex-labels (command &optional arg &rest ignored)
"company-auctex-labels backend"
(interactive (list 'interactive))
(case command
(interactive (company-begin-backend 'company-auctex-labels))
(prefix (company-auctex-prefix "\\\\.*ref{\\([^}]*\\)\\="))
(candidates (company-auctex-label-candidates arg))))
(add-to-list 'company-backends
'(company-auctex-macros
company-auctex-environments
company-math-symbols-unicode
company-math-symbols-latex))
(add-to-list 'company-backends #'company-auctex-labels)
(add-to-list 'company-backends #'company-auctex-bibs)))
(load "~/.spacemacs.d/package/emacscompanywords/company-words")
(add-hook 'org-mode-hook 'company-mode)
(add-hook 'org-mode-hook
(lambda ()
(set (make-local-variable 'company-backends) '(company-math-symbols-unicode company-math-symbols-latex company-files company-en-words company-dabbrev)))
)
#+END_SRC
** Better equation numbering in LaTeX fragments in org-mode
https://www.youtube.com/embed/pcMuJlUvKCw
#+BEGIN_SRC emacs-lisp
(defun org-renumber-environment (orig-func &rest args)
(let ((results '())
(counter -1)
(numberp))
(setq results (loop for (begin . env) in
(org-element-map (org-element-parse-buffer) 'latex-environment
(lambda (env)
(cons
(org-element-property :begin env)
(org-element-property :value env))))
collect
(cond
((and (string-match "\\\\begin{equation}" env)
(not (string-match "\\\\tag{" env)))
(incf counter)
(cons begin counter))
((string-match "\\\\begin{align}" env)
(prog2
(incf counter)
(cons begin counter)
(with-temp-buffer
(insert env)
(goto-char (point-min))
;; \\ is used for a new line. Each one leads to a number
(incf counter (count-matches "\\\\$"))
;; unless there are nonumbers.
(goto-char (point-min))
(decf counter (count-matches "\\nonumber")))))
(t
(cons begin nil)))))
(when (setq numberp (cdr (assoc (point) results)))
(setf (car args)
(concat
(format "\\setcounter{equation}{%s}\n" numberp)
(car args)))))
(apply orig-func args))
(advice-add 'org-create-formula-image :around #'org-renumber-environment)
;; (advice-remove 'org-create-formula-image #'org-renumber-environment)
#+END_SRC
* Programming Languages
This part is the customization to programming languages.
** Add support for editorconfig
[[http://editorconfig.org/][EditorConfig]] helps developers define and maintain consistent coding
styles between different editors and IDEs. The EditorConfig project
consists of a file format for defining coding styles and a collection
of text editor plugins that enable editors to read the file format and
adhere to defined styles. EditorConfig files are easily readable and
they work nicely with version control systems.
#+BEGIN_SRC emacs-lisp
(use-package editorconfig
:ensure t
:init
(add-hook 'prog-mode-hook (editorconfig-mode 1))
(add-hook 'text-mode-hook (editorconfig-mode 1)))
#+END_SRC
** Ess and R
#+BEGIN_SRC emacs-lisp
;; (defun add-ess-smart-S-assign ()
;; (interactive)
;; (insert " <- "))
;; (global-set-key (kbd "C-;") 'add-ess-smart-S-assign)
(add-hook 'R-mode-hook (lambda () (setq truncate-lines nil)))
(add-hook 'R-mode-hook 'smartparens-mode)
(add-hook 'R-mode-hook 'flycheck-mode)
(add-hook 'R-mode-hook 'flyspell-mode)
(add-hook 'inferior-ess-mode-hook 'company-mode)
(add-hook 'inferior-ess-mode-hook 'smartparens-mode)
(add-hook 'inferior-ess-mode-hook 'flycheck-mode)
(add-hook 'inferior-ess-mode-hook 'flyspell-mode)
#+END_SRC
** Python
#+BEGIN_SRC emacs-lisp
(add-hook 'python-mode-hook (lambda () (setq truncate-lines nil)))
(setq python-fill-column 80)
(add-hook 'inferior-python-mode-hook 'flycheck-mode)
(add-hook 'inferior-python-mode-hook 'flyspell-mode)
#+END_SRC
* External package besides Spacemacs
** Hungry-delete
https://github.com/kaushalmodi/.emacs.d/blob/master/setup-files/setup-hungry-delete.el
[[https://github.com/nflath/hungry-delete][hungry-delete]] borrows hungry deletion from =cc-mode=, which will causes deletion
to delete all whitespace in the direction you are deleting.
#+BEGIN_SRC emacs-lisp
(use-package hungry-delete
:config
(progn
(setq hungry-delete-chars-to-skip " \t\r\f\v")
;; Mon Nov 21 08:45:42 EST 2016 - kmodi
;; Override the default definitions of `hungry-delete-skip-ws-forward' and
;; `hungry-delete-skip-ws-backward'; do not delete back-slashes at EOL.
(defun hungry-delete-skip-ws-forward ()
"Skip over any whitespace following point.
This function skips over horizontal and vertical whitespace."
(skip-chars-forward hungry-delete-chars-to-skip)
(while (get-text-property (point) 'read-only)
(backward-char)))
(defun hungry-delete-skip-ws-backward ()
"Skip over any whitespace preceding point.
This function skips over horizontal and vertical whitespace."
(skip-chars-backward hungry-delete-chars-to-skip)
(while (get-text-property (point) 'read-only)
(forward-char)))
(defun modi/turn-off-hungry-delete-mode ()
"Turn off hungry delete mode."
(hungry-delete-mode -1))
;; Enable `hungry-delete-mode' everywhere ..
(global-hungry-delete-mode)
;; Except ..
;; `hungry-delete-mode'-loaded backspace does not work in `wdired-mode',
;; i.e. when editing file names in the *Dired* buffer.
(add-hook 'wdired-mode-hook #'modi/turn-off-hungry-delete-mode)
;; and in python-mode-hook
(add-hook 'python-mode-hook #'modi/turn-off-hungry-delete-mode)
;; and in minibuffer
(add-hook 'minibuffer-setup-hook #'modi/turn-off-hungry-delete-mode)))
#+END_SRC
* Other customization
This part is some customization not belong to the anterior part.
** Truncate lines automatically
#+BEGIN_SRC emacs-lisp
(add-hook 'magit-mode-hook (lambda () (setq truncate-lines nil)))
(add-hook 'org-mode-hook (lambda () (setq truncate-lines nil)))
(add-hook 'R-mode-hook (lambda () (setq truncate-lines nil)))
(add-hook 'python-mode-hook (lambda () (setq truncate-lines nil)))
#+END_SRC
* End of configuration
#+BEGIN_SRC emacs-lisp
(req-package-finish)
#+END_SRC