Skip to content

Instantly share code, notes, and snippets.

@tlkahn
Created January 27, 2020 08:27
Show Gist options
  • Save tlkahn/3e0b94a811b032296e3162b5c83ee027 to your computer and use it in GitHub Desktop.
Save tlkahn/3e0b94a811b032296e3162b5c83ee027 to your computer and use it in GitHub Desktop.
(add-to-list 'load-path "~/.emacs.d/site-lisp/go-mode.el/")
(add-to-list 'load-path "~/.emacs.d/site-lisp/ox-ipynb/")
(autoload 'go-mode "go-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))
(let ((default-directory "/usr/local/share/emacs/site-lisp"))
(normal-top-level-add-subdirs-to-load-path))
(setq tramp-default-method "ssh")
(global-hl-line-mode 1)
(menu-bar-mode -1)
(if (display-graphic-p)
(tool-bar-mode -1))
(require 'package)
(ido-mode t)
(setq ido-enable-flex-matching t)
(setq ido-use-filename-at-point nil)
(setq ido-use-virtual-buffers t)
(setq recentf-save-file (concat user-emacs-directory ".recentf"))
(require 'recentf)
(recentf-mode 1)
(prettify-symbols-mode 1)
;; (defun my-add-pretty-lambda ()
;; "make some word or string show as pretty Unicode symbols"
;; (setq prettify-symbols-alist
;; '(
;; ("lambda" . 955) λ
;; ("fn", . 955)
;; ("->" . 8594) →
;; ("=>" . 8658) ⇒
;; ("map" . 8614) ↦
;; ))
;; )
;; (add-hook 'clojure-mode-hook 'my-add-pretty-lambda)
(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)
;; package config
(setq package-archives '(("gnu" . "http://elpa.emacs-china.org/gnu/")
("melpa" . "http://elpa.emacs-china.org/melpa/")
;; ("melpa" . "http://melpa.milkbox.net/packages/")
("org" . "http://orgmode.org/elpa/")
))
(package-initialize)
;; (package-refresh-contents)
(set-frame-parameter (selected-frame) 'alpha '(90 . 90))
;; some aux functions
(defun comment-or-uncomment-region-or-line ()
"Comments or uncomments the region or the current line if there's no active region."
(interactive)
(let (beg end)
(if (region-active-p)
(setq beg (region-beginning) end (region-end))
(setq beg (line-beginning-position) end (line-end-position)))
(comment-or-uncomment-region beg end)))
(defun select-current-line ()
"Select the current line"
(interactive)
(beginning-of-line) ; move to end of line
(set-mark (line-end-position)))
(defun my-kill-ring-save ()
(interactive)
(if (not (use-region-p))
(select-current-line))
(kill-ring-save (region-beginning) (region-end)))
;; use 2 spaces for tabs
(defun die-tabs ()
(interactive)
(set-variable 'tab-width 2)
(mark-whole-buffer)
(untabify (region-beginning) (region-end))
(keyboard-quit))
;; fix weird os x kill error
(defun ns-get-pasteboard ()
"Returns the value of the pasteboard, or nil for unsupported formats."
(condition-case nil
(ns-get-selection-internal 'CLIPBOARD)
(quit nil)))
(setq electric-indent-mode nil)
(global-set-key (kbd "M-/") 'comment-or-uncomment-region-or-line)
(global-set-key (kbd "s-1") 'shell-command)
(defun open-in-vim()
(interactive)
(shell-command (concat "osascript -e 'tell application \"Terminal\" to activate' -e 'tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down' -e 'tell application \"Terminal\" to do script \"vim " (buffer-file-name) "\" in selected tab of the front window'")))
(global-set-key (kbd "M-g v") 'open-in-vim)
(global-set-key (kbd "s-z") 'undo-tree-undo)
(add-to-list 'load-path "~/.emacs.d/evil")
(require 'evil)
(add-to-list 'load-path "~/.emacs.d/site-lisp")
(add-to-list 'load-path "~/.emacs.d/site-lisp/dash.el")
(add-to-list 'load-path "~/.emacs.d/site-lisp/f.el")
(add-to-list 'load-path "~/.emacs.d/site-lisp/s.el")
(defun toggle-evil-mode ()
(interactive)
(if (eq evil-mode t)
(evil-mode 0)
(evil-mode t)))
(global-set-key (kbd "s-i") 'toggle-evil-mode)
(global-unset-key (kbd "C-M-SPC"))
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "s-j") 'helm-M-x)
(global-set-key (kbd "s-x") 'kill-region)
(require 'expand-region)
(global-set-key (kbd "C-j") 'er/pand-region)
(setq make-backup-files nil)
;;(load "~/.emacs.d/org-mind-map/org-mind-map.el")
(require 'org)
(require 'ob-ipython)
(require 'ox-ipynb)
(require 'ob-mathematica)
;; don't prompt me to confirm everytime I want to evaluate a block
(setq org-confirm-babel-evaluate nil)
(setq org-display-inlineimages t)
;;; display/update images in the buffer after I evaluate
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images 'append)
(setq org-babel-python-command "python3")
(org-babel-do-load-languages
'org-babel-load-languages
'(
(emacs-lisp . t)
(ipython . t)
(python . t)
(js . t)
(ruby . t)
(C .t)
(shell .t)
(mathematica .t)
(clojure .t)
(R .t)
(ein . t)
;; other languages..
))
(setq shell-file-name "bash")
(setq shell-command-switch "-ic")
;; (add-to-list 'org-latex-minted-langs '(ipython "python"))
;; (add-to-list 'load-path
;; "~/.emacs.d/plugins/yasnippet")
;; (require 'yasnippet)
;; (yas-global-mode 0)
(add-to-list 'load-path "~/.emacs.d/site-lisp/writegood-mode")
(require 'writegood-mode)
(add-to-list 'load-path "~/.emacs.d/site-lisp/fountain-mode")
(require 'fountain-mode)
(setq org-src-fontify-natively t)
(load "auctex.el" nil t t)
(require 'ox)
(visual-line-mode t)
(add-hook 'org-mode-hook #'(lambda ()
;; make the lines in the buffer wrap around the edges of the screen.
;; to press C-c q or fill-paragraph ever again!
(visual-line-mode)
(org-indent-mode)))
(require 'ob-mathematica)
(require 'ob-clojure)
(setq package-check-signature nil)
(setq ispell-program-name "/usr/local/bin/aspell")
(global-set-key (kbd "s-/") 'comment-or-uncomment-region)
;; disable scroll bar in gui mode
(when (display-graphic-p)
()
(scroll-bar-mode -1))
(defun get-selected-text (start end)
(interactive "r")
(if (use-region-p)
(let ((regionp (buffer-substring start end)))
(message "%d" start)
(message "%d" end)
(message regionp))))
(defun universal-copy(start end)
"copy the whole line if no region selected, or copy the region"
(interactive "r")
(if (use-region-p)
(kill-ring-save start end)
(kill-ring-save (line-beginning-position) (line-end-position))))
(global-set-key (kbd "s-c") 'universal-copy)
;; socks proxy settings for emacs url package.
;; (setq socks-noproxy '("127.0.0.1"))
;; (setq socks-server '("Default server" "127.0.0.1" 1080 5))
;; (setq url-gateway-method 'socks)
;; (setq url-gateway-method 'native)
;; define default bibliography doc
(setq reftex-default-bibliography '("~/Dropbox/bibliography/references.bib"))
;; see org-ref for use of these variables
(setq org-ref-bibliography-notes "~/Dropbox/bibliography/notes.org"
org-ref-default-bibliography '("~/Dropbox/bibliography/references.bib")
org-ref-pdf-directory "~/Dropbox/bibliography/bibtex-pdfs/")
(setq bibtex-completion-bibliography "~/Dropbox/bibliography/references.bib"
bibtex-completion-library-path "~/Dropbox/bibliography/bibtex-pdfs"
bibtex-completion-notes-path "~/Dropbox/bibliography/helm-bibtex-notes")
;; open pdf with system pdf viewer (works on mac)
(setq bibtex-completion-pdf-open-function
(lambda (fpath)
(start-process "open" "*open*" "open" fpath)))
;; alternative
(setq bibtex-completion-pdf-open-function 'org-open-file)
(require 'org-ref)
(require 'ox-latex)
(unless (boundp 'org-latex-classes)
(setq org-latex-classes nil))
(add-to-list 'org-latex-classes
'("IEEEtran"
"\documentclass[10pt,journal]{IEEEtran}"
("\section{%s}" . "\section_{%s}")
("\subsection{%s}" . "\subsection_{%s}")
("\subsubsection{%s}" . "\subsubsection*{%s}")))
(require 'org-ref-citeproc)
(defun org-ref-open-bibtex-pdf ()
(interactive)
(save-excursion
(bibtex-beginning-of-entry)
(let* ((bibtex-expand-strings t)
(entry (bibtex-parse-entry t))
(key (reftex-get-bib-field "=key=" entry))
(pdf (org-ref-get-mendeley-filename key)))
(message "opening pdf %s" pdf)
(if (file-exists-p pdf)
(org-open-link-from-string (format "[[file:%s]]" pdf))
(ding)))))
(setq org-ref-pdf-directory "/Users/toeinriver/Dropbox/bibliography/bibtex-pdfs"
bibtex-completion-pdf-field "file"
org-ref-get-pdf-filename-function 'org-ref-get-zotero-pdf-filename)
(defun org-ref-get-zotero-pdf-filename (key)
"Return the pdf filename indicated by zotero file field.
Argument KEY is the bibtex key."
(let* ((results (org-ref-get-bibtex-key-and-file key))
(bibfile (cdr results))
entry)
(with-temp-buffer
(insert-file-contents bibfile)
(bibtex-set-dialect (parsebib-find-bibtex-dialect) t)
(bibtex-search-entry key nil 0)
(setq entry (bibtex-parse-entry))
(let ((e (org-ref-reftex-get-bib-field "file" entry)))
(if (> (length e) 4)
(let ((clean-field (replace-regexp-in-string "/+" "/" e)))
(let ((first-file (car (split-string clean-field ";" t))))
(concat org-ref-pdf-directory first-file)))
(message "PDF filename not found.")
)))))
;; Override this function.
(defun org-ref-open-bibtex-pdf ()
"Open pdf for a bibtex entry, if it exists.
assumes point is in
the entry of interest in the bibfile. but does not check that."
(interactive)
(save-excursion
(bibtex-beginning-of-entry)
(let* ((bibtex-expand-strings t)
(entry (bibtex-parse-entry t))
(key (reftex-get-bib-field "=key=" entry))
(pdf (org-ref-get-zotero-pdf-filename key)))
(message "%s" pdf )
(if (file-exists-p pdf)
(org-open-link-from-string (format "[[file:%s]]" pdf))
(ding)))))
(require 'guide-key)
(setq guide-key/guide-key-sequence '("C-x r"))
(setq guide-key/recursive-key-sequence-flag t)
(guide-key-mode 1) ; Enable guide-key-mode
(setq guide-key/idle-delay 0.1)
(defun guide-key/my-hook-function-for-org-mode ()
(guide-key/add-local-guide-key-sequence "C-c")
(guide-key/add-local-guide-key-sequence "C-c C-x")
(guide-key/add-local-highlight-command-regexp "org-"))
(add-hook 'org-mode-hook 'guide-key/my-hook-function-for-org-mode)
;; (require 'evil-surround)
;; (global-evil-surround-mode 1)
;; (global-set-key (kbd "TAB") 'hippie-expand)
(require 'expand-region)
(defun smart-tab ()
"This smart tab is minibuffer compliant: it acts as usual in
the minibuffer. Else, if mark is active, indents region. Else if
point is at the end of a symbol, expands it. Else indents the
current line."
(interactive)
(if (minibufferp)
(unless (minibuffer-complete)
(hippie-expand nil))
(if mark-active
(indent-region (region-beginning)
(region-end))
(if (looking-at "\\_>")
(hippie-expand nil)
(indent-for-tab-command)))))
(global-set-key (kbd "TAB") 'smart-tab)
(setq hippie-expand-try-functions-list
'(
try-expand-dabbrev
try-expand-dabbrev-from-kill
try-expand-dabbrev-all-buffers
try-expand-line
try-complete-file-name-partially
try-complete-file-name
try-complete-lisp-symbol
try-complete-lisp-symbol-partially
))
(setq org-latex-pdf-process '("latexmk -pdflatex='%latex -shell-escape -interaction nonstopmode' -pdf -output-directory=%o -f %f"))
(add-to-list 'org-latex-classes
'("acm"
"\\documentclass[]{hitec}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
(put 'upcase-region 'disabled nil)
(setq org-agenda-files '("~/Dropbox/orgfiles/i.org"))
(setq org-agenda-include-diary t)
(put 'erase-buffer 'disabled nil)
(show-paren-mode 1)
(setq cider-repl-pop-to-buffer-on-connect nil)
(require 'cider-eldoc)
;; (require 'ob-clojure)
(setq cider-lein-parameters "repl :headless :host localhost")
(put 'downcase-region 'disabled nil)
(require 'ggtags)
(add-hook 'c-mode-common-hook
(lambda ()
(when (derived-mode-p 'c-mode 'c++-mode 'java-mode 'asm-mode)
(ggtags-mode 1))))
(add-hook 'fountain-mode-hook
(lambda ()
(global-set-key (kbd "TAB") 'smart-tab)))
(define-key ggtags-mode-map (kbd "C-c g s") 'ggtags-find-other-symbol)
(define-key ggtags-mode-map (kbd "C-c g h") 'ggtags-view-tag-history)
(define-key ggtags-mode-map (kbd "C-c g r") 'ggtags-find-reference)
(define-key ggtags-mode-map (kbd "C-c g f") 'ggtags-find-file)
(define-key ggtags-mode-map (kbd "C-c g c") 'ggtags-create-tags)
(define-key ggtags-mode-map (kbd "C-c g u") 'ggtags-update-tags)
(define-key ggtags-mode-map (kbd "M-,") 'pop-tag-mark)
(setq
helm-gtags-ignore-case t
helm-gtags-auto-update t
helm-gtags-use-input-at-cursor t
helm-gtags-pulse-at-cursor t
helm-gtags-prefix-key "\C-cg"
helm-gtags-suggested-key-mapping t
)
(require 'helm-gtags)
;; Enable helm-gtags-mode
(add-hook 'dired-mode-hook 'helm-gtags-mode)
(add-hook 'eshell-mode-hook 'helm-gtags-mode)
(add-hook 'c-mode-hook 'helm-gtags-mode)
(add-hook 'c++-mode-hook 'helm-gtags-mode)
(add-hook 'asm-mode-hook 'helm-gtags-mode)
(define-key helm-gtags-mode-map (kbd "C-c g a") 'helm-gtags-tags-in-this-function)
(define-key helm-gtags-mode-map (kbd "C-j") 'helm-gtags-select)
(define-key helm-gtags-mode-map (kbd "M-.") 'helm-gtags-dwim)
(define-key helm-gtags-mode-map (kbd "M-,") 'helm-gtags-pop-stack)
(define-key helm-gtags-mode-map (kbd "C-c <") 'helm-gtags-previous-history)
(define-key helm-gtags-mode-map (kbd "C-c >") 'helm-gtags-next-history)
(fa-config-default)
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
(set-default 'semantic-case-fold t)
;;If your includes aren't located in default dirs e.g. /usr/include/ etc, then you have to do something like this:
;;(semantic-add-system-include "~/Software/deal.II/include/" 'c++-mode)
;;(semantic-add-system-include "/usr/local/boost_1_54_0/" 'c++-mode)
(require 'semantic/bovine/c)
(add-to-list 'semantic-lex-c-preprocessor-symbol-file
"/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h")
(require 'sr-speedbar)
(defalias 'speedbar 'sr-speedbar-toggle)
(setq speedbar-initial-expansion-list-name "quick buffers")
(require 'company)
(add-hook 'after-init-hook 'global-company-mode)
(setq company-backends (delete 'company-semantic company-backends))
(define-key c-mode-map [(tab)] 'company-complete)
(define-key c++-mode-map [(tab)] 'company-complete)
(add-to-list 'company-backends 'company-c-headers)
(load-theme 'leuven t)
(require 'cc-mode)
(require 'semantic)
(global-semanticdb-minor-mode 1)
(global-semantic-idle-scheduler-mode 1)
(semantic-mode 1)
(projectile-mode +1)
(setq
;; use gdb-many-windows by default
gdb-many-windows t
;; Non-nil means display source file containing the main routine at startup
gdb-show-main t
)
(setq org-latex-pdf-process
'("xelatex -interaction nonstopmode %f"
"xelatex -interaction nonstopmode %f")) ;; for multiple passes
(setq company-idle-delay nil)
(setq gofmt-command "goimports")
;; UPDATE: gofmt-before-save is more convenient then having a command
;; for running gofmt manually. In practice, you want to
;; gofmt/goimports every time you save anyways.
(add-hook 'before-save-hook 'gofmt-before-save)
(global-set-key (kbd "C-c M-n") 'company-complete)
(global-set-key (kbd "C-c C-n") 'company-complete)
(defun my-go-mode-hook ()
;; UPDATE: I commented the next line out because it isn't needed
;; with the gofmt-before-save hook above.
;; (local-set-key (kbd "C-c m") 'gofmt)
(local-set-key (kbd "M-.") 'godef-jump)
(set (make-local-variable 'company-backends) '(company-go)))
(add-hook 'go-mode-hook 'my-go-mode-hook)
(add-hook 'go-mode-hook 'go-eldoc-setup)
(add-hook 'go-mode-hook 'company-mode)
(setq-default indent-tabs-mode nil)
(setq default-tab-width 4)
;; Set to the location of your Org files on your local system
;; (setq org-directory "/Users/toeinriver/Dropbox/Apps/MobileOrg")
;; Set to the name of the file where new notes will be stored
;; (setq org-mobile-inbox-for-pull "/Users/toeinriver/Dropbox/Apps/MobileOrg/flagged.org")
;; Set to <your Dropbox root directory>/MobileOrg.
;; (setq org-mobile-directory "/Users/toeinriver/Dropbox/Apps/MobileOrg")
(defun org-summary-todo (n-done n-not-done)
"Switch entry to DONE when all subentries are done, to TODO otherwise."
(let (org-log-done org-log-states) ; turn off logging
(org-todo (if (= n-not-done 0) "DONE" "TODO"))))
(add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
(require 'ag)
(require 'helm-ag)
(global-set-key (kbd "s-F") 'ag)
(setq ag-highlight-search t)
(setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin"))
(setq exec-path (append exec-path '("/usr/local/bin")))
(setq org-babel-clojure-backend 'cider)
(require 'virtualenvwrapper)
(venv-initialize-interactive-shells) ;; if you want interactive shell support
;; (venv-initialize-eshell) ;; if you want eshell support
;; note that setting `venv-location` is not necessary if you
;; use the default location (`~/.virtualenvs`), or if the
;; the environment variable `WORKON_HOME` points to the right place
;; (setq venv-location "/path/to/your/virtualenvs/")
(require 'neotree)
(global-set-key [f8] 'neotree-toggle)
;; (setq explicit-shell-file-name "/bin/bash")
(let ((path (shell-command-to-string ". ~/.bash_profile; echo -n $PATH")))
(setenv "PATH" path)
(setq exec-path
(append
(split-string-and-unquote path ":")
exec-path)))
(push '(font . "ubuntu mono 11") default-frame-alist)
(setq org-startup-indented t)
(setq org-hide-leading-stars t)
(persp-mode t)
(defun hide-org-bullets ()
(font-lock-add-keywords
'org-mode `(("\\(?:^\\(?1:\\*+\\)[[:blank:]]\\)"
(0 (progn (compose-region
(match-beginning 1) (match-end 1)
(pcase (length (match-string 1))
(1 ?\u2219)
(2 ?\u2022)
(3 ?\u25c9)
(_ ?\u25CB)))
nil))))))
(blink-cursor-mode 0)
(setq ring-bell-function 'ignore)
(global-set-key (kbd "C-c h") 'helm-command-prefix)
(global-unset-key (kbd "C-x c"))
(defun my/goto-same-spot-in-other-buffer ()
"Go to the same location in the other buffer. Useful for when you have cloned indirect buffers"
(interactive)
(org-tree-to-indirect-buffer)
)
(global-set-key (kbd "<s-mouse-1>") 'my/goto-same-spot-in-other-buffer)
(global-set-key (kbd "s-m") 'my/goto-same-spot-in-other-buffer)
;; (global-set-key (kbd "<C-s-mouse-1>") 'my/jump-to-point-and-show)
;; (global-set-key (kbd "C-s-m") 'my/jump-to-point-and-show)
(add-to-list 'load-path "~/.emacs.d/site-lisp/helm-fzf")
(require 'helm-fzf)
(global-set-key (kbd "s-t") (lambda () (interactive)(helm-fzf default-directory)))
;; (add-hook 'LaTeX-mode-hook 'flyspell-mode)
;; (add-hook 'org-mode-hook 'flyspell-mode)
(setq org-indirect-buffer-display 'new-frame)
(setq tramp-default-method "ssh")
;; (require 'org-brain)
;; (use-package org-brain :ensure t
;; :init
;; (setq org-brain-path "~/Document/org")
;; ;; For Evil users
;; (with-eval-after-load 'evil
;; (evil-set-initial-state 'org-brain-visualize-mode 'emacs))
;; :config
;; (setq org-id-track-globally t)
;; (setq org-id-locations-file "~/.emacs.d/.org-id-locations")
;; (push '("b" "Brain" plain (function org-brain-goto-end)
;; "* %i%?" :empty-lines 1)
;; org-capture-templates)
;; (setq org-brain-visualize-default-choices 'all)
;; (setq org-brain-title-max-length 12))
(global-visual-line-mode t)
(setq markdown-command "/usr/local/bin/pandoc")
(require 'highlight-symbol)
(global-set-key [(f3)] 'highlight-symbol)
(global-set-key (kbd "s-g") 'highlight-symbol-next)
(global-set-key (kbd "s-G") 'highlight-symbol-prev)
(global-set-key (kbd "s-@") 'highlight-symbol-query-replace)
(setq inferior-lisp-program "/usr/local/bin/sbcl")
;; (setq slime-contribs '(slime-fancy helm-slime))
;; (require 'hippie-expand-slime)
;; (add-hook 'slime-mode-hook 'set-up-slime-hippie-expand)
;; (add-hook 'slime-repl-mode-hook 'set-up-slime-hippie-expand)
(global-set-key (kbd "s-<f3>") 'highlight-symbol-remove-all)
(setq python-shell-interpreter "python3")
(global-set-key (kbd "s-Z") 'undo-tree-redo)
(setq tramp-default-method "ssh")
(global-flycheck-mode)
(package-install 'exec-path-from-shell)
(exec-path-from-shell-initialize)
(linum-mode t)
(provide 'init)
;;; init.el ends here
(set-variable 'markdown-command "pandoc -s --mathjax")
(use-package evil-surround
:ensure t
:config
(global-evil-surround-mode 1))
(setq org-image-actual-width nil)
(setq org-src-fontify-natively t)
(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.
'(ob-ein-languages
(quote
(("ein" . python)
("ein-python" . python)
("ein-R" . R)
("ein-r" . R)
("ein-julia" . julia)
("ein-hy" . hy)
("ein-Cpp17" . C++))))
'(org-agenda-files
(quote
("~/Dropbox/read-notes/journals/journal-20191208.org" "~/Dropbox/orgfiles/i.org")))
'(org-directory "~/Dropbox/orgfiles")
'(package-selected-packages
(quote
(gist simple-call-tree call-graph google-translate el-get cask px yasnippet-classic-snippets slime helm-projectile wolfram-mode ein xkcd edit-server-htmlize edit-server posframe pyim multiple-cursors helm-describe-modes ox-pandoc ob-ipython org jupyter ox-epub writeroom-mode zenburn-theme yasnippet-snippets writegood-mode virtualenvwrapper use-package typescript-mode tramp-theme sr-speedbar solidity-flycheck solaire-mode smex smartparens sly request-deferred pyvenv pyenv-mode projectile persp-mode origami org-ref org-brain ob-async nimbus-theme neotree multi markdown-mode magit macrostep iedit hippie-expand-slime highlight-symbol hideshow-org helm-gtags helm-ag guide-key go-errcheck go-eldoc go ggtags function-args fountain-mode fold-dwim-org flymake-python-pyflakes expand-region exec-path-from-shell evil-surround dumb-jump company-solidity company-c-headers cider auctex alert ag))))
(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.
)
;; (require 'poetry)
(global-set-key (kbd "M-c") 'capitaLize-word)
(require 'paredit)
(paredit-mode 1)
(setq tramp-default-method "ssh")
(use-package company
:ensure t
:config
(progn
(add-hook 'after-init-hook 'global-company-mode)))
(require 'multiple-cursors)
(global-unset-key (kbd "M-<down-mouse-1>"))
(global-set-key (kbd "M-<mouse-1>") 'mc/add-cursor-on-click)
(global-set-key (kbd "s-d") 'mc/mark-next-like-this)
(global-set-key (kbd "s-D") 'mc/mark-previous-like-this)
(if (> emacs-major-version 25)
(require 'posframe)
nil)
(require 'pyim)
(require 'pyim-basedict) ; 拼音词库设置,五笔用户 *不需要* 此行设置
(pyim-basedict-enable) ; 拼音词库,五笔用户 *不需要* 此行设置
(setq default-input-method "pyim")
(global-set-key (kbd "C-\\") 'toggle-input-method)
(use-package pyim
:ensure nil
:demand t
:config
;; 激活 basedict 拼音词库,五笔用户请继续阅读 README
(use-package pyim-basedict
:ensure nil
:config (pyim-basedict-enable))
(setq default-input-method "pyim")
;; 我使用全拼
(setq pyim-default-scheme 'quanpin)
;; 设置 pyim 探针设置,这是 pyim 高级功能设置,可以实现 *无痛* 中英文切换 :-)
;; 我自己使用的中英文动态切换规则是:
;; 1. 光标只有在注释里面时,才可以输入中文。
;; 2. 光标前是汉字字符时,才能输入中文。
;; 3. 使用 M-j 快捷键,强制将光标前的拼音字符串转换为中文。
(setq-default pyim-english-input-switch-functions
'(pyim-probe-dynamic-english
pyim-probe-isearch-mode
pyim-probe-program-mode
pyim-probe-org-structure-template))
(setq-default pyim-punctuation-half-width-functions
'(pyim-probe-punctuation-line-beginning
pyim-probe-punctuation-after-punctuation))
;; 开启拼音搜索功能
(pyim-isearch-mode 1)
;; 使用 popup-el 来绘制选词框, 如果用 emacs26, 建议设置
;; 为 'posframe, 速度很快并且菜单不会变形,不过需要用户
;; 手动安装 posframe 包。
(setq pyim-page-tooltip 'posframe)
(defun my-converter (string)
;; (if (equal string "二呆")
;; "超级帅小伙"
;; string)
string
)
(setq pyim-magic-converter #'my-converter)
;; 选词框显示5个候选词
(setq pyim-page-length 5)
:bind
(("M-j" . pyim-convert-string-at-point) ;与 pyim-probe-dynamic-english 配合
("C-;" . pyim-delete-word-from-personal-buffer)))
(setq org-special-ctrl-a/e t)
(add-hook 'term-mode-hook (lambda()
(yas-minor-mode -1)
(setq yas-dont-activate t)))
(setq org-cycle-include-plain-lists 'integrate)
;; org-protocol setup
;; (setq server-socket-dir (format "/tmp/emacs%d" (user-uid)))
(server-start)
(require 'org-protocol)
(setq org-capture-templates
(quote
(
;; ("w"
;; "Default template"
;; entry
;; (file+headline "~/org/capture.org" "Notes")
;; "* %^{Title}\n\n Source: %u, %c\n\n %i"
;; :empty-lines 1)
;; ... more templates here ...
;; ("w" "Web site" entry
;; (file "")
;; "* %a :website:\n\n%U %?\n\n%:initial")
("w" "Web site" entry
(file "")
"* %a :website:\n\n%U %?\n\n%:initial")
("t" "todo" entry (file org-default-notes-file)
"* TODO %?\n%u\n%a\n" :clock-in t :clock-resume t)
("m" "Meeting" entry (file org-default-notes-file)
"* MEETING with %? :MEETING:\n%t" :clock-in t :clock-resume t)
("d" "Diary" entry (file+datetree "~/org/diary.org")
"* %?\n%U\n" :clock-in t :clock-resume t)
("i" "Idea" entry (file org-default-notes-file)
"* %? :IDEA: \n%t" :clock-in t :clock-resume t)
("n" "Next Task" entry (file+headline org-default-notes-file "Tasks")
"** NEXT %? \nDEADLINE: %t"
)
("p" "Protocol" entry (file+headline ,(concat org-directory "notes.org") "Inbox")
"* %^{Title}\nSource: %u, %c\n #+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n\n%?")
("L" "Protocol Link" entry (file+headline ,(concat org-directory "notes.org") "Inbox")
"* %? [[%:link][%:description]] \nCaptured On: %U")
)))
(add-to-list 'load-path "~/.emacs.d/site-lisp/org-protocol-capture-html/")
(require 'org-protocol-capture-html)
(require 'edit-server)
(if (not (server-running-p server-name))
(use-package edit-server
:ensure t
:config
(progn
;; Don't pop up a new frame
(setq edit-server-new-frame nil)
(setq edit-server-default-major-mode 'org-mode)
(setq edit-server-url-major-mode-alist
'(("github\\.com" . markdown-mode)
("stackexchange\\.com" . markdown-mode)
("stackoverflow\\.com" . markdown-mode)
("reddit\\.com" . markdown-mode)))
;; Integration with Gmail
(use-package edit-server-htmlize
:ensure t
:defer t
:config
(progn
(add-hook 'edit-server-start-hook #'edit-server-maybe-dehtmlize-buffer)
(add-hook 'edit-server-done-hook #'edit-server-maybe-htmlize-buffer)))
(edit-server-start))))
(use-package xkcd
:defer t
:config
(progn
(bind-keys
:map xkcd-mode-map
("/" . xkcd-get)
("g" . xkcd-get-latest)
("c" . xkcd-get-latest-cached)
("p" . xkcd-prev)
("n" . xkcd-next)
("v" . xkcd-open-browser)
("w" . xkcd-copy-link)
("?" . xkcd-open-explanation-browser))))
(provide 'setup-xkcd)
;; (server-mode 1)
(setenv "EDITOR" "emacsclient")
;; add save-as function
(defun save-as (filename)
(interactive "F")
(write-region (point-min) (point-max) filename))
(global-set-key (kbd "s-S") 'save-as)
(global-set-key (kbd "s-b") 'helm-buffers-list)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(global-set-key (kbd "s-o") 'helm-find-files)
(setq helm-locate-command
"glocate %s %s"
helm-locate-create-db-command
"gupdatedb --output='%s' --localpaths='%s'")
(setq helm-locate-project-list
(list "/Users/yongguo/.emacs.d/"))
;; Set common-lisp system and, optionally, some contribs
;; (setq slime-lisp-implementations
;; '(
;; (clisp ("/opt/local/bin/clisp" "-q -I"))
;; (sbcl ("/usr/local/bin/sbcl") :coding-system utf-8-unix)))
(setq inferior-lisp-program "/usr/local/bin/sbcl --noinform --no-linedit")
(setq slime-contribs '(slime-fancy))
(require 'px)
(global-set-key (kbd "s-w") 'ido-kill-buffer)
(global-set-key (kbd "s-p") 'apropos)
(global-set-key (kbd "C-e") 'end-of-visual-line)
;; define keys in evil mode command mode
(eval-after-load 'evil-ex
'(evil-ex-define-cmd "bl" 'gud-break))
(with-eval-after-load 'evil-maps
(define-key evil-normal-state-map (kbd "C-e") 'end-of-visual-line)
(define-key evil-normal-state-map (kbd "C-a") 'evil-first-non-blank-of-visual-line)
(define-key evil-insert-state-map (kbd "C-e") 'end-of-visual-line)
(define-key evil-normal-state-map (kbd "C-e") 'end-of-visual-line)
(define-key evil-visual-state-map (kbd "C-e") 'end-of-visual-line)
(define-key evil-insert-state-map (kbd "C-a") 'evil-first-non-blank-of-visual-line)
(define-key evil-normal-state-map (kbd "C-n") 'evil-next-line)
(define-key evil-normal-state-map (kbd "C-p") 'evil-previous-line)
(define-key evil-insert-state-map (kbd "C-n") 'evil-next-line)
(define-key evil-insert-state-map (kbd "C-p") 'evil-previous-line)
(define-key evil-normal-state-map (kbd "C-k") 'evil-delete-line)
(define-key evil-insert-state-map (kbd "C-k") 'evil-delete-line)
)
(defun get-lang-from-src-block-mode (mode-name)
(message mode-name)
(if
(equalp mode-name "ipython")
"python"
mode-name)
)
(defun open-src-block-region-in-sublime()
(interactive)
(let ((lang (get-lang-from-src-block-mode (nth 0 (org-babel-get-src-block-info)))))
(shell-command (format "subl -n -w --command \"set_file_type {\\\"syntax\\\":\\\"Packages/%s/%s.sublime-syntax\\\"}\"" (capitalize lang) lang))))
(global-set-key (kbd "M-g s") 'open-src-block-region-in-sublime)
;; (defvar current-src-block-lang nil)
;; (defadvice org-edit-special (before org-edit-src-code activate)
;; (let ((lang (nth 0 (org-babel-get-src-block-info))))
;; (setq current-src-block-lang lang)
;; ))
(setq org-columns-default-format "%50ITEM(Task) %10CLOCKSUM %16TIMESTAMP_IA")
(setq org-refile-targets (quote ((nil :maxlevel . 9)
(org-agenda-files :maxlevel . 9))))
;; (defconst org-protocol-capture-html-pandoc-no-wrap-option "--wrap=auto")
(message "This is the end of init.el")
(defun copy-from-osx ()
(shell-command-to-string "pbpaste"))
(defun paste-to-osx (text &optional push)
(let ((process-connection-type nil))
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
(process-send-string proc text)
(process-send-eof proc))))
(setq interprogram-cut-function 'paste-to-osx)
(setq interprogram-paste-function 'copy-from-osx)
(global-set-key (kbd "C-c a") 'org-agenda)
(org-agenda nil "a")
;; archive all the DONE tasks using a single command
(defun my-org-archive-done-tasks ()
(interactive)
(org-map-entries 'org-archive-subtree "/DONE" 'file))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment