Created
July 31, 2017 08:39
-
-
Save quasilyte/4034a6783644cf1753803b4bc3446055 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; File name: ` ~/.emacs ' | |
;;; --------------------- | |
;;; | |
;;; If you need your own personal ~/.emacs | |
;;; please make a copy of this file | |
;;; an placein your changes and/or extension. | |
;;; | |
;;; Copyright (c) 1997-2002 SuSE Gmbh Nuernberg, Germany. | |
;;; | |
;;; Author: Werner Fink, <feedback@suse.de> 1997,98,99,2002 | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; | |
;;; Test of Emacs derivates | |
;;; ----------------------- | |
;; Added by Package.el. This must come before configurations of | |
;; installed packages. Don't delete this line. If you don't want it, | |
;; just comment it out by adding a semicolon to the start of the line. | |
;; You may delete these explanatory comments. | |
(package-initialize) | |
(if (string-match "XEmacs\\|Lucid" emacs-version) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; XEmacs | |
;;; ------ | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(progn | |
(if (file-readable-p "~/.xemacs/init.el") | |
(load "~/.xemacs/init.el" nil t)) | |
) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; GNU-Emacs | |
;;; --------- | |
;;; load ~/.gnu-emacs or, if not exists /etc/skel/.gnu-emacs | |
;;; For a description and the settings see /etc/skel/.gnu-emacs | |
;;; ... for your private ~/.gnu-emacs your are on your one. | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(if (file-readable-p "~/.gnu-emacs") | |
(load "~/.gnu-emacs" nil t) | |
(if (file-readable-p "/etc/skel/.gnu-emacs") | |
(load "/etc/skel/.gnu-emacs" nil t))) | |
;; Custom Settings | |
;; =============== | |
;; To avoid any trouble with the customization system of GNU emacs | |
;; we set the default file ~/.gnu-emacs-custom | |
(setq custom-file "~/.gnu-emacs-custom") | |
(load "~/.gnu-emacs-custom" t t) | |
;;; | |
) | |
;;; | |
(set-default 'truncate-lines t) | |
(setq scroll-step 1 | |
inhibit-startup-screen t) | |
(require 'whitespace) | |
(setq whitespace-style '(face empty tabs lines-tail trailing)) | |
(global-whitespace-mode t) | |
;; New installation? | |
(unless (require 'dash nil 'noerror) | |
(require 'package) | |
(package-initialize) | |
(add-to-list | |
'package-archives | |
'("melpa-stable" . "http://stable.melpa.org/packages/") t) | |
(package-refresh-contents) | |
;; Install missing packages | |
(dolist (pkg '(dash | |
company | |
smex | |
smartparens | |
s | |
flycheck | |
flycheck-package)) | |
(package-install pkg))) | |
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes") | |
(global-set-key (kbd "M-x") 'smex) | |
(global-set-key (kbd "C-x C-f") 'ido-find-file) | |
(global-set-key (kbd "C-x g") 'Go-translate-by-name) | |
(global-set-key (kbd "M-<up>") 'move-line-up) | |
(global-set-key (kbd "M-<down>") 'move-line-down) | |
(global-set-key (kbd "M-<left>") 'pop-tag-mark) ; "Go back" | |
(global-set-key (kbd "M-S-<down>") 'mc/mark-next-like-this) | |
(global-set-key (kbd "M-S-<up>") 'mc/mark-previous-like-this) | |
(global-set-key (kbd "C-<tab>") 'company-complete) | |
;; To be safe, all key-chords start with a backslash. | |
(require 'key-chord) | |
(key-chord-mode 1) | |
(key-chord-define-global "\\\\" #'=M-x) | |
(require 'multiple-cursors) | |
(define-key mc/keymap (kbd "<return>") nil) | |
(defun =M-x () | |
(interactive) | |
(require 'smex) | |
(unless smex-initialized-p | |
(smex-initialize)) | |
(if (smex-already-running) | |
(smex-update-and-rerun) | |
(and smex-auto-update | |
(smex-detect-new-commands) | |
(smex-update)) | |
(let* ((item-name (ido-completing-read | |
"M-x " | |
smex-ido-cache | |
nil | |
nil | |
"@" | |
'extended-command-history)) | |
(item (intern-soft item-name))) | |
(unwind-protect | |
(execute-extended-command current-prefix-arg item-name) | |
(smex-rank item))))) | |
(setq backup-inhibited t) | |
(setq make-backup-files nil) | |
(setq auto-save-list-file-name nil) | |
(setq auto-save-default nil) | |
(menu-bar-mode -1) | |
(tool-bar-mode -1) | |
(require 'ido) | |
(ido-mode t) | |
(ido-everywhere 1) | |
(eval-after-load "magit" | |
(setq magit-completing-read-function 'magit-ido-completing-read)) | |
(setq show-paren-style 'expression) | |
(show-paren-mode 2) | |
(set-default-font "Droid Sans Mono") | |
(set-face-attribute 'default nil :height 120) | |
(setq-default indent-tabs-mode nil) | |
(defun @elisp () | |
(interactive) | |
(company-mode) | |
(smartparens-mode) | |
(require 'smartparens-config) | |
(setq sp-highlight-pair-overlay nil)) | |
(add-hook 'java-mode-hook (lambda () | |
(c-set-offset 'arglist-intro '+) | |
(c-set-offset 'arglist-close 0))) | |
(add-hook 'c++-mode-hook (lambda () | |
(c-set-offset 'arglist-intro '+) | |
(c-set-offset 'arglist-close 0))) | |
(add-hook 'c-mode-hook (lambda () | |
(c-set-offset 'arglist-intro '+) | |
(c-set-offset 'arglist-close 0))) | |
(add-hook 'python-mode-hook 'auto-complete-mode) | |
(defun @widen () | |
(interactive) | |
(widen)) | |
(defun @narrow () | |
(interactive) | |
(if mark-active | |
(narrow-to-region (region-beginning) | |
(region-end)) | |
(narrow-to-defun t))) | |
(defun @org () | |
(interactive) | |
(find-file "~/org.org")) | |
(defun @todo () | |
(interactive) | |
(find-file "~/todo.org")) | |
(defun @rm-buffer () | |
"Kill the current buffer and delete the file it is visiting." | |
(interactive) | |
(let ((filename (buffer-file-name))) | |
(when (and filename | |
(y-or-n-p (concat "Delete " filename " ?"))) | |
(delete-file filename) | |
(message "Deleted file %s." filename) | |
(kill-buffer)))) | |
(defun rename-file-and-buffer () | |
"Rename the current buffer and file it is visiting." | |
(interactive) | |
(let ((filename (buffer-file-name))) | |
(if (not (and filename (file-exists-p filename))) | |
(message "Buffer is not visiting a file!") | |
(let ((new-name (read-file-name "New name: " filename))) | |
(cond | |
((vc-backend filename) (vc-rename-file filename new-name)) | |
(t | |
(rename-file filename new-name t) | |
(set-visited-file-name new-name t t))))))) | |
(defun @mv-buffer () | |
"Rename the current buffer and file it is visiting." | |
(interactive) | |
(let* ((old-name (buffer-file-name)) | |
(new-name (read-string "Rename to: " old-name))) | |
(when old-name | |
(rename-file old-name new-name t) | |
(set-visited-file-name new-name t t)))) | |
(defmacro dis-lambda (params &rest body) | |
(declare (indent defun)) | |
`(let ((lexical-binding t)) | |
(disassemble | |
(byte-compile | |
(lambda ,params | |
,@body))))) | |
(defun move-line-up () | |
(interactive) | |
(transpose-lines 1) | |
(forward-line -2)) | |
(defun move-line-down () | |
(interactive) | |
(forward-line 1) | |
(transpose-lines 1) | |
(forward-line -1)) | |
;; Setup Go language support. | |
(when (require 'go-mode nil 'noerror) | |
(setenv "GOPATH" "/home/quasilyte/CODE/elgo") | |
(setenv "PATH" (concat (getenv "PATH") ":/usr/local/go/bin")) | |
(setq exec-path (append exec-path '("/usr/local/go/bin")))) | |
(defun my-go-mode-hook () | |
(require 'go-rename) | |
(auto-revert-mode) ;; Useful in conjunction with gorename | |
;; Use goimports instead of go-fmt | |
(setq gofmt-command "goimports") | |
;; Call Gofmt before saving. | |
(add-hook 'before-save-hook 'gofmt-before-save) | |
;; Godef jump key binding. | |
(local-set-key (kbd "<C-return>") #'godef-jump) | |
;; Set autocomplete. | |
(set (make-local-variable 'company-backends) '(company-go)) | |
(company-mode) | |
(setq company-go-begin-after-member-access nil) | |
;; Additional configuration. | |
(go-eldoc-setup) | |
(smartparens-mode) | |
(flycheck-mode)) | |
(add-hook 'go-mode-hook 'my-go-mode-hook) | |
(defun my-go-doc () | |
(godoc-at-point (point))) | |
(defun my-elisp-doc () | |
(describe-symbol (intern-soft (thing-at-point 'symbol)))) | |
(defun @doc () | |
(interactive) | |
(funcall (pcase major-mode | |
(`go-mode #'my-go-doc) | |
(`emacs-lisp-mode #'my-elisp-doc)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment