Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning at start-up after changing dotspacemacs #6980

Closed
yilihong opened this issue Sep 1, 2016 · 5 comments
Closed

warning at start-up after changing dotspacemacs #6980

yilihong opened this issue Sep 1, 2016 · 5 comments

Comments

@yilihong
Copy link

yilihong commented Sep 1, 2016

Hi, I receive this warning from time to time after changing the .spacemacs file, when I close emacs and reload, it typically just go away, emacs --debug-init won't report any error. Anyone experiencing something similar?

screenshot 2016-08-31 22 13 20

@NJBS
Copy link
Contributor

NJBS commented Sep 1, 2016

Can you post your .spacemacs file?

@yilihong
Copy link
Author

yilihong commented Sep 1, 2016

@NJBS

Here it is. It's pretty messy...

;; -*- mode: emacs-lisp -*-
;; This file should be stored in the home directory.

(defun dotspacemacs/layers ()
  "Configuration Layers declaration.
Do not put any user code in this function besides modifying the variable
values."
  (setq-default
   ;; Base distribution to use. This is a layer contained in the directory
   ;; `+distribution'. For now available distributions are `spacemacs-base'
   ;; or `spacemacs'. (default 'spacemacs)
   dotspacemacs-distribution 'spacemacs-base
   ;; List of additional paths where to look for configuration layers.
   ;; Paths must have a trailing slash (i.e. `~/.mycontribs/')
   dotspacemacs-configuration-layer-path '()
   ;; List of configuration layers to load. If it is the symbol `all' instead
   ;; of a list then all discovered layers will be installed.
   dotspacemacs-configuration-layers
   '(
     ;; ----------------------------------------------------------------
     ;; Example of useful layers you may want to use right away.
     ;; Uncomment some layer names and press <SPC f e R> (Vim style) or
     ;; <M-m f e R> (Emacs style) to install them.
     ;; ----------------------------------------------------------------
     (auto-completion :variables
                      auto-completion-enable-snippets-in-popup t
                      auto-completion-enable-help-tooltip t
                      auto-completion-enable-sort-by-usage t)
     (chinese :variables
              chinese-enable-youdao-dict t)
     better-defaults
     emacs-lisp
     (git :variables
          git-gutter-use-fringe t)
     github
     markdown
     python
     (latex :variables
            latex-build-command "LatexMk"
            latex-enable-auto-fill nil
            latex-enable-folding nil)
     html
     themes-megapack
     (shell :variables
             shell-default-height 30
             shell-default-position 'bottom
             shell-default-shell 'eshell
             shell-enable-smart-eshell t)
     (spell-checking :variables
                     spell-checking-enable-by-default nil
                     spell-checking-enable-auto-dictionary t)
     (syntax-checking :variables
                      syntax-checking-enable-by-default nil)
     ;;(version-control :variables
     ;;                 version-control-diff-tool 'diff-hl
     ;;                version-control-global-margin t)
     (org :variables
          org-enable-github-support t)
     (colors :variables
             colors-enable-rainbow-identifiers nil
             colors-enable-nyan-cat-progress-bar nil)
     eyebrowse
     pandoc
     dash
     ;;vinegar
     ;;geolocation
     )
   ;; List of additional packages that will be installed without being
   ;; wrapped in a layer. If you need some configuration for these
   ;; packages, consider creating a layer. You can also put the
   ;; configuration in `dotspacemacs/user-config'.
   dotspacemacs-additional-packages
   '(anzu
     dired+
     highlight-indentation
     neotree
     ace-window
     projectile
     tramp
     popup
     reveal-in-osx-finder
     pdf-tools
     autopair
     multiple-cursors
     ;;w3m
     exec-path-from-shell
     ox-twbs
     org-ref
     hydra
     key-chord
     parsebib
     async
     osx-dictionary
     popwin
     shackle
     gscholar-bibtex
     request
     spaceline
     diminish
     flycheck
     ;;golden-ratio
     hungry-delete
     magic-latex-buffer
     )
   ;; A list of packages and/or extensions that will not be install and loaded.
   dotspacemacs-excluded-packages '()
   ;; If non-nil spacemacs will delete any orphan packages, i.e. packages that
   ;; are declared in a layer which is not a member of
   ;; the list `dotspacemacs-configuration-layers'. (default t)
   dotspacemacs-delete-orphan-packages t))

(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."
  ;; This setq-default sexp is an exhaustive list of all the supported
  ;; spacemacs settings.
  (setq-default
   ;; If non nil ELPA repositories are contacted via HTTPS whenever it's
   ;; possible. Set it to nil if you have no way to use HTTPS in your
   ;; environment, otherwise it is strongly recommended to let it set to t.
   ;; This variable has no effect if Emacs is launched with the parameter
   ;; `--insecure' which forces the value of this variable to nil.
   ;; (default t)
   dotspacemacs-elpa-https nil
   ;; Maximum allowed time in seconds to contact an ELPA repository.
   dotspacemacs-elpa-timeout 5
   ;; If non nil then spacemacs will check for updates at startup
   ;; when the current branch is not `develop'. (default t)
   dotspacemacs-check-for-update t
   ;; One of `vim', `emacs' or `hybrid'. Evil is always enabled but if the
   ;; variable is `emacs' then the `holy-mode' is enabled at startup. `hybrid'
   ;; uses emacs key bindings for vim's insert mode, but otherwise leaves evil
   ;; unchanged. (default 'vim)
   dotspacemacs-editing-style 'emacs
   ;; If non nil output loading progress in `*Messages*' buffer. (default nil)
   dotspacemacs-verbose-loading nil
   ;; Specify the startup banner. Default value is `official', it displays
   ;; the official spacemacs logo. An integer value is the index of text
   ;; banner, `random' chooses a random text banner in `core/banners'
   ;; directory. A string value must be a path to an image format supported
   ;; by your Emacs build.
   ;; If the value is nil then no banner is displayed. (default 'official)
   dotspacemacs-startup-banner 'random
   ;; List of items to show in the startup buffer. If nil it is disabled.
   ;; Possible values are: `recents' `bookmarks' `projects'.
   ;; (default '(recents projects))
   dotspacemacs-startup-lists '(recents bookmarks)
   ;; Number of recent files to show in the startup buffer. Ignored if
   ;; `dotspacemacs-startup-lists' doesn't include `recents'. (default 5)
   dotspacemacs-startup-recent-list-size 5
   ;; Default major mode of the scratch buffer (default `text-mode')
   dotspacemacs-scratch-mode 'text-mode
   ;; List of themes, the first of the list is loaded when spacemacs starts.
   ;; Press <SPC> T n to cycle to the next theme in the list (works great
   ;; with 2 themes variants, one dark and one light)
   dotspacemacs-themes '(spacemacs-dark
                         wombat
                         sanityinc-tomorrow-eighties
                         tangotango
                         sanityinc-tomorrow-night
                         apropospriate-dark
                         cyberpunk
                         spacemacs-light
                         flatland
                         solarized-light
                         solarized-dark
                         leuven
                         monokai
                         zenburn)
   ;; If non nil the cursor color matches the state color in GUI Emacs.
   dotspacemacs-colorize-cursor-according-to-state t
   ;; Default font. `powerline-scale' allows to quickly tweak the mode-line
   ;; size to make separators look not too crappy.
   dotspacemacs-default-font '("InconsolataGo"
                               :size 18
                               :weight normal
                               :width normal
                               :powerline-scale 1)
   ;; The leader key
   dotspacemacs-leader-key "SPC"
   ;; The leader key accessible in `emacs state' and `insert state'
   ;; (default "M-m")
   dotspacemacs-emacs-leader-key "M-m"
   ;; Major mode leader key is a shortcut key which is the equivalent of
   ;; pressing `<leader> m`. Set it to `nil` to disable it. (default ",")
   dotspacemacs-major-mode-leader-key ","
   ;; Major mode leader key accessible in `emacs state' and `insert state'.
   ;; (default "C-M-m)
   dotspacemacs-major-mode-emacs-leader-key "C-M-m"
   ;; These variables control whether separate commands are bound in the GUI to
   ;; the key pairs C-i, TAB and C-m, RET.
   ;; Setting it to a non-nil value, allows for separate commands under <C-i>
   ;; and TAB or <C-m> and RET.
   ;; In the terminal, these pairs are generally indistinguishable, so this only
   ;; works in the GUI. (default nil)
   dotspacemacs-distinguish-gui-tab nil
   ;; (Not implemented) dotspacemacs-distinguish-gui-ret nil
   ;; The command key used for Evil commands (ex-commands) and
   ;; Emacs commands (M-x).
   ;; By default the command key is `:' so ex-commands are executed like in Vim
   ;; with `:' and Emacs commands are executed with `<leader> :'.
   dotspacemacs-command-key ":"
   ;; If non nil `Y' is remapped to `y$'. (default t)
   dotspacemacs-remap-Y-to-y$ t
   ;; Name of the default layout (default "Default")
   dotspacemacs-default-layout-name "Default"
   ;; If non nil the default layout name is displayed in the mode-line.
   ;; (default nil)
   dotspacemacs-display-default-layout nil
   ;; If non nil then the last auto saved layouts are resume automatically upon
   ;; start. (default nil)
   dotspacemacs-auto-resume-layouts nil
   ;; Location where to auto-save files. Possible values are `original' to
   ;; auto-save the file in-place, `cache' to auto-save the file to another
   ;; file stored in the cache directory and `nil' to disable auto-saving.
   ;; (default 'cache)
   dotspacemacs-auto-save-file-location 'cache
   ;; Maximum number of rollback slots to keep in the cache. (default 5)
   dotspacemacs-max-rollback-slots 5
   ;; If non nil then `ido' replaces `helm' for some commands. For now only
   ;; `find-files' (SPC f f), `find-spacemacs-file' (SPC f e s), and
   ;; `find-contrib-file' (SPC f e c) are replaced. (default nil)
   dotspacemacs-use-ido nil
   ;; If non nil, `helm' will try to minimize the space it uses. (default nil)
   dotspacemacs-helm-resize t
   ;; if non nil, the helm header is hidden when there is only one source.
   ;; (default nil)
   dotspacemacs-helm-no-header nil
   ;; define the position to display `helm', options are `bottom', `top',
   ;; `left', or `right'. (default 'bottom)
   dotspacemacs-helm-position 'bottom
   ;; If non nil the paste micro-state is enabled. When enabled pressing `p`
   ;; several times cycle between the kill ring content. (default nil)
   dotspacemacs-enable-paste-micro-state nil
   ;; Which-key delay in seconds. The which-key buffer is the popup listing
   ;; the commands bound to the current keystroke sequence. (default 0.4)
   dotspacemacs-which-key-delay 0.4
   ;; Which-key frame position. Possible values are `right', `bottom' and
   ;; `right-then-bottom'. right-then-bottom tries to display the frame to the
   ;; right; if there is insufficient space it displays it at the bottom.
   ;; (default 'bottom)
   dotspacemacs-which-key-position 'bottom
   ;; If non nil a progress bar is displayed when spacemacs is loading. This
   ;; may increase the boot time on some systems and emacs builds, set it to
   ;; nil to boost the loading time. (default t)
   dotspacemacs-loading-progress-bar t
   ;; If non nil the frame is fullscreen when Emacs starts up. (default nil)
   ;; (Emacs 24.4+ only)
   dotspacemacs-fullscreen-at-startup nil
   ;; If non nil `spacemacs/toggle-fullscreen' will not use native fullscreen.
   ;; Use to disable fullscreen animations in OSX. (default nil)
   dotspacemacs-fullscreen-use-non-native nil
   ;; If non nil the frame is maximized when Emacs starts up.
   ;; Takes effect only if `dotspacemacs-fullscreen-at-startup' is nil.
   ;; (default nil) (Emacs 24.4+ only)
   dotspacemacs-maximized-at-startup nil
   ;; A value from the range (0..100), in increasing opacity, which describes
   ;; the transparency level of a frame when it's active or selected.
   ;; Transparency can be toggled through `toggle-transparency'. (default 90)
   dotspacemacs-active-transparency 90
   ;; A value from the range (0..100), in increasing opacity, which describes
   ;; the transparency level of a frame when it's inactive or deselected.
   ;; Transparency can be toggled through `toggle-transparency'. (default 90)
   dotspacemacs-inactive-transparency 90
   ;; If non nil unicode symbols are displayed in the mode line. (default t)
   dotspacemacs-mode-line-unicode-symbols nil
   ;; If non nil smooth scrolling (native-scrolling) is enabled. Smooth
   ;; scrolling overrides the default behavior of Emacs which recenters the
   ;; point when it reaches the top or bottom of the screen. (default t)
   dotspacemacs-smooth-scrolling t
   ;; If non nil line numbers are turned on in all `prog-mode' and `text-mode'
   ;; derivatives. If set to `relative', also turns on relative line numbers.
   ;; (default nil)
   dotspacemacs-line-numbers t
   ;; If non-nil smartparens-strict-mode will be enabled in programming modes.
   ;; (default nil)
   dotspacemacs-smartparens-strict-mode nil
   ;; Select a scope to highlight delimiters. Possible values are `any',
   ;; `current', `all' or `nil'. Default is `all' (highlight any scope and
   ;; emphasis the current one). (default 'all)
   dotspacemacs-highlight-delimiters 'all
   ;; If non nil advises quit functions to keep server open when quitting.
   ;; (default nil)
   dotspacemacs-persistent-server nil
   ;; List of search tool executable names. Spacemacs uses the first installed
   ;; tool of the list. Supported tools are `ag', `pt', `ack' and `grep'.
   ;; (default '("ag" "pt" "ack" "grep"))
   dotspacemacs-search-tools '("ag" "pt" "ack" "grep")
   ;; The default package repository used if no explicit repository has been
   ;; specified with an installed package.
   ;; Not used for now. (default nil)
   dotspacemacs-default-package-repository nil
   ;; Delete whitespace while saving buffer. Possible values are `all'
   ;; to aggressively delete empty line and long sequences of whitespace,
   ;; `trailing' to delete only the whitespace at end of lines, `changed'to
   ;; delete only whitespace for changed lines or `nil' to disable cleanup.
   ;; (default nil)
   dotspacemacs-whitespace-cleanup 'trailing
   ))

(defun dotspacemacs/user-init ()
  (setq-default git-enable-magit-svn-plugin t)
  (setq spacemacs-banner-directory "~/Google Drive/_spacemacs/banners/")
  ;; setup tramp
  (setq tramp-ssh-controlmaster-options
        "-o ControlMaster=auto -o ControlPath='tramp.%%C' -o ControlPersist=no")
  (setq tramp-default-method "ssh")

  ;;set up exec-path-from-shell
  ;;(when (memq window-system '(mac ns))
  ;;  (exec-path-from-shell-initialize))

  ;; default line spacing
  (setq-default line-spacing 0.1)
  (setq-default line-height 1.1)

  (defvar ao/v-dired-omit t
    "If dired-omit-mode enabled by default. Don't setq me.")

  (defun ao/dired-omit-switch ()
    "This function is a small enhancement for `dired-omit-mode', which will
   \"remember\" omit state across Dired buffers."
    (interactive)
    (if (eq ao/v-dired-omit t)
        (setq ao/v-dired-omit nil)
      (setq ao/v-dired-omit t))
    (ao/dired-omit-caller)
    (when (equal major-mode 'dired-mode)
      (revert-buffer)))

  (defun ao/dired-omit-caller ()
    (if ao/v-dired-omit
        (setq dired-omit-mode t)
      (setq dired-omit-mode nil)))

  (defun ao/dired-back-to-top()
    "Move to the first file."
    (interactive)
    (beginning-of-buffer)
    (dired-next-line 2))

  (defun ao/dired-jump-to-bottom()
    "Move to last file."
    (interactive)
    (end-of-buffer)
    (dired-next-line -1))

  "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 ()
  ;;enable magic-latex-buffer
  (require 'magic-latex-buffer)
  (add-hook 'latex-mode-hook 'magic-latex-buffer)
  (add-hook 'Latex-mode-hook 'magic-latex-buffer)

  (require 'spaceline-config)
  (spaceline-spacemacs-theme)

  ;;(setq spaceline-window-numbers-unicode t)
  ;;(setq spaceline-workspace-numbers-unicode t)

  ;; Note: The Hiragino Sans GB is bundled with MacOS X.
  ;; If you are not using MacOS X, you should change it to another Chinese font name.
  (spacemacs//set-monospaced-font   "InconsolataGo" "Hiragino Sans GB" 18 14)

  ;; Essential settings.
  (setq inhibit-splash-screen t
        inhibit-startup-message t
        inhibit-startup-echo-area-message t)
  (add-hook 'org-mode-hook 'visual-line-mode)
  (global-git-commit-mode t)
  (global-company-mode)
  (delete-selection-mode 1) ;; delete the selected region when entering text
  (menu-bar-mode -1)
  (tool-bar-mode -1)
  (when (boundp 'scroll-bar-mode)
    (scroll-bar-mode -1))
  (setq visual-line-fringe-indicators '(left-curly-arrow right-curly-arrow))
  ;; add golden ratio mode
  ;;(require 'golden-ratio)
  ;;(golden-ratio-mode 1)
  (global-hungry-delete-mode)
  ;;(setq-default left-fringe-width nil)
  ;; (setq-default indent-tabs-mode nil)
  (eval-after-load "vc" '(setq vc-handled-backends nil))
  (setq vc-follow-symlinks t)
  (setq large-file-warning-threshold nil)
  (setq split-width-threshold nil)
  (put 'narrow-to-region 'disabled nil)
  (add-hook 'web-mode-hook 'rainbow-mode)  ;; hook rainbow-mode to the html mode as default

  ;;set up anzu
  (global-anzu-mode +1)
  (setq anzu-cons-mode-line-p nil) ;; avoid anzu info showing twice on spaceline
  (set-face-attribute 'anzu-mode-line nil
                      :foreground "maroon" :weight 'bold)

  (custom-set-variables
   '(anzu-mode-lighter "")
   '(anzu-deactivate-region t)
   '(anzu-search-threshold 1000)
   '(anzu-replace-threshold 50)
   '(anzu-replace-to-string-separator " => "))

  (global-set-key [remap query-replace] 'anzu-query-replace)
  (global-set-key [remap query-replace-regexp] 'anzu-query-replace-regexp)

  ;; (global-linum-mode t)
  (setq linum-format "%2d ")

  (defun ask-before-closing ()
    "Ask whether or not to close, and then close if y was pressed"
    (interactive)
    (if (y-or-n-p (format "Sure you want to exit Emacs, Kevin? "))
        (if (< emacs-major-version 24)
            (save-buffers-kill-terminal)
          (save-buffers-kill-emacs))
      (message "Kevin has canceled exiting Emacs.")))

  (when window-system
    (global-set-key (kbd "C-x C-c") 'ask-before-closing))

  (add-to-list 'default-frame-alist '(height . 57))
  (add-to-list 'default-frame-alist '(width . 116))
  (setq TeX-view-program-selection '((output-pdf "PDF Viewer")))
  (setq TeX-view-program-list
        '(("PDF Viewer" "/Applications/Skim.app/Contents/SharedSupport/displayline -b %n %o %b")))

  ;;helm for files setup, look for files anywhere!
  (use-package helm
    :ensure t
    :init
    (progn
      (require 'helm-config)
      ;; limit max number of matches displayed for speed
      (setq helm-candidate-number-limit 6)
      ;; ignore boring files like .o and .a
      (setq helm-ff-skip-boring-files t)
      ;; replace locate with spotlight on Mac
      (setq helm-locate-command "mdfind -name %s %s"))
    :bind (("C-x f" . helm-for-files)))

  ;;pandoc setting
  (custom-set-variables
   '(markdown-command "~/anaconda/bin/pandoc"))
  (add-hook 'markdown-mode-hook 'pandoc-mode)
  (add-hook 'pandoc-mode-hook 'pandoc-load-default-settings)

  ;;neotree setting
  (global-set-key [f8] 'neotree-toggle)
  (setq neo-smart-open t)
  (setq neo-theme 'ascii)
  (setq neo-create-file-auto-open t)

  ;;git gutter setting
  ;;(setq git-gutter-fr+-side 'left-fringe)

  (setq-default left-fringe-width  12)
  (setq-default right-fringe-width 12)

  ;;ace window keybinding
  (global-set-key (kbd "M-p") 'ace-window)
  (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))

  ;;set up org mode for todo

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; org-mode agenda more options                                                ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;; set key for agenda
  (global-set-key (kbd "C-c a") 'org-agenda)

  ;;file to save todo items
  (setq org-agenda-files '("~/todo.org"))

  ;;set priority range from A to C with default A
  (setq org-highest-priority ?A)
  (setq org-lowest-priority ?C)
  (setq org-default-priority ?A)

  ;;set colours for priorities
  (setq org-priority-faces '((?A . (:foreground "#F0DFAF" :weight bold))
                             (?B . (:foreground "LightSteelBlue"))
                             (?C . (:foreground "OliveDrab"))))


  ;;capture todo items using C-c c t
  (define-key global-map (kbd "C-c c") 'org-capture)
  (setq org-capture-templates
        '(("t" "todo" entry (file+headline "~/todo.org" "Tasks")
           "* TODO [#A] %?\nDEADLINE: %(org-insert-time-stamp (org-read-date nil t \"+0d\"))\n")))

  ;;open agenda in current window
  (setq org-agenda-window-setup (quote current-window))
  ;;warn me of any deadlines in next 7 days
  (setq org-deadline-warning-days 7)
  ;;show me tasks scheduled or due in next fortnight
  (setq org-agenda-span (quote fortnight))
  ;;don't show tasks as scheduled if they are already shown as a deadline
  (setq org-agenda-skip-scheduled-if-deadline-is-shown t)
  ;;don't give awarning colour to tasks with impending deadlines
  ;;if they are scheduled to be done
  (setq org-agenda-skip-deadline-prewarning-if-scheduled (quote pre-scheduled))
  ;;don't show tasks that are scheduled or have deadlines in the
  ;;normal todo list
  (setq org-agenda-todo-ignore-deadlines (quote all))
  (setq org-agenda-todo-ignore-scheduled (quote all))
  ;;sort tasks in order of when they are due and then by priority
  (setq org-agenda-sorting-strategy
        (quote
         ((agenda deadline-up priority-down)
          (todo priority-down category-keep)
          (tags priority-down category-keep)
          (search category-keep))))

  ;;set up kbd for reveal-in-osx-finder
  (global-set-key (kbd "C-c z") 'reveal-in-osx-finder)

  ;;set up fly-check to ignore the E501 error
  (setq-default flycheck-flake8-maximum-line-length 160)

  (autopair-global-mode t) ;; enable autopair in all buffers
  ;;(ac-config-default)

  ;;(column-number-mode)

  ;; settings for show-paren-mode
  (show-paren-mode t)
  (setq show-paren-delay 0)
  (setq show-paren-style 'parenthesis)
  (set-face-background 'show-paren-match (face-background 'default))
  (set-face-foreground 'show-paren-match "maroon")
  (set-face-attribute 'show-paren-match nil
                      :weight 'ultra-bold
                      :underline nil
                      :overline nil)

  ;; setting an undo-tree mode to go back in point - amazing
  (global-undo-tree-mode)
  (global-set-key (kbd "M-/") 'undo-tree-visualize)

  ;; (setq-default 'cursor-type 'hbar) ;; change cursor type

  ;; setting transparency
  ;;(global-set-key (kbd "C-M-)") 'transparency-increase)
  ;;(global-set-key (kbd "C-M-(") 'transparency-decrease)

  ;; kbd for multiple cursors
  (global-set-key (kbd "C->") 'mc/mark-next-like-this)
  (global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
  (global-set-key (kbd "C-c C->") 'mc/mark-all-like-this)

  ;; kbd for deletion of the current line
  (global-set-key (kbd "M-9") 'kill-whole-line)

  ;; auto evaluate buffer
  (global-auto-revert-mode t)

  ;; powerline separators
  ;; (defun cycle-powerline-separators (&optional reverse)
  ;;   "Set Powerline separators in turn.  If REVERSE is not nil, go backwards."
  ;;   (interactive)
  ;;   (let* ((fn (if reverse 'reverse 'identity))
  ;;          (separators (funcall fn '("arrow" "arrow-fade" "slant"
  ;;                                    "chamfer" "wave" "brace" "roundstub" "zigzag"
  ;;                                    "butt" "rounded" "contour" "curve")))
  ;;          (found nil))
  ;;     (while (not found)
  ;;       (progn (setq separators (append (cdr separators) (list (car separators))))
  ;;              (when (string= (car separators) powerline-default-separator)
  ;;                (progn (setq powerline-default-separator (cadr separators))
  ;;                       (setq found t)
  ;;                       (redraw-display)))))))

  ;; set up browser in emacs: http://beatofthegeek.com/2014/02/my-setup-for-using-emacs-as-web-browser.html
  ;;(setq browse-url-browser-function 'w3m-goto-url-new-session)  ;;comment out this line to enable within emacs browsing
  (setq w3m-user-agent "Mozilla/5.0 (Linux; U; Android 2.3.3; zh-tw; HTC_Pyramid Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.")
  ;; awesome wikipedia search
  (defun wikipedia-search (search-term)
    "Search for SEARCH-TERM on wikipedia"
    (interactive
     (let ((term (if mark-active
                     (buffer-substring (region-beginning) (region-end))
                   (word-at-point))))
       (list
        (read-string
         (format "Wikipedia (%s):" term) nil nil term)))
     )
    (browse-url
     (concat
      "http://en.m.wikipedia.org/w/index.php?search="
      search-term
      ))
    )

  ;;when I want to enter the web address all by hand
  (defun open-a-website (site)
    "Opens site in new w3m session with 'http://' appended"
    (interactive
     (list (read-string "Enter website address: http://" nil nil "scholar.google.com/citations?user=VwQmUFQAAAAJ&hl=en" )))
    (browse-url
     (concat "http://" site)))

  ;; turn off sRGB color
  (setq ns-use-srgb-colorspace nil)

  ;;set up flycheck for proselint
  (require 'flycheck)
  (flycheck-define-checker proselint
    "A linter for prose."
    :command ("proselint" source-inplace)
    :error-patterns
    ((warning line-start (file-name) ":" line ":" column ": "
              (id (one-or-more (not (any " "))))
              (message (one-or-more not-newline)
                       (zero-or-more "\n" (any " ") (one-or-more not-newline)))
              line-end))
    :modes (text-mode markdown-mode gfm-mode org-mode))

  (add-to-list 'flycheck-checkers 'proselint)
  (add-hook 'markdown-mode-hook #'flycheck-mode)
  (add-hook 'gfm-mode-hook #'flycheck-mode)
  (add-hook 'text-mode-hook #'flycheck-mode)
  (add-hook 'org-mode-hook #'flycheck-mode)

  ;; setting for oxtwbs
  (setq org-publish-project-alist
        '(("org-notes"
           :base-directory "~/org/"
           :publishing-directory "~/public_html/"
           :publishing-function org-twbs-publish-to-html
           :with-sub-superscript nil
           )))

  (defun my-org-publish-buffer ()
    (interactive)
    (save-buffer)
    (save-excursion (org-publish-current-file))
    (let* ((proj (org-publish-get-project-from-filename buffer-file-name))
           (proj-plist (cdr proj))
           (rel (file-relative-name buffer-file-name
                                    (plist-get proj-plist :base-directory)))
           (dest (plist-get proj-plist :publishing-directory)))
      (browse-url (concat "file://"
                          (file-name-as-directory (expand-file-name dest))
                          (file-name-sans-extension rel)
                          ".html"))))

  ;; org mode stuff
  (require 'org-ref)
  (require 'org-ref-pdf)
  (require 'org-ref-url-utils)
  (require 'helm-bibtex)
  (require 'dash)
  (require 'hydra)
  (require 'key-chord)
  (require 'parsebib)
  (require 'async)

  (add-to-list 'org-latex-default-packages-alist '("" "natbib" "") t)
  (add-to-list 'org-latex-default-packages-alist
               '("linktocpage,pdfstartview=FitH,colorlinks,
  linkcolor=blue,anchorcolor=blue,
  citecolor=blue,filecolor=blue,menucolor=blue,urlcolor=blue"
                 "hyperref" nil)
               t)

  (setq bibtex-autokey-year-length 4
        bibtex-autokey-name-year-separator "-"
        bibtex-autokey-year-title-separator "-"
        bibtex-autokey-titleword-separator "-"
        bibtex-autokey-titlewords 2
        bibtex-autokey-titlewords-stretch 1
        bibtex-autokey-titleword-length 5)

  (setq org-latex-default-packages-alist
        (-remove-item
         '("" "hyperref" nil)
         org-latex-default-packages-alist))

  (setq bibtex-completion-bibliography '("~/Google Drive/bibliography/references.bib"))
  (setq reftex-default-bibliography
        '("~/Google Drive/bibliography/references.bib"))

  (setq reftex-bibpath-environment-variables
        '("~/Google Drive/bibliography/"))

  (setq reftex-default-bibliography '("~/Google Drive/bibliography/references.bib"))
  (setq reftex-bibliography-commands '("bibliography" "nobibliography" "addbibresource"))

  (setq reftex-default-bibliography
        (quote
         ("user.bib" "local.bib" "main.bib")))

  (add-hook 'LaTeX-mode-hook 'turn-on-reftex)   ; with AUCTeX LaTeX mode
  (autoload 'reftex-mode     "reftex" "RefTeX Minor Mode" t)
  (autoload 'turn-on-reftex  "reftex" "RefTeX Minor Mode" nil)
  (autoload 'reftex-citation "reftex-cite" "Make citation" nil)
  (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)
  (add-hook 'latex-mode-hook 'turn-on-reftex)   ; with Emacs latex mode

  ;; Make RefTeX faster
  (setq reftex-enable-partial-scans t)
  (setq reftex-save-parse-info t)
  (setq reftex-use-multiple-selection-buffers t)
  (setq reftex-plug-into-AUCTeX t)

  ;; Make RefTeX work with Org-Mode
  ;; use 'C-c (' instead of 'C-c [' because the latter is already
  ;; defined in orgmode to the add-to-agenda command.
  (defun org-mode-reftex-setup ()
    (load-library "reftex")
    (and (buffer-file-name)
         (file-exists-p (buffer-file-name))
         (reftex-parse-all))
    (define-key org-mode-map (kbd "C-c (") 'reftex-citation))

  (add-hook 'org-mode-hook 'org-mode-reftex-setup)

  (setq org-latex-pdf-process
      '("pdflatex -interaction nonstopmode -output-directory %o %f"
        "bibtex %b"
        "pdflatex -interaction nonstopmode -output-directory %o %f"
        "pdflatex -interaction nonstopmode -output-directory %o %f"))

  ;; RefTeX formats for biblatex (not natbib)
  (setq reftex-cite-format
        '(
          (?\C-m . "\\cite[]{%l}")
          (?t . "\\textcite{%l}")
          (?a . "\\autocite[]{%l}")
          (?p . "\\parencite{%l}")
          (?f . "\\footcite[][]{%l}")
          (?F . "\\fullcite[]{%l}")
          (?x . "[]{%l}")
          (?X . "{%l}")
          ))

  (setq font-latex-match-reference-keywords
        '(("cite" "[{")
          ("cites" "[{}]")
          ("autocite" "[{")
          ("footcite" "[{")
          ("footcites" "[{")
          ("parencite" "[{")
          ("textcite" "[{")
          ("fullcite" "[{")
          ("citetitle" "[{")
          ("citetitles" "[{")
          ("headlessfullcite" "[{")))

  (setq reftex-cite-prompt-optional-args nil)
  (setq reftex-cite-cleanup-optional-args t)

  ;;Publishing and task management with Org-mode

  ;;Display preferences

  ;;I like to see an outline of pretty bullets instead of a list of asterisks.

  (add-hook 'org-mode-hook
            (lambda ()
              (org-bullets-mode t)))

  ;; I like seeing a little downward-pointing arrow instead of the usual ellipsis
  ;; (=...=) that org displays when there's stuff under a header.

  ;;(setq org-ellipsis "⤵")

  ;;Use syntax highlighting in source blocks while editing.

  (setq org-src-fontify-natively t)

  ;;Make TAB act as if it were issued in a buffer of the language's major mode.

  (setq org-src-tab-acts-natively t)

  ;;When editing a code snippet, use the current window rather than popping open a new one (which shows the same information).

  (setq org-src-window-setup 'current-window)

  ;;(setq bibtex-completion-pdf-open-function
  ;;      (lambda (fpath)
  ;;        (call-process "open" nil 0 nil "-a" "/Applications/Skim.app" fpath)))

  (setf org-todo-keyword-faces '(("PLANED" . (:foreground "white" :background "#FF8598" :bold t :weight bold))
                                 ("TODO" . (:foreground "white" :background "#AEAEAE"  :bold t :weight bold))
                                 ("STARTED" . (:foreground "white" :background "#01B0F0" :bold t :weight bold))
                                 ("DONE" . (:foreground "black" :background "#AEEE00" :bold t :weight bold))))
  (setq org-bullets-bullet-list '("☰" "☷" "✿" "✸"))

  ;; OSX dictionary
  ;; Support Chinese word
  ;; (setq osx-dictionary-use-chinese-text-segmentation t)

  ;; Choose explicitly a dictionary for searching (use the first available
  ;; dictionary in Dictionary.app if not set)
  ;; (setq osx-dictionary-dictionary-choice "Apple")
  ;; To search in more than one dictionaries
  (setq osx-dictionary-dictionary-choice (list "English" "English Thesaurus"))
  ;; To search in all dictionaries
  ;; (setq osx-dictionary-dictionary-choice (osx-dictionary-get-all-dictionaries))

  ;; Key bindings
  (global-set-key (kbd "C-c d") 'osx-dictionary-search-pointer)
  (global-set-key (kbd "C-c i") 'osx-dictionary-search-input)

  ;; Work with popwin-el (https://github.com/m2ym/popwin-el)
  ;; (push "*osx-dictionary*" popwin:special-display-config)

  ;; disable popwin-mode in an active Helm session It should be disabled
  ;; otherwise it will conflict with other window opened by Helm persistent
  ;; action, such as *Help* window.
  ;;(push '("^\*helm.+\*$" :regexp t) popwin:special-display-config)
  ;;(add-hook 'helm-after-initialize-hook (lambda ()
  ;;                                        (popwin:display-buffer helm-buffer t)
  ;;                                        (popwin-mode -1)))

  ;;  Restore popwin-mode after a Helm session finishes.
  ;;(add-hook 'helm-cleanup-hook (lambda () (popwin-mode 1)))
  (shackle-mode 1)
  (setq shackle-rules '(("\\`\\*helm.*?\\*\\'" :regexp t :align t :ratio 0.4)))
  (push '("*osx-dictionary*" :width 0.4 :position right) popwin:special-display-config)

  ;; youdao dictionary
  ;; Enable Cache
  ;;(setq url-automatic-caching t)

  ;; Example Key binding
  (global-set-key (kbd "C-c Y") 'youdao-dictionary-search-at-point+)
  (global-set-key (kbd "C-c y") 'youdao-dictionary-search)

  ;; Integrate with popwin-el (https://github.com/m2ym/popwin-el)
  (push '("*Youdao Dictionary*" :width 0.4 :position right) popwin:special-display-config)

  ;; Set file path for saving search history
  (setq youdao-dictionary-search-history-file "~/.emacs.d/.youdao")

  ;; Enable Chinese word segmentation support (支持中文分词)
  (setq youdao-dictionary-use-chinese-word-segmentation t)

  ;; define google scholar as the default bibtex search for "gscholar-bibtex"
  (setq gscholar-bibtex-default-source "Google Scholar")
  (setq gscholar-bibtex-database-file "~/Google Drive/bibliography/references.bib")

  ;;(require 'powerline)
  ;; set up diminish mode line replace verbose text with unicode icons
  (when (require 'diminish nil 'noerror)
    (require 'diminish)
    ;; Hide jiggle-mode lighter from mode line
    (diminish 'jiggle-mode)
    ;; Replace abbrev-mode lighter with "Abv"
    (diminish 'abbrev-mode "Abv")
    (diminish 'projectile-mode "")
    (diminish 'holy-mode)
    (diminish 'company-mode "")
    (diminish 'autopair-mode "")
    (diminish 'which-key-mode "")
    (diminish 'reftex-mode "")
    (diminish 'visual-line-mode "")
    (diminish 'hungry-delete-mode "")
    (diminish 'golden-ratio-mode)
    (diminish 'anzu-mode "")
    (diminish 'isearch-mode "")
    (diminish 'magic-latex-buffer "")
    (diminish 'iimage-mode "")
    ;;(diminish 'flycheck-mode "")
    ;;(diminish 'python-mode "\f156")
    (eval-after-load "yasnippet"
      '(diminish 'yas-minor-mode "")))

  ;; add fancy git icon
  (defadvice vc-mode-line (after strip-backend () activate)
    (when (stringp vc-mode)
      (let ((gitlogo (replace-regexp-in-string "^ Git." "  " vc-mode)))
        (setq vc-mode gitlogo))))

  ;;set scroll type, C+l will recenter the buffer.
  (setq scroll-step            1
        scroll-conservatively  10000)


  "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."
  )

;; Do not write anything past this comment. This is where Emacs will
;; auto-generate custom variable definitions.
(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.
 '(custom-safe-themes
   (quote
    ("fa2b58bb98b62c3b8cf3b6f02f058ef7827a8e497125de0254f56e373abee088" "77c65d672b375c1e07383a9a22c9f9fc1dec34c8774fe8e5b21e76dca06d3b09" "a2e7b508533d46b701ad3b055e7c708323fb110b6676a8be458a758dd8f24e27" "71ecffba18621354a1be303687f33b84788e13f40141580fa81e7840752d31bf" "a27c00821ccfd5a78b01e4f35dc056706dd9ede09a8b90c6955ae6a390eb1c1e" "c74e83f8aa4c78a121b52146eadb792c9facc5b1f02c917e3dbb454fca931223" "b9e9ba5aeedcc5ba8be99f1cc9301f6679912910ff92fdf7980929c2fc83ab4d" "84d2f9eeb3f82d619ca4bfffe5f157282f4779732f48a5ac1484d94d5ff5b279" "3c83b3676d796422704082049fc38b6966bcad960f896669dfc21a7a37a748fa" default)))
 '(markdown-command "~/anaconda/bin/pandoc"))
(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.
 '(company-tooltip-common ((t (:inherit company-tooltip :weight bold :underline nil))))
 '(company-tooltip-common-selection ((t (:inherit company-tooltip-selection :weight bold :underline nil)))))

@NJBS
Copy link
Contributor

NJBS commented Sep 1, 2016

Oh my 😮 , and I thought my dotfile was messy 😄 .

Because of the complexity of your dotfile catching the cause of the error by eye is probably not feasible in a short amount of time.

Can you instead M-x toggle-debug-on-error then try reloading your dotfile using M-m f e R? You should get dropped into a backtrace at the first error it encounters when it tries to test your dotfile.

What's strange is that you mention you only encounter the error on startup from time to time. You should try to figure out exactly what actions you are taking such that you can consistently reproduce this error, from there --debug-init should reliably drop you into backtrace with the call stack when it encounters the error on startup.

P.S. Using a paste service like https://gist.github.com/ for huge snippets of code keeps the issue from getting cluttered 😄 .

@yilihong
Copy link
Author

yilihong commented Sep 1, 2016

@NJBS yeah... I know... this is very messy. I am wondering if there is a way I can write the user config part in an org file and import here. I do intend to re-organize all the lisp codes.

Again, thanks for your suggestions. Now it is back to normal, no error when I --debug-init. It happens sporadically when I change some lisp codes - and back to normal when I quit and re-open emacs! Mind-boggling...

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Feb 29, 2020
@lebensterben lebensterben removed the stale marked as a stale issue/pr (usually by a bot) label Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants