Last active
September 19, 2023 14:11
-
-
Save nedclimax/4d1fd825e453cdf9f82f7213fd55dc33 to your computer and use it in GitHub Desktop.
poopy emacs configuration
This file contains hidden or 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
| (require 'cc-mode) | |
| (add-to-list 'default-frame-alist '(fullscreen . maximized)) | |
| (tool-bar-mode 0) | |
| (menu-bar-mode 0) | |
| (scroll-bar-mode 0) | |
| (column-number-mode 1) | |
| (if (eq system-type 'windows-nt) | |
| (set-face-attribute 'default nil :font "Consolas" :height 100)) | |
| (set-face-attribute font-lock-builtin-face nil :foreground "#A85E1D") | |
| (set-face-attribute font-lock-comment-face nil :foreground "gray50") | |
| (set-face-attribute font-lock-doc-face nil :foreground "gray50") | |
| (set-face-attribute font-lock-keyword-face nil :foreground "darkgoldenrod3") | |
| (set-face-attribute font-lock-function-name-face nil :foreground "burlywood3") | |
| (set-face-attribute font-lock-string-face nil :foreground "olivedrab50") | |
| (set-face-attribute font-lock-constant-face nil :foreground "darkgoldenrod3") | |
| (set-background-color "#161616") | |
| (set-foreground-color "burlywood") | |
| (set-cursor-color "green") | |
| ;; Color TODOs NOTEs and FIXMEs | |
| (setq hl-modes '(cc-mode emacs-lisp-mode)) | |
| (make-face 'font-lock-todo-face) | |
| (make-face 'font-lock-note-face) | |
| (mapc (lambda (mode) | |
| (font-lock-add-keywords | |
| mode | |
| '(("\\<\\(TODO\\)" 1 'font-lock-todo-face t) | |
| ("\\<\\(NOTE\\)" 1 'font-lock-note-face t) | |
| ))) | |
| hl-modes) | |
| (modify-face 'font-lock-todo-face "orange" nil nil t nil t nil nil) | |
| (modify-face 'font-lock-note-face "olivedrab" nil nil t nil t nil nil) | |
| (setq blink-cursor-blinks 0) | |
| (global-hl-line-mode 0) | |
| (set-face-background 'hl-line "midnight blue") | |
| (setq frame-title-format '("emacs@" system-name)) | |
| (setq inhibit-splash-screen t) | |
| (setq truncate-lines t) | |
| (add-hook 'window-setup-hook (lambda () | |
| (interactive) | |
| (toggle-truncate-lines t) | |
| (split-window-horizontally))) | |
| (add-hook 'prog-mode-hook (lambda () | |
| (make-local-variable 'truncate-lines) | |
| (make-local-variable 'indent-tabs-mode) | |
| (setq indent-tabs-mode t) | |
| (setq truncate-lines t))) | |
| (add-hook 'emacs-lisp-mode-hook (lambda () | |
| (make-local-variable 'indent-tabs-mode) | |
| (setq indent-tabs-mode nil))) | |
| (add-hook 'org-mode-hook (lambda () | |
| (make-local-variable 'truncate-lines) | |
| (setq truncate-lines nil))) | |
| (setq create-lockfiles nil) | |
| (setq make-backup-files nil) | |
| (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) | |
| ;;; Put Emacs auto-save and backup files to /tmp/ or C:/Temp/ | |
| (defconst emacs-tmp-dir (expand-file-name (format "emacs%d" (user-uid)) temporary-file-directory)) | |
| (setq backup-by-copying t | |
| delete-old-versions t | |
| kept-new-versions 6 | |
| kept-old-versions 2 | |
| version-control t | |
| auto-save-list-file-prefix emacs-tmp-dir | |
| auto-save-file-name-transforms `((".*" ,emacs-tmp-dir t)) | |
| backup-directory-alist `((".*" . ,emacs-tmp-dir))) | |
| (fset 'yes-or-no-p 'y-or-n-p) | |
| (add-hook 'before-save-hook 'whitespace-cleanup) | |
| (require 'ido) | |
| (ido-mode t) | |
| (ido-everywhere t) | |
| (require 'compile) | |
| (setq compilation-scroll-output t) | |
| (add-hook 'compilation-mode-hook (lambda () | |
| (make-local-variable 'truncate-lines) | |
| (setq truncate-lines nil))) | |
| (electric-pair-mode 1) | |
| (electric-quote-mode 1) | |
| (electric-indent-mode 1) | |
| (electric-layout-mode 1) | |
| (show-paren-mode 1) | |
| (setq ring-bell-function 'ignore) | |
| (setq create-lockfiles nil) | |
| (setq-default indent-tabs-mode t) | |
| (setq-default tab-width 4) | |
| (setq-default c-basic-offset 4) | |
| (setq c-default-style '((java-mode . "java") | |
| (awk-mode . "awk") | |
| (other . "k&r"))) | |
| (setq dabbrev-case-replace t) | |
| (setq dabbrev-case-fold-search t) | |
| (setq dabbrev-case-distinction t) | |
| (setq dabbrev-upcase-means-case-search t) | |
| (abbrev-mode 1) | |
| (global-set-key (kbd "C-,") 'other-window) | |
| (global-set-key (kbd "C-M-,") (lambda () | |
| (interactive) | |
| (other-window -1))) | |
| (global-set-key (kbd "C-z") 'undo) | |
| (global-set-key (kbd "C-f") 'find-file) | |
| (global-set-key (kbd "C-b") 'switch-to-buffer) | |
| (global-set-key (kbd "C-M-f") 'find-file-other-window) | |
| (global-set-key (kbd "C-M-b") 'switch-to-buffer-other-window) | |
| (global-set-key (kbd "M-f") 'write-file) | |
| (global-set-key (kbd "M-RET") 'recompile) | |
| ;; Disable useless keybindings | |
| (global-unset-key (kbd "C-n")) | |
| (global-unset-key (kbd "C-p")) | |
| (global-unset-key (kbd "M-b")) | |
| (global-unset-key (kbd "C-M-n")) | |
| (global-unset-key (kbd "C-M-p")) | |
| (defun move-text-internal (arg) | |
| "Move region (transient-mark-mode active) or current line." | |
| (let ((remember-point (point))) | |
| ;; Can't get correct effect of `transpose-lines' | |
| ;; when `point-max' is not at beginning of line | |
| ;; So fix this bug. | |
| (goto-char (point-max)) | |
| (if (not (bolp)) (newline)) ;add newline to fix | |
| (goto-char remember-point) | |
| ;; logic code start | |
| (cond ((and mark-active transient-mark-mode) | |
| (if (> (point) (mark)) | |
| (exchange-point-and-mark)) | |
| (let ((column (current-column)) | |
| (text (delete-and-extract-region (point) (mark)))) | |
| (forward-line arg) | |
| (move-to-column column t) | |
| (set-mark (point)) | |
| (insert text) | |
| (exchange-point-and-mark) | |
| (setq deactivate-mark nil))) | |
| (t | |
| (let ((column (current-column))) | |
| (beginning-of-line) | |
| (when (or (> arg 0) (not (bobp))) | |
| (forward-line 1) | |
| (when (or (< arg 0) (not (eobp))) | |
| (transpose-lines arg)) | |
| (forward-line -1)) | |
| (move-to-column column t)) | |
| )))) | |
| (defun move-text-up (arg) | |
| "Move region (transient-mark-mode active) or current line ARG lines up." | |
| (interactive "*p") | |
| (move-text-internal (- arg))) | |
| (defun move-text-down (arg) | |
| "Move region (transient-mar-mode active) or current line (ARG lines) down." | |
| (interactive "*p") | |
| (move-text-internal arg)) | |
| (defun duplicate-line-or-region-above (&optional reverse) | |
| "Duplicate current line or region above. | |
| By default, duplicate current line above. | |
| If mark is activate, duplicate region lines above. | |
| Default duplicate above, unless option REVERSE is non-nil." | |
| (interactive) | |
| (let ((origianl-column (current-column)) | |
| duplicate-content) | |
| (if mark-active | |
| ;; If mark active. | |
| (let ((region-start-pos (region-beginning)) | |
| (region-end-pos (region-end))) | |
| ;; Set duplicate start line position. | |
| (setq region-start-pos (progn | |
| (goto-char region-start-pos) | |
| (line-beginning-position))) | |
| ;; Set duplicate end line position. | |
| (setq region-end-pos (progn | |
| (goto-char region-end-pos) | |
| (line-end-position))) | |
| ;; Get duplicate content. | |
| (setq duplicate-content (buffer-substring region-start-pos region-end-pos)) | |
| (if reverse | |
| ;; Go to next line after duplicate end position. | |
| (progn | |
| (goto-char region-end-pos) | |
| (forward-line +1)) | |
| ;; Otherwise go to duplicate start position. | |
| (goto-char region-start-pos))) | |
| ;; Otherwise set duplicate content equal current line. | |
| (setq duplicate-content (buffer-substring | |
| (line-beginning-position) | |
| (line-end-position))) | |
| ;; Just move next line when `reverse' is non-nil. | |
| (and reverse (forward-line 1)) | |
| ;; Move to beginning of line. | |
| (beginning-of-line)) | |
| ;; Open one line. | |
| (open-line 1) | |
| ;; Insert duplicate content and revert column. | |
| (insert duplicate-content) | |
| (move-to-column origianl-column t))) | |
| (defun duplicate-line-or-region-below () | |
| "Duplicate current line or region below. | |
| By default, duplicate current line below. | |
| If mark is activate, duplicate region lines below." | |
| (interactive) | |
| (duplicate-line-or-region-above t)) | |
| (defun duplicate-line-above-comment (&optional reverse) | |
| "Duplicate current line above, and comment current line." | |
| (interactive) | |
| (if reverse | |
| (duplicate-line-or-region-below) | |
| (duplicate-line-or-region-above)) | |
| (save-excursion | |
| (if reverse | |
| (forward-line -1) | |
| (forward-line +1)) | |
| (comment-or-uncomment-region+))) | |
| (defun mark-line () | |
| "Mark one whole line, similar to `mark-paragraph'." | |
| (interactive) | |
| (beginning-of-line) | |
| (if mark-active | |
| (exchange-point-and-mark) | |
| (push-mark nil nil t)) | |
| (forward-line) | |
| (exchange-point-and-mark)) | |
| (defun open-newline-above (arg) | |
| "Move to the previous line (like vi) and then opens a line." | |
| (interactive "p") | |
| (beginning-of-line) | |
| (open-line arg) | |
| (if (not (member major-mode '(haskell-mode org-mode literate-haskell-mode))) | |
| (indent-according-to-mode) | |
| (beginning-of-line))) | |
| (defun open-newline-below (arg) | |
| "Move to the next line (like vi) and then opens a line." | |
| (interactive "p") | |
| (end-of-line) | |
| (open-line arg) | |
| (call-interactively 'next-line arg) | |
| (if (not (member major-mode '(haskell-mode org-mode literate-haskell-mode))) | |
| (indent-according-to-mode) | |
| (beginning-of-line))) | |
| (global-set-key (kbd "C-l") 'duplicate-line-or-region-below) | |
| (global-set-key (kbd "C-M-l") 'duplicate-line-or-region-above) | |
| (global-set-key (kbd "M-<up>") 'move-text-up) | |
| (global-set-key (kbd "M-<down>") 'move-text-down) | |
| (global-set-key (kbd "C-<return>") 'open-newline-below) | |
| (global-set-key (kbd "C-M-<return>") 'open-newline-above) | |
| (define-key c-mode-base-map (kbd "S-<tab>") 'indent-for-tab-command) | |
| (define-key c-mode-base-map (kbd "<tab>") 'dabbrev-expand) | |
| (put 'upcase-region 'disabled nil) | |
| (put 'downcase-region 'disabled nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment