Emacs: Clean up main settings.

master
Pierre Neidhardt 2019-11-02 16:41:17 +01:00
parent a4de491950
commit 6456632d18
1 changed files with 56 additions and 99 deletions

View File

@ -12,8 +12,50 @@
;;; Force on using the minibuffer instead.
(setq use-dialog-box nil)
;;; Timeout before echoing the prefix of an unfinished keystroke.
(setq echo-keystrokes 0.5)
(setq
recentf-max-saved-items 100
disabled-command-function nil ; Enable all disabled commands.
scroll-error-top-bottom t ; Alternative scrolling
kill-whole-line t ; Kill whole line including \n.
scroll-step 1 ; Line by line scrolling
calendar-week-start-day 1
calendar-date-style 'iso
comint-prompt-read-only t
woman-fill-column fill-column
abbrev-file-name (expand-file-name "abbrev_defs" "~/personal")
frame-title-format (concat "%b" (unless (daemonp) " [serverless]"))
delete-by-moving-to-trash t
uniquify-buffer-name-style 'forward
vc-follow-symlinks t ; Disable prompt (but leave warning) on git symlink.
sort-fold-case t
;;; Clipboard and primary selection.
select-enable-primary t
save-interprogram-paste-before-kill t
;;; Save all visited URLs.
url-history-track t
url-history-file (expand-file-name "url/history" user-emacs-directory)
;; Timeout before echoing the prefix of an unfinished keystroke.
echo-keystrokes 0.5
;; Disable autosave features.
auto-save-default nil
auto-save-list-file-prefix nil
;; Place backup files in specific directory.
backup-directory-alist
`(("." . ,(expand-file-name "backups" user-emacs-directory)))
;; Enforce horizontal splitting. 140 means that the window is large enough to
;; hold 2 other windows of 70 columns.
split-height-threshold nil
split-width-threshold 140
;; TODO: Ediff does not seem to auto-refine. Bug? Compare daemon and no-daemon.
ediff-window-setup-function 'ediff-setup-windows-plain
ediff-split-window-function 'split-window-horizontally)
;;; Remember last cursor position.
(save-place-mode)
@ -21,35 +63,17 @@
;;; allows to save places at a strategic moment.
(add-hook 'before-save-hook 'save-place-kill-emacs-hook)
;;; Recent files.
(setq recentf-max-saved-items 100)
(savehist-mode) ; Save M-: history.
;;; Save M-: history.
(savehist-mode)
;;; Disable autosave features.
(setq auto-save-default nil)
(setq auto-save-list-file-prefix nil)
;;; Place backup files in specific directory.
(setq backup-directory-alist
`(("." . ,(expand-file-name "backups" user-emacs-directory))))
;;; Default mode
(setq-default major-mode 'text-mode)
(setq-default major-mode 'text-mode) ; Default mode.
;;; Disable suspend key since it is useless on Emacs server.
(global-unset-key (kbd "C-z"))
(global-unset-key (kbd "C-x C-z"))
;;; Make questions less annoying.
(defalias 'yes-or-no-p 'y-or-n-p)
(defalias 'yes-or-no-p 'y-or-n-p) ; Make questions less annoying.
;;; Enable all disabled commands.
(setq disabled-command-function nil)
;;; Print buffer size in mode line.
(size-indication-mode 1)
(size-indication-mode 1) ; Print buffer size in mode line.
;;; Display defun in mode line.
;; (which-function-mode)
@ -78,20 +102,11 @@
(setq auto-revert-interval 1)
(add-hook 'auto-revert-tail-mode-hook 'ambrevar/turn-on-absolute-line-number)
;;; Alternative scrolling
(setq scroll-error-top-bottom t)
;;; Kill whole line including \n.
(setq kill-whole-line t)
;;; Indentation
(setq-default tab-width 2)
(defvaralias 'standard-indent 'tab-width)
(setq-default indent-tabs-mode t)
;;; Line by line scrolling
(setq scroll-step 1)
(setq
whitespace-style
'(face empty indentation space-after-tab space-before-tab tab-mark trailing))
@ -116,12 +131,6 @@
(when (getenv "MANWIDTH")
(setq-default fill-column (string-to-number (getenv "MANWIDTH"))))
(add-hook 'text-mode-hook 'turn-on-auto-fill)
;; (setq sentence-end-double-space nil)
;;; Enforce horizontal splitting. 140 means that the window is large enough to
;;; hold 2 other windows of 70 columns.
(setq split-height-threshold nil
split-width-threshold 140)
;;; Windmove mode
;;; By default, it allows easy window switching with Shift+arrows. I like to
@ -154,7 +163,6 @@
(executable-find browse-url-kde-program)
(executable-find browse-url-conkeror-program)
(executable-find browse-url-chrome-program)))
(setq shr-external-browser browse-url-browser-function)
(setq browse-url-browser-function '(;; TODO: Display hyperspec in other window.
("http://www.lispworks.com/reference/HyperSpec/.*" . eww-browse-url)
("file:///.*HyperSpec.*" . eww-browse-url)
@ -164,7 +172,8 @@
(setq shr-width (string-to-number (or (getenv "MANWIDTH") "80"))
;; If you're using a dark theme, and the messages are hard to read, it
;; can help to change the luminosity, e.g.:
shr-color-visible-luminance-min 80)
shr-color-visible-luminance-min 80
shr-external-browser browse-url-browser-function)
;;; Extend MIME-types support for videos.
(with-eval-after-load 'mailcap
@ -191,22 +200,15 @@
(show-paren-mode 1)
;;; By default, theres a small delay before showing a matching parenthesis. Set
;;; it to 0 to deactivate.
(setq show-paren-delay 0)
(setq show-paren-when-point-inside-paren t)
(setq show-paren-delay 0
show-paren-when-point-inside-paren t)
;;; Electric Pairs to auto-complete () [] {} "" etc. It works on regions.
;; (electric-pair-mode)
;;; Spawn terminal shortcut: WM's binding is s+<return>.
(global-set-key (kbd "C-x M-<return>") 'spawn-terminal)
;;; Calendar ISO display.
(setq calendar-week-start-day 1)
(setq calendar-date-style 'iso)
;;; Compilation bindings and conveniences.
(setq compilation-ask-about-save nil)
(setq compilation-scroll-output 'first-error)
(setq compilation-ask-about-save nil
compilation-scroll-output 'first-error)
(with-eval-after-load 'compile
;; Making `compilation-directory' local only works with `recompile'
;; and if `compile' is never used. In such a scenario,
@ -232,14 +234,6 @@
;; Do not use `recompile' since we want to change the compilation folder for the current buffer.
"<f6>" 'ambrevar/compile-last-command)
;;; REVIEW: Bug 26658 reports that cc-modes mistakenly does not make use of prog-mode-map.
;;; The following line is a suggested work-around.
;;; This should be fixed in Emacs 26.
(eval-after-load 'cc-mode '(set-keymap-parent c-mode-base-map prog-mode-map))
;;; Comint mode
(setq comint-prompt-read-only t)
;;; Desktop-mode
;;; REVIEW: `desktop-kill' should not query the user in `kill-emacs-hook'.
;;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28943
@ -255,7 +249,7 @@
(or (not (boundp 'desktop-save-mode))
(null desktop-save-mode)))
(when (< emacs-major-version 27)
;; By default, Emacs<27 prompts for unsafe variable when loading desktop
;; TODO: By default, Emacs<27 prompts for unsafe variable when loading desktop
;; which stucks the daemon. Disable this behaviour.
(defun ambrevar/enable-safe-local-variables ()
(setq enable-local-variables t))
@ -312,9 +306,6 @@
;; server-mode does not seem to have any post-start hook.
(advice-add 'server-start :after #'ambrevar/desktop-setup)
;;; Buffer names.
(setq uniquify-buffer-name-style 'forward)
;;; Skeleton settings
(when (require 'patch-skeletons nil 'noerror)
;;; Do not expand abbrevs in skeletons.
@ -324,14 +315,6 @@
"C->" 'skeleton-next-position
"C-<" 'skeleton-previous-position))
;;; Disable prompt (but leave warning) on git symlink.
(setq vc-follow-symlinks t)
;;; Clipboard and primary selection.
;; (setq select-enable-clipboard t)
(setq select-enable-primary t
save-interprogram-paste-before-kill t)
;;; Move mouse away.
(mouse-avoidance-mode 'banish)
;;; That binding is not very useful and gets in the way of C-<mouse-1>.
@ -345,27 +328,12 @@
"C-<mouse-4>" 'text-scale-increase)
(setq text-scale-mode-step 1.1)
;;; Sort
(setq sort-fold-case t)
;;; Replace not-so-useful comment-dwim binding.
(global-set-key (kbd "M-;") 'comment-line)
;;; Eldoc: Disable if too distracting.
;; (global-eldoc-mode 0)
;; (setq eldoc-idle-delay 0.1) ; Could be even more distracting.
;;; Replace `kill-buffer' binding by `kill-this-buffer'.
(global-set-key (kbd "C-x k") 'kill-this-buffer)
;;; Ediff
;;; TODO: Ediff does not seem to auto-refine. Bug? Compare daemon and no-daemon.
(setq ediff-window-setup-function 'ediff-setup-windows-plain
ediff-split-window-function 'split-window-horizontally)
;;; Trash
(setq delete-by-moving-to-trash t)
;;; Display Time World
(setq
zoneinfo-style-world-list
@ -380,9 +348,6 @@
("America/New_York" "New York")
("America/Los_Angeles" "Los Angeles")))
;;; Frame title
(setq frame-title-format (concat "%b" (unless (daemonp) " [serverless]")))
;;; Initial scratch buffer message.
(require 'functions) ; For `ambrevar/fortune-scratch-message'.
(let ((fortune (ambrevar/fortune-scratch-message)))
@ -401,19 +366,11 @@
;; edebug-test-coverage t
;; edebug-trace t)
;;; Make windowing more reactive on. This is especially true with Helm on EXWM.
;; TODO: Test if still a problem with Emacs 27.
(when (= emacs-major-version 26)
(setq x-wait-for-event-timeout nil))
(setq woman-fill-column fill-column)
;;; Save all visited URLs.
(setq url-history-track t
url-history-file (expand-file-name "url/history" user-emacs-directory))
(setq abbrev-file-name (expand-file-name "abbrev_defs" "~/personal"))
(when (require 'so-long nil 'noerror)
(global-so-long-mode 1))