Reorganized .emacs

clean_emacs
TuDatTr 2018-01-05 12:15:52 +01:00
parent b1ea714647
commit 4e85c75919
No known key found for this signature in database
GPG Key ID: 6B2AC5D2CAECE06A
2 changed files with 55 additions and 52 deletions

106
.emacs
View File

@ -17,42 +17,42 @@
;; Copy and Paste ;; Copy and Paste
;; https://github.com/Boruch-Baum ;; https://github.com/Boruch-Baum
(defun my-copy-to-xclipboard(arg) (defun my-copy-to-xclipboard(arg)
(interactive "P") (interactive "P")
(cond (cond
((not (use-region-p)) ((not (use-region-p))
(message "Nothing to yank to X-clipboard")) (message "Nothing to yank to X-clipboard"))
((and (not (display-graphic-p)) ((and (not (display-graphic-p))
(/= 0 (shell-command-on-region (/= 0 (shell-command-on-region
(region-beginning) (region-end) "xsel -i -b"))) (region-beginning) (region-end) "xsel -i -b")))
(error "Is program `xsel' installed?")) (error "Is program `xsel' installed?"))
(t (t
(when (display-graphic-p) (when (display-graphic-p)
(call-interactively 'clipboard-kill-ring-save)) (call-interactively 'clipboard-kill-ring-save))
(message "Yanked region to X-clipboard") (message "Yanked region to X-clipboard")
(when arg (when arg
(kill-region (region-beginning) (region-end))) (kill-region (region-beginning) (region-end)))
(deactivate-mark)))) (deactivate-mark))))
(defun my-cut-to-xclipboard() (defun my-cut-to-xclipboard()
(interactive) (interactive)
(my-copy-to-xclipboard t)) (my-copy-to-xclipboard t))
(defun my-paste-from-xclipboard() (defun my-paste-from-xclipboard()
"Uses shell command `xsel -o' to paste from x-clipboard. With "Uses shell command `xsel -o' to paste from x-clipboard. With
one prefix arg, pastes from X-PRIMARY, and with two prefix args, one prefix arg, pastes from X-PRIMARY, and with two prefix args,
pastes from X-SECONDARY." pastes from X-SECONDARY."
(interactive) (interactive)
(if (display-graphic-p) (if (display-graphic-p)
(clipboard-yank) (clipboard-yank)
(let* (let*
((opt (prefix-numeric-value current-prefix-arg)) ((opt (prefix-numeric-value current-prefix-arg))
(opt (cond (opt (cond
((= 1 opt) "b") ((= 1 opt) "b")
((= 4 opt) "p") ((= 4 opt) "p")
((= 16 opt) "s")))) ((= 16 opt) "s"))))
(insert (shell-command-to-string (concat "xsel -o -" opt)))))) (insert (shell-command-to-string (concat "xsel -o -" opt))))))
;; elpy-mode functions
(defun pyexec () (defun pyexec ()
"Execute the python program in an external terminal." "Execute the python program in an external terminal."
(interactive) (interactive)
@ -60,7 +60,7 @@
(shell-command (concat "termite --hold -e \"python " buffer-file-name "\"")) (shell-command (concat "termite --hold -e \"python " buffer-file-name "\""))
) )
) )
;; CC-mode functions
(defun cppexec () (defun cppexec ()
"Execute the python program in an external terminal." "Execute the python program in an external terminal."
(interactive) (interactive)
@ -69,11 +69,11 @@
(shell-command (concat "termite --hold -e \"./a.out\"")) (shell-command (concat "termite --hold -e \"./a.out\""))
) )
) )
;; Latex ;; Latex-mode functions
(fset 'next-section (fset 'next-section
(lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ("\\sec " 0 "%d")) arg))) (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ("\\sec " 0 "%d")) arg)))
(fset 'prev-section (fset 'prev-section
(lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ("\\sec " 0 "%d")) arg))) (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ("\\sec " 0 "%d")) arg)))
;; Theme ;; Theme
(custom-set-variables (custom-set-variables
@ -84,6 +84,11 @@
'(custom-safe-themes '(custom-safe-themes
(quote (quote
("66881e95c0eda61d34aa7f08ebacf03319d37fe202d68ecf6a1dbfd49d664bc3" default))) ("66881e95c0eda61d34aa7f08ebacf03319d37fe202d68ecf6a1dbfd49d664bc3" default)))
'(dp-pairs
(quote
(("(" ")" nil)
("[" "]" nil)
("{" "}" dp-brace-post-handler))))
'(elpy-dedicated-shells t) '(elpy-dedicated-shells t)
'(elpy-shell-display-buffer-after-send t) '(elpy-shell-display-buffer-after-send t)
'(global-font-lock-mode t) '(global-font-lock-mode t)
@ -107,9 +112,7 @@
;; Startup ;; Startup
;; Load Theme ;; Load Theme
(load-theme 'forest-blue t) (load-theme 'forest-blue t)
;; General stuff
(show-paren-mode 1)
(menu-bar-mode -1)
;; Python ;; Python
(elpy-enable) (elpy-enable)
(defalias 'workon 'pyvenv-workon) (defalias 'workon 'pyvenv-workon)
@ -117,10 +120,13 @@
(eval-after-load 'elpy (eval-after-load 'elpy
'(define-key elpy-mode-map (kbd "C-c C-c") 'pyexec) '(define-key elpy-mode-map (kbd "C-c C-c") 'pyexec)
) )
;; C++ ;; C++
(eval-after-load 'cc-mode (eval-after-load 'cc-mode
'(define-key c++-mode-map (kbd "C-c C-c") 'cppexec)) '(define-key c++-mode-map (kbd "C-c C-c") 'cppexec))
;; LaTeX ;; LaTeX
(require 'tex)
(setq TeX-auto-save t) (setq TeX-auto-save t)
(setq TeX-parse-self t) (setq TeX-parse-self t)
(setq-default TeX-master nil) (setq-default TeX-master nil)
@ -128,27 +134,23 @@
'(define-key LaTeX-mode-map (kbd "C-c n") 'next-section)) '(define-key LaTeX-mode-map (kbd "C-c n") 'next-section))
(eval-after-load 'latex (eval-after-load 'latex
'(define-key LaTeX-mode-map (kbd "C-c p") 'prev-section)) '(define-key LaTeX-mode-map (kbd "C-c p") 'prev-section))
;; Tex To PDF
(require 'tex)
(TeX-global-PDF-mode t)
;; Yasnippet ;; Yasnippet
(setq yas-snippet-dirs (setq yas-snippet-dirs
'("~/.emacs.d/snippets" ;; personal snippets/copied ones '("~/.emacs.d/snippets" ;; personal snippets/copied ones
) )
) )
(yas-global-mode t)
;; flycheck
(add-hook 'after-init-hook #'global-flycheck-mode) ;; Modes
;; dummyparents (show-paren-mode 1)
(eval-after-load "dummyparens-autoloads" (menu-bar-mode -1)
'(progn
(if (require 'dummyparens nil t)
(global-dummyparens-mode)
(warn "dummyparens not found"))))
;; Google-this
(google-this-mode 1) (google-this-mode 1)
;; Nyan-Mode
(nyan-mode 1) (nyan-mode 1)
(TeX-global-PDF-mode t)
(yas-global-mode t)
(global-dummyparens-mode)
(add-hook 'after-init-hook #'global-flycheck-mode)
;; Custom Keybinds ;; Custom Keybinds
(global-set-key (kbd "C-c C-w") 'my-cut-to-xclipboard) (global-set-key (kbd "C-c C-w") 'my-cut-to-xclipboard)

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*~ *~
\#*\# \#*\#
*.log *.log
.#\config