Emacs: Refactor basics/*.
This commit is contained in:
parent
db84b0f02e
commit
0f0c3e68c8
|
@ -1,6 +1,6 @@
|
|||
;;; appearance.el --- Configure appearance. -*- lexical-binding: t; -*-
|
||||
|
||||
;; Time-stamp: <2020-03-08T10:50:44+0100>
|
||||
;; Time-stamp: <2020-03-10T14:32:14+0100>
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; buffers.el --- Default settings for buffers. -*- lexical-binding: t; -*-
|
||||
|
||||
;; Time-stamp: <2020-03-03T04:05:28+0100>
|
||||
;; Time-stamp: <2020-03-10T14:01:00+0100>
|
||||
|
||||
;;; Commentary:
|
||||
;; * Setup scratch buffer.
|
||||
|
@ -12,110 +12,89 @@
|
|||
|
||||
(use-package emacs
|
||||
:ensure nil
|
||||
:custom ((initial-scratch-message nil) ; Make scratch buffer empty,
|
||||
(initial-major-mode 'gfm-mode)) ; and select mode.
|
||||
:config (progn
|
||||
(defvar my/skippable-buffers '("^\\*" "^magit[:-]")
|
||||
"Buffer names ignored by `next-buffer' and `previous-buffer'.")
|
||||
(defvar my/never-skippable-buffers
|
||||
'("^\\*scratch\\*$" "^\\*Easy-hugo\\*$")
|
||||
"Buffer names never ignored by `next-buffer' and `previous-buffer'.")
|
||||
(defun my/buffer-predicate (buffer)
|
||||
"Return nil if buffer-name matches expression in `my/skippable-buffers'."
|
||||
(catch 'return
|
||||
;; Return t if buffer-name is on never-skippable list.
|
||||
(dolist (expression my/never-skippable-buffers)
|
||||
(if (string-match expression (buffer-name buffer))
|
||||
(throw 'return t)))
|
||||
;; Return nil if buffer-name is on skippable list.
|
||||
(dolist (expression my/skippable-buffers)
|
||||
(if (string-match expression (buffer-name buffer))
|
||||
(throw 'return nil)))
|
||||
t))
|
||||
(set-frame-parameter nil 'buffer-predicate 'my/buffer-predicate)
|
||||
|
||||
:custom
|
||||
(initial-scratch-message nil) ; Make scratch buffer empty,
|
||||
(initial-major-mode 'gfm-mode) ; and select mode.
|
||||
(defun my/truncate-lines ()
|
||||
"Truncate lines in local buffer instead of wrapping them."
|
||||
(setq-local truncate-lines t)))
|
||||
:bind (("M-<left>" . previous-buffer)
|
||||
("M-<right>" . next-buffer))
|
||||
:hook ((prog-mode . my/truncate-lines)
|
||||
(conf-mode . my/truncate-lines)))
|
||||
|
||||
:config
|
||||
(defvar my/skippable-buffers '("^\\*" "^magit[:-]")
|
||||
"Buffer names ignored by `next-buffer' and `previous-buffer'.")
|
||||
(defvar my/never-skippable-buffers '("^\\*scratch\\*$" "^\\*Easy-hugo\\*$")
|
||||
"Buffer names never ignored by `next-buffer' and `previous-buffer'.")
|
||||
|
||||
(defun my/buffer-predicate (buffer)
|
||||
"Returns nil if buffer-name matches expression in `my/skippable-buffers'."
|
||||
(catch 'return
|
||||
;; Return t if buffer-name is on never-skippable list.
|
||||
(dolist (expression my/never-skippable-buffers)
|
||||
(if (string-match expression (buffer-name buffer))
|
||||
(throw 'return t)
|
||||
))
|
||||
;; Return nil if buffer-name is on skippable list.
|
||||
(dolist (expression my/skippable-buffers)
|
||||
(if (string-match expression (buffer-name buffer))
|
||||
(throw 'return nil)
|
||||
))
|
||||
t))
|
||||
|
||||
(set-frame-parameter nil 'buffer-predicate 'my/buffer-predicate)
|
||||
|
||||
(defun my/truncate-lines ()
|
||||
"Truncate lines instead of wrapping them."
|
||||
(setq-local truncate-lines t))
|
||||
|
||||
:bind
|
||||
;; Switch buffers.
|
||||
("M-<left>" . previous-buffer)
|
||||
("M-<right>" . next-buffer)
|
||||
|
||||
:hook
|
||||
(prog-mode . my/truncate-lines)
|
||||
(conf-mode . my/truncate-lines)
|
||||
)
|
||||
|
||||
;; Show and select buffers.
|
||||
;; Show and select buffers. Minimal interface for recovery situations.
|
||||
(use-package bs
|
||||
:bind
|
||||
("C-x C-b" . bs-show)
|
||||
)
|
||||
:bind ("C-x C-b" . bs-show))
|
||||
|
||||
;; Delete old buffers.
|
||||
;; https://www.emacswiki.org/emacs/CleanBufferList
|
||||
(use-package midnight
|
||||
:defer 10
|
||||
:init (setq midnight-delay 30 ; 30 seconds after “midnight”.
|
||||
midnight-period (* 2 60 60)) ; Clean every 2 hours.
|
||||
:custom ((clean-buffer-list-delay-general 1) ; Clean normal bufs after 1d,
|
||||
(clean-buffer-list-delay-special (* 30 60))) ; special after 30m.
|
||||
:config (progn
|
||||
(setq clean-buffer-list-kill-regexps ; Add these to special buffers.
|
||||
(nconc clean-buffer-list-kill-regexps
|
||||
'("^magit-?.*:"
|
||||
"\\.log$"
|
||||
"^\\*rdm\\*$"
|
||||
"^\\*Backtrace\\*$"
|
||||
"^Pfuture-Callback"
|
||||
)))
|
||||
(midnight-mode t)))
|
||||
|
||||
:init
|
||||
(setq midnight-delay 30 ; 30 seconds after “midnight”.
|
||||
midnight-period (* 2 60 60)) ; Clean every 2 hours.
|
||||
|
||||
:custom
|
||||
(clean-buffer-list-delay-general 1) ; Clean normal bufs after 1d.
|
||||
(clean-buffer-list-delay-special (* 30 60)) ; Clean special bufs after 30m.
|
||||
|
||||
:config
|
||||
(setq clean-buffer-list-kill-regexps ; Add these to special buffers.
|
||||
(nconc clean-buffer-list-kill-regexps
|
||||
'("^magit-?.*:"
|
||||
"\\.log$"
|
||||
"^\\*rdm\\*$"
|
||||
"^\\*Backtrace\\*$"
|
||||
"^Pfuture-Callback"
|
||||
)))
|
||||
(midnight-mode t)
|
||||
)
|
||||
|
||||
;; Dedicate windows to “purposes”.
|
||||
(use-package window-purpose
|
||||
:pin melpa ; We need > 1.7 <https://github.com/bmag/emacs-purpose/issues/158>
|
||||
:defer nil
|
||||
:config (progn
|
||||
(purpose-mode)
|
||||
(add-to-list 'purpose-user-mode-purposes '(c++-mode . cpp))
|
||||
(add-to-list 'purpose-user-mode-purposes '(qml-mode . cpp))
|
||||
(add-to-list 'purpose-user-mode-purposes '(emacs-lisp-mode . elisp))
|
||||
(add-to-list 'purpose-user-mode-purposes '(ebuild-mode . ebuild))
|
||||
(add-to-list 'purpose-user-mode-purposes '(adoc-mode . adoc))
|
||||
(add-to-list 'purpose-user-mode-purposes '(markdown-mode . md))
|
||||
(add-to-list 'purpose-user-mode-purposes '(gfm-mode . md))
|
||||
(add-to-list 'purpose-user-mode-purposes '(Man-mode . help-buf))
|
||||
(add-to-list 'purpose-user-mode-purposes '(help-mode . help-buf))
|
||||
(add-to-list 'purpose-user-mode-purposes '(info-mode . help-buf))
|
||||
(add-to-list 'purpose-user-mode-purposes
|
||||
'(compilation-mode . compile))
|
||||
|
||||
:config
|
||||
(purpose-mode)
|
||||
(add-to-list 'purpose-user-mode-purposes '(c++-mode . cpp))
|
||||
(add-to-list 'purpose-user-mode-purposes '(qml-mode . cpp))
|
||||
(add-to-list 'purpose-user-mode-purposes '(emacs-lisp-mode . elisp))
|
||||
(add-to-list 'purpose-user-mode-purposes '(ebuild-mode . ebuild))
|
||||
(add-to-list 'purpose-user-mode-purposes '(adoc-mode . adoc))
|
||||
(add-to-list 'purpose-user-mode-purposes '(markdown-mode . md))
|
||||
(add-to-list 'purpose-user-mode-purposes '(gfm-mode . md))
|
||||
(add-to-list 'purpose-user-mode-purposes '(Man-mode . help-buf))
|
||||
(add-to-list 'purpose-user-mode-purposes '(help-mode . help-buf))
|
||||
(add-to-list 'purpose-user-mode-purposes '(info-mode . help-buf))
|
||||
(add-to-list 'purpose-user-mode-purposes '(compilation-mode . compile))
|
||||
(add-to-list 'purpose-special-action-sequences
|
||||
'(help-buf purpose-display-reuse-window-buffer))
|
||||
(purpose-compile-user-configuration)
|
||||
|
||||
(add-to-list 'purpose-special-action-sequences
|
||||
'(help-buf purpose-display-reuse-window-buffer))
|
||||
(purpose-compile-user-configuration)
|
||||
|
||||
(require 'window-purpose-x)
|
||||
(purpose-x-magit-single-on) ; All Magit buffers have the same purpose.
|
||||
(purpose-x-kill-setup) ; Replace killed buffers with same purpose.
|
||||
|
||||
:bind
|
||||
("<f2>" . purpose-toggle-window-purpose-dedicated)
|
||||
("C-<f2>" . purpose-toggle-window-buffer-dedicated)
|
||||
("M-<f2>" . purpose-load-window-layout)
|
||||
)
|
||||
(require 'window-purpose-x)
|
||||
;; Assign all Magit buffers the same purpose.
|
||||
(purpose-x-magit-single-on)
|
||||
(purpose-x-kill-setup)) ; Replace killed buffers with same purpose.
|
||||
:bind (("<f2>" . purpose-toggle-window-purpose-dedicated)
|
||||
("C-<f2>" . purpose-toggle-window-buffer-dedicated)
|
||||
("M-<f2>" . purpose-load-window-layout)))
|
||||
|
||||
;; Highlight which buffer is active by dimming the others.
|
||||
(use-package dimmer
|
||||
|
@ -123,8 +102,7 @@
|
|||
:config (progn
|
||||
(dimmer-configure-which-key)
|
||||
(dimmer-configure-magit)
|
||||
(dimmer-mode t))
|
||||
)
|
||||
(dimmer-mode t)))
|
||||
|
||||
(provide 'basics/buffers)
|
||||
;;; buffers.el ends here
|
||||
|
|
|
@ -1,64 +1,54 @@
|
|||
;;; global-variables.el --- Set some global variables. -*- lexical-binding: t; -*-
|
||||
|
||||
;; Time-stamp: <2020-03-10T12:59:21+0100>
|
||||
;; Time-stamp: <2020-03-10T14:31:32+0100>
|
||||
|
||||
;;; Commentary:
|
||||
;; * Set `slow-computer'.
|
||||
;; * Set `LC_MESSAGES'.
|
||||
;; * Banish customizations.
|
||||
;; * Fewer startup messages.
|
||||
;; * Configure backup settings.
|
||||
;; * Set username and email-address.
|
||||
;; * Set up authentication sources
|
||||
;; * Set `LC_MESSAGES'.
|
||||
;; * Set `slow-computer'.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defvar slow-computer nil)
|
||||
(if (member (system-name) '("steuerbeamter" "azimuth" "localhost"))
|
||||
(setq slow-computer t)) ; localhost is schnibble
|
||||
|
||||
;; Show manpages and error messages from compilers in English.
|
||||
(setenv "LC_MESSAGES" "en_US.utf8")
|
||||
|
||||
(use-package emacs
|
||||
:ensure nil
|
||||
:diminish abbrev-mode
|
||||
:diminish auto-fill-function
|
||||
|
||||
:init
|
||||
;; Banish customizations to another file.
|
||||
(setq custom-file (concat user-emacs-directory "custom.el"))
|
||||
:init (setq custom-file (concat user-emacs-directory "custom.el"))
|
||||
:custom ((inhibit-startup-screen t)
|
||||
(inhibit-startup-echo-area-message t)
|
||||
(backup-directory-alist ; Save backups in ~/.emacs.d/backups/.
|
||||
`(("." . ,(concat user-emacs-directory "backups"))))
|
||||
(delete-old-versions t) ; Delete old backups.
|
||||
(kept-new-versions 6) ; Keep 6 newest backups.
|
||||
(backup-by-copying t) ; Copy to backup folder.
|
||||
(version-control t) ; Append version numbers to file names.
|
||||
(auto-save-file-name-transforms ; Save auto-saves in backup dir.
|
||||
`((".*" ,(concat user-emacs-directory "backups/") t)))
|
||||
(create-lockfiles nil) ; Don't create lockfiles (.#<file>).
|
||||
(user-full-name "tastytea")
|
||||
(user-mail-address "tastytea@tastytea.de")
|
||||
(recentf-max-saved-items 200) ; Number of buffers to keep in history.
|
||||
(auth-sources ; Preference of authentication sources.
|
||||
'("~/.authinfo.gpg" "~/.authinfo" "~/.netrc"))
|
||||
(auth-source-gpg-encrypt-to ; Encrypt to these users.
|
||||
(cons (symbol-value 'user-mail-address) '())))
|
||||
|
||||
:custom
|
||||
(inhibit-startup-screen t)
|
||||
(inhibit-startup-echo-area-message t)
|
||||
|
||||
(backup-directory-alist ; Save backups in ~/.emacs.d/backups/.
|
||||
`(("." . ,(concat user-emacs-directory "backups"))))
|
||||
(delete-old-versions t) ; Delete old backups.
|
||||
(kept-new-versions 6) ; Keep 6 newest backups.
|
||||
(backup-by-copying t) ; Copy to backup folder.
|
||||
(version-control t) ; Append version numbers to file names.
|
||||
(auto-save-file-name-transforms ; Save auto-saves in ~/.emacs.d/backups/.
|
||||
`((".*" ,(concat user-emacs-directory "backups/") t)))
|
||||
(create-lockfiles nil) ; Don't create lockfiles (.#<file>).
|
||||
|
||||
(user-full-name "tastytea")
|
||||
(user-mail-address "tastytea@tastytea.de")
|
||||
|
||||
(recentf-max-saved-items 200) ; Keep this number of buffers in history.
|
||||
|
||||
;; Preference of authentication sources.
|
||||
(auth-sources '("~/.authinfo.gpg" "~/.authinfo" "~/.netrc"))
|
||||
;; Encrypt to these users.
|
||||
(auth-source-gpg-encrypt-to (cons (symbol-value 'user-mail-address) '()))
|
||||
|
||||
:config
|
||||
;; Amount of data which is read from a process. LSP responses are large.
|
||||
(setq read-process-output-max (* 1024 1024))
|
||||
(defalias 'yes-or-no-p 'y-or-n-p) ; Just type y/n instead of yes/no.
|
||||
(savehist-mode t) ; Save minibuffer history.
|
||||
(global-auto-revert-mode t)) ; Auto-revert file if changed on disk.
|
||||
:config (progn
|
||||
;; read more data per chunk. LSP responses are large.
|
||||
(setq read-process-output-max (* 1024 1024))
|
||||
(defalias 'yes-or-no-p 'y-or-n-p) ; Just type y/n instead of yes/no.
|
||||
(savehist-mode t) ; Save minibuffer history.
|
||||
(global-auto-revert-mode t) ; Auto-revert file if changed on disk.
|
||||
;; Show manpages and error messages from compilers in English.
|
||||
(setenv "LC_MESSAGES" "en_US.utf8")
|
||||
(defvar slow-computer nil) ; Slow computers load fewer packages.
|
||||
(if (member (system-name) '("steuerbeamter" "azimuth" "localhost"))
|
||||
(setq slow-computer t)))) ; localhost is schnibble.
|
||||
|
||||
(provide 'basics/global-variables)
|
||||
;;; global-variables.el ends here
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; input.el --- Configure behaviour of input devices. -*- lexical-binding: t; -*-
|
||||
|
||||
;; Time-stamp: <2020-02-11T17:46:36+0100>
|
||||
;; Time-stamp: <2020-03-10T13:42:34+0100>
|
||||
|
||||
;;; Commentary:
|
||||
;; * Setup mouse & keyboard behaviour.
|
||||
|
@ -10,102 +10,82 @@
|
|||
|
||||
(use-package emacs
|
||||
:ensure nil
|
||||
|
||||
:custom
|
||||
(mouse-wheel-scroll-amount '(1 ((shift) . 1))) ; Scroll 1 line at a time.
|
||||
;; Paste text where the cursor is, not where the mouse is.
|
||||
(mouse-yank-at-point t)
|
||||
;; Reduce scroll lag significantly. <https://emacs.stackexchange.com/a/28746>
|
||||
(auto-window-vscroll nil)
|
||||
|
||||
:config
|
||||
(delete-selection-mode t) ; Delete selection when you start to write.
|
||||
|
||||
;; kill-region (cut) and kill-ring-save (copy) act on the current line if no
|
||||
;; text is visually selected.
|
||||
;; <https://www.emacswiki.org/emacs/WholeLineOrRegion>
|
||||
(put 'kill-ring-save 'interactive-form
|
||||
'(interactive
|
||||
(if (use-region-p)
|
||||
(list (region-beginning) (region-end))
|
||||
(list (line-beginning-position) (line-beginning-position 2)))))
|
||||
(put 'kill-region 'interactive-form
|
||||
'(interactive
|
||||
(if (use-region-p)
|
||||
(list (region-beginning) (region-end))
|
||||
(list (line-beginning-position) (line-beginning-position 2)))))
|
||||
)
|
||||
:custom ((mouse-wheel-scroll-amount '(1 ((shift) . 1))) ; Scroll 1 line.
|
||||
;; Paste text where the cursor is, not where the mouse is.
|
||||
(mouse-yank-at-point t)
|
||||
;; Reduce scroll lag. <https://emacs.stackexchange.com/a/28746>
|
||||
(auto-window-vscroll nil))
|
||||
:config (progn
|
||||
(delete-selection-mode t) ; Delete selection when you start to write.
|
||||
;; kill-region (cut) and kill-ring-save (copy) act on the current
|
||||
;; line if no text is visually selected.
|
||||
;; <https://www.emacswiki.org/emacs/WholeLineOrRegion>
|
||||
(put 'kill-ring-save 'interactive-form
|
||||
'(interactive
|
||||
(if (use-region-p)
|
||||
(list (region-beginning) (region-end))
|
||||
(list (line-beginning-position)
|
||||
(line-beginning-position 2)))))
|
||||
(put 'kill-region 'interactive-form
|
||||
'(interactive
|
||||
(if (use-region-p)
|
||||
(list (region-beginning) (region-end))
|
||||
(list (line-beginning-position)
|
||||
(line-beginning-position 2)))))))
|
||||
|
||||
(use-package bind-key
|
||||
:functions (my/delete-word my/backward-delete-word)
|
||||
:config (progn
|
||||
(defun my/delete-word (arg)
|
||||
"Delete characters forward until encountering the end of a word.
|
||||
With ARG, do it that many times."
|
||||
(interactive "p")
|
||||
(if (use-region-p)
|
||||
(delete-region (region-beginning) (region-end))
|
||||
(delete-region (point) (progn (forward-word arg) (point)))))
|
||||
|
||||
:config
|
||||
(defun my/delete-word (arg)
|
||||
"Delete characters forward until encountering the end of a word.
|
||||
With argument, do this that many times."
|
||||
(interactive "p")
|
||||
(if (use-region-p)
|
||||
(delete-region (region-beginning) (region-end))
|
||||
(delete-region (point) (progn (forward-word arg) (point)))))
|
||||
|
||||
(defun my/backward-delete-word (arg)
|
||||
"Delete characters backward until encountering the end of a word.
|
||||
With argument, do this that many times."
|
||||
(interactive "p")
|
||||
(my/delete-word (- arg)))
|
||||
|
||||
(bind-keys
|
||||
;; Reduce whitespace around cursor to 0 or 1, according to context.
|
||||
("C-S-<delete>" . fixup-whitespace)
|
||||
;; Scroll without moving the cursor.
|
||||
("M-<down>" . scroll-up-line)
|
||||
("M-<up>" . scroll-down-line)
|
||||
;; Delete words without storing them in the kill buffer.
|
||||
("C-<delete>" . my/delete-word)
|
||||
("C-<backspace>" . my/backward-delete-word)
|
||||
("C-q" . delete-frame)
|
||||
;; Insert next character with control characters. Like C-S-v in the shell.
|
||||
("C-S-v" . quoted-insert)
|
||||
;; C-x C-f will be replaced with projectile-find-file.
|
||||
("C-x C-S-f" . find-file)
|
||||
)
|
||||
)
|
||||
(defun my/backward-delete-word (arg)
|
||||
"Delete characters backward until encountering the end of a word.
|
||||
With ARG, do it that many times."
|
||||
(interactive "p")
|
||||
(my/delete-word (- arg)))
|
||||
(bind-keys
|
||||
;; Reduce whitespace around cursor to 0 or 1, according to context.
|
||||
("C-S-<delete>" . fixup-whitespace)
|
||||
;; Scroll without moving the cursor.
|
||||
("M-<down>" . scroll-up-line)
|
||||
("M-<up>" . scroll-down-line)
|
||||
;; Delete words without storing them in the kill buffer.
|
||||
("C-<delete>" . my/delete-word)
|
||||
("C-<backspace>" . my/backward-delete-word)
|
||||
("C-q" . delete-frame)
|
||||
;; Insert next character with control characters.
|
||||
("C-S-v" . quoted-insert)
|
||||
;; C-x C-f will be replaced with projectile-find-file.
|
||||
("C-x C-S-f" . find-file))))
|
||||
|
||||
; Multiple cursors.
|
||||
(use-package multiple-cursors
|
||||
:init
|
||||
(global-unset-key (kbd "M-<down-mouse-1>"))
|
||||
|
||||
:bind
|
||||
("C-x M-m" . mc/edit-lines)
|
||||
("M-<mouse-1>" . mc/add-cursor-on-click)
|
||||
)
|
||||
:init (global-unset-key (kbd "M-<down-mouse-1>"))
|
||||
:bind (("C-x M-m" . mc/edit-lines)
|
||||
("M-<mouse-1>" . mc/add-cursor-on-click)))
|
||||
|
||||
;; Edit multiple regions in the same way simultaneously.
|
||||
(use-package iedit
|
||||
:bind
|
||||
("C-;" . iedit-mode)
|
||||
)
|
||||
:bind ("C-;" . iedit-mode))
|
||||
|
||||
;; Display available keybindings.
|
||||
(use-package which-key
|
||||
:diminish which-key-mode
|
||||
|
||||
:config
|
||||
(which-key-mode)
|
||||
)
|
||||
:config (which-key-mode))
|
||||
|
||||
;; Navigate between windows with alt+arrows.
|
||||
(use-package windmove
|
||||
:config
|
||||
(windmove-default-keybindings '(meta shift))
|
||||
|
||||
:bind ; Needed for Emacs-over-SSH. 🤷
|
||||
([(meta shift left)] . windmove-left)
|
||||
([(meta shift right)] . windmove-right)
|
||||
([(meta shift up)] . windmove-up)
|
||||
([(meta shift down)] . windmove-down)
|
||||
)
|
||||
:config (windmove-default-keybindings '(meta shift))
|
||||
:bind (([(meta shift left)] . windmove-left) ; Needed for Emacs-over-SSH. 🤷
|
||||
([(meta shift right)] . windmove-right)
|
||||
([(meta shift up)] . windmove-up)
|
||||
([(meta shift down)] . windmove-down)))
|
||||
|
||||
(provide 'basics/input)
|
||||
;;; input.el ends here
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
;;; misc.el --- Basic things that do not fit any other category. -*- lexical-binding: t; -*-
|
||||
|
||||
;; Time-stamp: <2020-02-11T17:33:45+0100>
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; Hide minor-mode from modeline.
|
||||
(use-package diminish)
|
||||
|
||||
(provide 'basics/misc)
|
||||
;;; misc.el ends here
|
|
@ -1,6 +1,6 @@
|
|||
;;; package-management.el --- Initialize package management. -*- lexical-binding: t; -*-
|
||||
|
||||
;; Time-stamp: <2020-03-03T03:45:02+0100>
|
||||
;; Time-stamp: <2020-03-10T13:33:32+0100>
|
||||
|
||||
;;; Commentary:
|
||||
;; * Set up package sources and their priorities.
|
||||
|
@ -41,7 +41,7 @@
|
|||
;; Always install packages if they are not present.
|
||||
(use-package use-package
|
||||
:custom (use-package-always-ensure t)
|
||||
)
|
||||
:config (use-package diminish)) ; Hide minor-mode from modeline.
|
||||
|
||||
;; Autocompile files on load.
|
||||
(use-package auto-compile
|
||||
|
@ -59,16 +59,14 @@
|
|||
|
||||
;; Only update keyring if atime (mtime with relatime) is > 1 week ago.
|
||||
(if (> (- (time-to-seconds) my/keyring-last-access) (* 60 60 24 7))
|
||||
(gnu-elpa-keyring-update))
|
||||
)
|
||||
(gnu-elpa-keyring-update)))
|
||||
|
||||
;; Update packages if at least 7 days have passed.
|
||||
(use-package auto-package-update
|
||||
:custom ((auto-package-update-delete-old-versions t)
|
||||
(auto-package-update-interval 7)
|
||||
(auto-package-update-hide-results nil))
|
||||
:config (auto-package-update-maybe)
|
||||
)
|
||||
:config (auto-package-update-maybe))
|
||||
|
||||
;; Install Emacs packages directly from source.
|
||||
(use-package quelpa
|
||||
|
@ -78,14 +76,13 @@
|
|||
(quelpa-checkout-melpa-p nil)
|
||||
(quelpa-upgrade-interval 7))
|
||||
|
||||
:hook (after-init . quelpa-upgrade-all-maybe)
|
||||
)
|
||||
:hook (after-init . quelpa-upgrade-all-maybe))
|
||||
|
||||
;; Use :quelpa in use-package configurations.
|
||||
(use-package quelpa-use-package
|
||||
:after (use-package quelpa)
|
||||
; Override `use-package-always-ensure' for quelpa-packages.
|
||||
:config (quelpa-use-package-activate-advice)
|
||||
)
|
||||
:config (quelpa-use-package-activate-advice))
|
||||
|
||||
(provide 'basics/package-management)
|
||||
;;; package-management.el ends here
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; ui.el --- Configure user interfaces. -*- lexical-binding: t; -*-
|
||||
|
||||
;; Time-stamp: <2020-03-10T12:20:03+0100>
|
||||
;; Time-stamp: <2020-03-10T14:08:16+0100>
|
||||
|
||||
;;; Commentary:
|
||||
;; * treemacs
|
||||
|
@ -13,126 +13,81 @@
|
|||
:pin melpa ; We need > 2.6 for lsp-treemacs.
|
||||
:demand t
|
||||
:after (display-line-numbers)
|
||||
|
||||
:custom
|
||||
(treemacs-project-follow-cleanup t) ; Collapse projects when leaving.
|
||||
(treemacs-silent-refresh t) ; No log message on refresh.
|
||||
|
||||
:custom ((treemacs-project-follow-cleanup t) ; Collapse projects when leaving.
|
||||
(treemacs-silent-refresh t)) ; No log message on refresh.
|
||||
;; Remove after > 2.6 is out (treemacs-magit uses the old variable).
|
||||
:config (define-obsolete-variable-alias
|
||||
'treemacs--buffer-storage 'treemacs-buffer-storage)
|
||||
|
||||
:bind
|
||||
("<f8>" . treemacs-select-window) ; Focus treemacs.
|
||||
("C-<f8>" . treemacs) ; Toggle treemacs.
|
||||
("M-<f8>" . treemacs-add-and-display-current-project) ; Add current project.
|
||||
(:map treemacs-mode-map
|
||||
("<mouse-1>" . treemacs-single-click-expand-action))
|
||||
|
||||
:hook
|
||||
(treemacs-mode . my/disable-line-numbers)
|
||||
)
|
||||
:bind (("<f8>" . treemacs-select-window) ; Focus treemacs.
|
||||
("C-<f8>" . treemacs) ; Toggle treemacs.
|
||||
("M-<f8>" . treemacs-add-and-display-current-project)
|
||||
(:map treemacs-mode-map
|
||||
("<mouse-1>" . treemacs-single-click-expand-action)))
|
||||
:hook (treemacs-mode . my/disable-line-numbers))
|
||||
|
||||
(use-package treemacs-projectile
|
||||
:after (treemacs projectile)
|
||||
)
|
||||
:after (treemacs projectile))
|
||||
|
||||
(use-package treemacs-magit
|
||||
:after (treemacs magit)
|
||||
)
|
||||
:after (treemacs magit))
|
||||
|
||||
;; Completion in many Emacs commands.
|
||||
(use-package ivy
|
||||
:demand t
|
||||
:diminish ivy-mode
|
||||
|
||||
:custom
|
||||
(ivy-use-virtual-buffers t)
|
||||
(ivy-count-format "[%d/%d] ")
|
||||
(ivy-wrap t)
|
||||
|
||||
:config
|
||||
(ivy-mode 1)
|
||||
|
||||
:bind
|
||||
("C-c C-r" . ivy-resume)
|
||||
(:map ivy-minibuffer-map
|
||||
("M-<up>" . ivy-previous-history-element)
|
||||
("M-<down>" . ivy-next-history-element)
|
||||
("S-<return>" . ivy-immediate-done) ; Ignore completion.
|
||||
)
|
||||
)
|
||||
:custom ((ivy-use-virtual-buffers t)
|
||||
(ivy-count-format "[%d/%d] ")
|
||||
(ivy-wrap t))
|
||||
:config (ivy-mode 1)
|
||||
:bind (("C-c C-r" . ivy-resume)
|
||||
(:map ivy-minibuffer-map
|
||||
("M-<up>" . ivy-previous-history-element)
|
||||
("M-<down>" . ivy-next-history-element)
|
||||
("S-<return>" . ivy-immediate-done)))) ; Ignore completion.
|
||||
|
||||
;; Extensions for ivy
|
||||
(use-package counsel
|
||||
:after (ivy)
|
||||
:demand t
|
||||
|
||||
:bind
|
||||
("C-x C-f" . counsel-find-file)
|
||||
("M-x" . counsel-M-x)
|
||||
)
|
||||
:bind (("C-x C-f" . counsel-find-file)
|
||||
("M-x" . counsel-M-x)))
|
||||
|
||||
;; Use icons in ivy.
|
||||
(use-package all-the-icons-ivy
|
||||
:after (all-the-icons counsel)
|
||||
|
||||
:config
|
||||
(all-the-icons-ivy-setup)
|
||||
)
|
||||
:config (all-the-icons-ivy-setup))
|
||||
|
||||
;; More information in ivy mini-buffers.
|
||||
(use-package ivy-rich
|
||||
;; all-the-icons-ivy would override the ivy-rich switch-buffer improvements.
|
||||
:after (all-the-icons-ivy counsel)
|
||||
:config (ivy-rich-mode 1)
|
||||
)
|
||||
:config (ivy-rich-mode 1))
|
||||
|
||||
;; Use icons in ivy-rich.
|
||||
(use-package all-the-icons-ivy-rich
|
||||
:after (all-the-icons ivy-rich)
|
||||
:config (all-the-icons-ivy-rich-mode 1)
|
||||
)
|
||||
:config (all-the-icons-ivy-rich-mode 1))
|
||||
|
||||
(use-package ivy-purpose
|
||||
:after (window-purpose)
|
||||
|
||||
:config
|
||||
(ivy-purpose-setup)
|
||||
|
||||
:bind
|
||||
(:map purpose-mode-map
|
||||
("C-x b" . ivy-switch-buffer)
|
||||
;; ("C-x b" . ivy-purpose-switch-buffer-without-purpose)
|
||||
)
|
||||
)
|
||||
:config (ivy-purpose-setup)
|
||||
:bind (:map purpose-mode-map
|
||||
("C-x b" . ivy-switch-buffer)))
|
||||
|
||||
(use-package counsel-projectile
|
||||
:after (projectile)
|
||||
:custom ((counsel-projectile-mode t)
|
||||
(projectile-switch-project-action 'my/switch-project))
|
||||
:config (progn
|
||||
(defun my/counsel-projectile-switch-project-action (project)
|
||||
"Call `my/switch-project'."
|
||||
(let ((projectile-switch-project-action 'my/switch-project))
|
||||
(counsel-projectile-switch-project-by-name project)))
|
||||
|
||||
:custom
|
||||
(counsel-projectile-mode t) ; Turn on projectile-mode and enable keybindings.
|
||||
(projectile-switch-project-action 'my/switch-project)
|
||||
|
||||
:config
|
||||
(defun my/counsel-projectile-switch-project-action (project)
|
||||
"Call `my/switch-project'."
|
||||
(let ((projectile-switch-project-action 'my/switch-project))
|
||||
(counsel-projectile-switch-project-by-name project)))
|
||||
|
||||
(counsel-projectile-modify-action
|
||||
'counsel-projectile-switch-project-action
|
||||
'((add ("Y" my/counsel-projectile-switch-project-action
|
||||
"open project in treemacs") 1)))
|
||||
)
|
||||
|
||||
;; Switch between named persistent window configurations.
|
||||
(when (>= emacs-major-version 27)
|
||||
(use-package tab-bar
|
||||
:bind
|
||||
("C-<prior>" . tab-bar-switch-to-prev-tab)
|
||||
("C-<next>" . tab-bar-switch-to-next-tab)
|
||||
))
|
||||
(counsel-projectile-modify-action
|
||||
'counsel-projectile-switch-project-action
|
||||
'((add ("Y" my/counsel-projectile-switch-project-action
|
||||
"open project in treemacs") 1)))))
|
||||
|
||||
;; Shows tabs of all visible buffers per window.
|
||||
(when (>= emacs-major-version 27)
|
||||
|
@ -145,8 +100,7 @@
|
|||
:background "grey10"
|
||||
:foreground "grey70"))))
|
||||
(tab-line-highlight ((t (:inherit tab-line-tab-current
|
||||
:foreground "white"))))
|
||||
))
|
||||
:foreground "white"))))))
|
||||
|
||||
(provide 'basics/ui)
|
||||
;;; ui.el ends here
|
||||
|
|
14
init.el
14
init.el
|
@ -1,6 +1,6 @@
|
|||
;;; init.el --- tastytea's Emacs init file. -*- lexical-binding: t; -*-
|
||||
|
||||
;; Time-stamp: <2020-02-27T05:16:37+0100>
|
||||
;; Time-stamp: <2020-03-10T14:31:51+0100>
|
||||
|
||||
;;; Commentary:
|
||||
;; Requires at least Emacs 26. Most of it will probably work with Emacs 24 and
|
||||
|
@ -8,20 +8,14 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
;; Set garbage collection threshold to 20 MiB to speed up init.
|
||||
(setq gc-cons-threshold (* 20 1024 1024))
|
||||
|
||||
;; Add path to init files.
|
||||
(push (concat user-emacs-directory "init.d") load-path)
|
||||
|
||||
(require 'basics/package-management)
|
||||
|
||||
(require 'basics/global-variables)
|
||||
|
||||
;; Set garbage collection threshold to 100 MiB (or 20 MiB) to speed up init.
|
||||
;; It is reset at the end of the file.
|
||||
(if slow-computer
|
||||
(setq gc-cons-threshold (* 20 1024 1024))
|
||||
(setq gc-cons-threshold (* 100 1024 1024)))
|
||||
|
||||
(require 'basics/misc)
|
||||
(require 'basics/input)
|
||||
(require 'basics/buffers)
|
||||
(require 'basics/appearance)
|
||||
|
|
Loading…
Reference in New Issue
Block a user