Advertisement
Guest User

init-defaults.el

a guest
Jun 29th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 10.31 KB | None | 0 0
  1. ;;; init-defaults.el --- Some default things -*- lexical-binding: t; -*-
  2.  
  3. ;;; Commentary:
  4.  
  5. ;;; Code:
  6.  
  7. ;; Some variables
  8. (defvar minotaur-emacs-dir
  9.   (eval-when-compile (file-truename user-emacs-directory))
  10.   "Our Emacs directory, where everything is loaded. Must end with a slash.")
  11.  
  12. (defvar minotaur-local-dir
  13.   (concat minotaur-emacs-dir ".local/")
  14.   "For local storage of many things.
  15.  
  16. Purely for the sake of sanity; i.e. we don't want random files that are used
  17. for saving places or any other data just lying in the `user-emacs-directory'.")
  18.  
  19. (defvar minotaur-etc-dir
  20.   (concat minotaur-local-dir "etc/")
  21.   "For non-volatile local storage.
  22.  
  23. Stuff that doesn't change.")
  24.  
  25. (defvar minotaur-cache-dir
  26.   (concat minotaur-local-dir "cache/")
  27.   "For volatile local storage.
  28.  
  29. For stuff that *does* change.")
  30.  
  31. (defvar minotaur-package-dir
  32.   (concat minotaur-local-dir "packages/")
  33.   "A clean place to store packages.")
  34.  
  35. (defvar minotaur-debug-mode (or (getenv "DEBUG") init-file-debug)
  36.   "If non-nil, Minotaur will log more.
  37.  
  38. Use `minotaur-toggle-debug-mode' to toggle it. The --debug-init flag and setting the
  39. DEBUG envvar will enable this at startup.")
  40.  
  41. (defun minotaur-toggle-debug-mode (&optional arg)
  42.   "Toggle `debug-on-error' and `minotaur-debug-mode' for verbose logging."
  43.   (interactive (list (or current-prefix-arg 'toggle)))
  44.   (let ((value
  45.          (cond ((eq arg 'toggle) (not minotaur-debug-mode))
  46.                ((> (prefix-numeric-value arg) 0)))))
  47.     (setq minotaur-debug-mode value
  48.           debug-on-error value)
  49.     (message "Debug mode %s" (if value "on" "off"))))
  50.  
  51. (defconst EMACS26+ (> emacs-major-version 25))
  52. (defconst EMACS27+ (> emacs-major-version 26))
  53.  
  54. (defconst IS-MAC     (eq system-type 'darwin))
  55. (defconst IS-LINUX   (eq system-type 'gnu/linux))
  56. (defconst IS-WINDOWS (memq system-type '(cygwin windows-nt ms-dos)))
  57. (defconst IS-BSD (or IS-MAC (eq system-type 'berkeley-unix)))
  58.  
  59. ;;; Editing basics from Doom Emacs
  60. (setq-default
  61.  large-file-warning-threshold 15000000
  62.  vc-follow-symlinks t
  63.  ;; Save clipboard contents into kill-ring before replacing them
  64.  save-interprogram-paste-before-kill t
  65.  ;; Bookmarks
  66.  bookmark-default-file (concat minotaur-etc-dir "bookmarks")
  67.  bookmark-save-flag t
  68.  ;; Formatting
  69.  delete-trailing-lines nil
  70.  fill-column 80
  71.  sentence-end-double-space nil
  72.  word-wrap t
  73.  ;; Scrolling
  74.  hscroll-margin 2
  75.  hscroll-step 1
  76.  scroll-conservatively 1001
  77.  scroll-margin 1
  78.  scroll-preserve-screen-position t
  79.  mouse-wheel-scroll-amount '(5 ((shift) . 2))
  80.  mouse-wheel-progressive-speed nil ; don't accelerate scrolling
  81.  ;; Whitespace (see `editorconfig')
  82.  indent-tabs-mode nil
  83.  require-final-newline t
  84.  tab-always-indent t
  85.  tab-width 4
  86.  tabify-regexp "^\t* [ \t]+" ; for :retab
  87.  ;; Wrapping
  88.  truncate-lines t
  89.  truncate-partial-width-windows 50)
  90.  
  91. ;; Remove hscroll-margin in shells, otherwise it causes jumpiness
  92. (with-eval-after-load 'eshell
  93.   (setq hscroll-margin 0))
  94. (with-eval-after-load 'term
  95.   (setq hscroll-margin 0))
  96.  
  97. ;; More editing defaults
  98. (setq uniquify-buffer-name-style 'post-forward-angle-brackets) ; Show path if names are same
  99. (setq adaptive-fill-regexp "[ t]+|[ t]*([0-9]+.|*+)[ t]*")
  100. (setq adaptive-fill-first-line-regexp "^* *$")
  101. (setq delete-by-moving-to-trash t)         ; Deleting files go to OS's trash folder
  102. (setq make-backup-files nil)               ; Forbide to make backup files
  103. (setq auto-save-default nil)               ; Disable auto save
  104. (setq set-mark-command-repeat-pop t) ; Repeating C-SPC after popping mark pops it again
  105. (setq sentence-end "\\([。!?]\\|……\\|[.?!][]\"')}]*\\($\\|[ \t]\\)\\)[ \t\n]*")
  106. (setq sentence-end-double-space nil)
  107. ;; Permanently indent with spaces, never with TABs
  108. (setq-default c-basic-offset   4
  109.               tab-width        4
  110.               indent-tabs-mode nil)
  111.  
  112. ;; UI defaults
  113. (setq ansi-color-for-comint-mode t
  114.       bidi-display-reordering nil ; disable bidirectional text for tiny performance boost
  115.       blink-matching-paren nil    ; don't blink--too distracting
  116.       compilation-always-kill t        ; kill compilation process before starting another
  117.       compilation-ask-about-save nil   ; save all buffers on `compile'
  118.       compilation-scroll-output 'first-error
  119.       confirm-nonexistent-file-or-buffer t
  120.       cursor-in-non-selected-windows nil ; hide cursors in other windows
  121.       display-line-numbers-width 3
  122.       track-eol t
  123.       enable-recursive-minibuffers nil
  124.       frame-inhibit-implied-resize t
  125.       ;; remove continuation arrow on right fringe
  126.       fringe-indicator-alist
  127.       (delq (assq 'continuation fringe-indicator-alist)
  128.             fringe-indicator-alist)
  129.       highlight-nonselected-windows nil
  130.       image-animate-loop t
  131.       sentence-end-double-space nil
  132.       indicate-buffer-boundaries nil
  133.       indicate-empty-lines nil
  134.       max-mini-window-height 0.3
  135.       use-file-dialog nil
  136.       use-dialog-box nil
  137.       inhibit-startup-screen t
  138.       inhibit-startup-echo-area-message t
  139.       echo-keystrokes 0.1
  140.       mode-line-default-help-echo nil ; disable mode-line mouseovers
  141.       mouse-yank-at-point t           ; middle-click paste at point, not at click
  142.       resize-mini-windows 'grow-only  ; Minibuffer resizing
  143.       show-help-function nil          ; hide :help-echo text
  144.       split-width-threshold 160       ; favor horizontal splits
  145.       uniquify-buffer-name-style nil  ; custom modeline will show file paths anyway
  146.       use-dialog-box nil              ; always avoid GUI
  147.       show-trailing-whitespace t
  148.       visible-cursor nil
  149.       x-stretch-cursor nil
  150.       ;; `pos-tip' defaults
  151.       pos-tip-internal-border-width 6
  152.       pos-tip-border-width 1
  153.       ;; no beeping or blinking please
  154.       ring-bell-function #'ignore
  155.       visible-bell nil
  156.       ;; don't (region-end)size emacs in steps, it looks weird
  157.       window-resize-pixelwise t
  158.       frame-resize-pixelwise t)
  159.  
  160. ;; UTF-8 as the default coding system
  161. (when (fboundp 'set-charset-priority)
  162.   (set-charset-priority 'unicode))     ; pretty
  163. (prefer-coding-system 'utf-8)          ; pretty
  164. (setq locale-coding-system 'utf-8)     ; please
  165. (unless IS-WINDOWS
  166.   (setq selection-coding-system 'utf-8)) ; with sugar on top
  167.  
  168. (fset #'yes-or-no-p #'y-or-n-p)
  169. (fset #'display-startup-echo-area-message #'ignore)
  170. (if (bound-and-true-p tooltip-mode) (tooltip-mode -1))
  171. (blink-cursor-mode -1)
  172. (add-to-list 'default-frame-alist '(tool-bar-lines . 0))
  173. (add-to-list 'default-frame-alist '(menu-bar-lines . 0))
  174. (add-to-list 'default-frame-alist '(vertical-scroll-bars))
  175.  
  176. (setq-default show-trailing-whitespace nil)
  177. (with-eval-after-load 'prog-mode
  178.   (setq show-trailing-white-space t))
  179. (with-eval-after-load 'text-mode
  180.   (setq show-trailing-white-space t))
  181. (with-eval-after-load 'conf-mode
  182.   (setq show-trailing-white-space t))
  183.  
  184. (put 'whitespace-toggle-options 'disabled t)
  185. (put 'global-whitespace-toggle-options 'disabled t)
  186.  
  187. ;; Leave me alone, *Warnings* and *Flycheck errors*
  188. (add-to-list 'display-buffer-alist '("^\\*Warnings\\*$" (display-buffer-no-window)
  189.                                      (allow-no-window . t)))
  190. (add-to-list 'display-buffer-alist '("^\\*Flycheck errors\\*$" (display-buffer-no-window)
  191.                                      (allow-no-window . t)))
  192.  
  193. ;; More defaults from Doom Emacs.
  194. (setq-default
  195.  ad-redefinition-action 'accept   ; silence redefined function warnings
  196.  apropos-do-all t                 ; make `apropos' more useful
  197.  auto-mode-case-fold nil
  198.  autoload-compute-prefixes nil
  199.  load-prefer-newer t
  200.  ediff-window-setup-function 'ediff-setup-windows-plain
  201.  debug-on-error minotaur-debug-mode
  202.  jka-compr-verbose minotaur-debug-mode ; silence compression messages
  203.  ffap-machine-p-known 'reject     ; don't ping things that look like domain names
  204.  find-file-visit-truename t       ; resolve symlinks when opening files
  205.  idle-update-delay 1              ; update ui slightly less often
  206.  ;; be quiet at startup; don't load or display anything unnecessary
  207.  inhibit-startup-message t
  208.  inhibit-startup-echo-area-message user-login-name
  209.  inhibit-default-init t
  210.  initial-major-mode 'fundamental-mode
  211.  initial-scratch-message nil
  212.  ;; History & backup settings (save nothing, that's what git is for)
  213.  auto-save-default nil
  214.  create-lockfiles nil
  215.  history-length 500
  216.  make-backup-files nil  ; don't create backup~ files
  217.  ;; byte compilation
  218.  byte-compile-verbose minotaur-debug-mode
  219.  byte-compile-warnings '(not free-vars unresolved noruntime lexical make-local)
  220.  ;; security
  221.  gnutls-verify-error (not (getenv "INSECURE")) ; you shouldn't use this
  222.  tls-checktrust gnutls-verify-error
  223.  tls-program (list "gnutls-cli --x509cafile %t -p %p %h"
  224.                    ;; compatibility fallbacks
  225.                    "gnutls-cli -p %p %h"
  226.                    "openssl s_client -connect %h:%p -no_ssl2 -no_ssl3 -ign_eof")
  227.  ;; Don't store authinfo in plain text!
  228.  auth-sources (list (expand-file-name "authinfo.gpg" minotaur-etc-dir)
  229.                     "~/.authinfo.gpg")
  230.  ;; Don't litter `minotaur-emacs-dir'
  231.  abbrev-file-name             (concat minotaur-local-dir "abbrev.el")
  232.  async-byte-compile-log-file  (concat minotaur-etc-dir "async-bytecomp.log")
  233.  auto-save-file-name-transformers (concat minotaur-cache-dir "auto-save-list/")
  234.  auto-save-list-file-name     (concat minotaur-cache-dir "autosave")
  235.  backup-directory-alist       (list (cons "." (concat minotaur-cache-dir "backup/")))
  236.  desktop-dirname              (concat minotaur-etc-dir "desktop")
  237.  desktop-base-file-name       "autosave"
  238.  desktop-base-lock-name       "autosave-lock"
  239.  pcache-directory             (concat minotaur-cache-dir "pcache/")
  240.  request-storage-directory    (concat minotaur-cache-dir "request")
  241.  server-auth-dir              (concat minotaur-cache-dir "server/")
  242.  shared-game-score-directory  (concat minotaur-etc-dir "shared-game-score/")
  243.  tramp-auto-save-directory    (concat minotaur-cache-dir "tramp-auto-save/")
  244.  tramp-backup-directory-alist backup-directory-alist
  245.  tramp-persistency-file-name  (concat minotaur-cache-dir "tramp-persistency.el")
  246.  url-cache-directory          (concat minotaur-cache-dir "url/")
  247.  url-configuration-directory  (concat minotaur-etc-dir "url/")
  248.  gamegrid-user-score-file-directory (concat minotaur-etc-dir "games/"))
  249.  
  250. (autoload 'zap-up-to-char "misc"
  251.   "Kill up to, but not including ARGth occurrence of CHAR." t)
  252.  
  253. (provide 'init-defaults)
  254. ;;; init-defaults.el ends here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement