add general settings
This commit is contained in:
675
settings/general-settings.el
Normal file
675
settings/general-settings.el
Normal file
@@ -0,0 +1,675 @@
|
||||
;; general-settings.el --- General settings -*- lexical-binding: t -*-
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Requirements:
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; Change "yes or no" to "y or n"
|
||||
(fset 'yes-or-no-p 'y-or-n-p)
|
||||
|
||||
;; default-frame-alist not empty
|
||||
(mapc (lambda (item)
|
||||
(add-to-list 'default-frame-alist item)
|
||||
)
|
||||
'(
|
||||
(fullscreen . maximized)
|
||||
(tool-bar-position . left)
|
||||
;;(horizontal-scroll-bars . t) ;; see gui-settings
|
||||
)
|
||||
)
|
||||
|
||||
;; transparency
|
||||
;;(set-frame-parameter (selected-frame) 'alpha '(<active> . <inactive>))
|
||||
;;(set-frame-parameter (selected-frame) 'alpha <both>)
|
||||
(set-frame-parameter (selected-frame) 'alpha '(90 . 90))
|
||||
(add-to-list 'default-frame-alist '(alpha . (90 . 90)))
|
||||
|
||||
;; recentf stuff
|
||||
(use-package recentf
|
||||
:config
|
||||
(setq
|
||||
recentf-save-file (locate-user-emacs-file ".cache/recentf" "recentf")
|
||||
recentf-max-saved-items 1000
|
||||
recentf-max-menu-items 30
|
||||
recentf-auto-cleanup 'never ;; disable before we start recentf! Set to never bc otherwise it tries to read also tramp (remote) files
|
||||
)
|
||||
(add-to-list 'recentf-exclude
|
||||
(recentf-expand-file-name user-cache-directory))
|
||||
;;(global-set-key "\C-x\ \C-r" 'recentf-open-files) ;; see completion-settings ivy counsel
|
||||
;;(run-at-time nil (* 10 60) 'recentf-save-list)
|
||||
(run-with-idle-timer (* 10 60) t 'recentf-save-list)
|
||||
(recentf-mode)
|
||||
)
|
||||
|
||||
;; by default backup files are saved in the current directory, ending with ~
|
||||
;; instead stashes them all in
|
||||
(let ((backup-dir (concat user-cache-directory "backups"))
|
||||
(auto-saves-dir (concat user-cache-directory "auto-saves/")))
|
||||
(dolist (dir (list backup-dir auto-saves-dir))
|
||||
(when (not (file-directory-p dir))
|
||||
(make-directory dir t)))
|
||||
(setq backup-directory-alist `(("." . ,backup-dir)))
|
||||
(setq backup-by-copying t)
|
||||
(setq auto-save-file-name-transforms `((".*" ,auto-saves-dir t)))
|
||||
(setq auto-save-list-file-prefix (concat auto-saves-dir ".saves-"))
|
||||
(setq tramp-backup-directory-alist `((".*" . ,backup-dir)))
|
||||
(setq tramp-auto-save-directory auto-saves-dir)
|
||||
)
|
||||
(setq-default delete-by-moving-to-trash t) ;; Delete files to trash
|
||||
|
||||
(if (fboundp 'save-place-mode)
|
||||
(save-place-mode)
|
||||
(setq save-place t)
|
||||
)
|
||||
;; Save point position between sessions
|
||||
(setq save-place-file (concat user-cache-directory "places"))
|
||||
|
||||
;; minibuffer history, e.g. M-x with amex
|
||||
(setq savehist-file (concat user-cache-directory "history"))
|
||||
(savehist-mode)
|
||||
|
||||
;;; desktop
|
||||
(require 'desktop)
|
||||
;; save session
|
||||
;;(desktop-save-mode 1)
|
||||
(setq desktop-dirname user-cache-directory)
|
||||
(setq history-length 500) ;; Since all lists will be truncated when saved, it is important to have a high default history length
|
||||
(add-to-list 'desktop-path user-cache-directory)
|
||||
(defun desktop-settings-setup ()
|
||||
"Some settings setup for 'desktop-save-mode'."
|
||||
(interactive)
|
||||
|
||||
;; At this point the desktop.el hook in after-init-hook was
|
||||
;; executed, so (desktop-read) is avoided.
|
||||
(when (not (eq (emacs-pid) (desktop-owner))) ; Check that emacs did not load a desktop yet
|
||||
;; Here we activate the desktop mode
|
||||
(desktop-save-mode 1)
|
||||
|
||||
;; Since all lists will be truncated when saved, it is important to have a high default history length
|
||||
(setq history-length 250)
|
||||
|
||||
;; Set the location to save/load default desktop
|
||||
(setq desktop-dirname user-cache-directory)
|
||||
(add-to-list 'desktop-path user-cache-directory)
|
||||
|
||||
;; The default desktop is saved always
|
||||
(setq desktop-save t)
|
||||
|
||||
;; The default desktop is loaded anyway if it is locked
|
||||
(setq desktop-load-locked-desktop t)
|
||||
|
||||
;; Make sure that even if emacs or OS crashed, emacs
|
||||
;; still have last opened files.
|
||||
(add-hook 'find-file-hook
|
||||
(lambda ()
|
||||
(run-with-timer 5 nil
|
||||
(lambda ()
|
||||
;; Reset desktop modification time so the user is not bothered
|
||||
(setq desktop-file-modtime (nth 5 (file-attributes (desktop-full-file-name))))
|
||||
(desktop-save user-emacs-directory)))))
|
||||
|
||||
;; Read default desktop
|
||||
(if (file-exists-p (concat desktop-dirname desktop-base-file-name))
|
||||
(desktop-read desktop-dirname))
|
||||
|
||||
;; Add a hook when emacs is closed to we reset the desktop
|
||||
;; modification time (in this way the user does not get a warning
|
||||
;; message about desktop modifications)
|
||||
(add-hook 'kill-emacs-hook
|
||||
(lambda ()
|
||||
;; Reset desktop modification time so the user is not bothered
|
||||
(setq desktop-file-modtime (nth 5 (file-attributes (desktop-full-file-name))))))
|
||||
)
|
||||
)
|
||||
;; (add-hook 'after-init-hook
|
||||
;; 'desktop-settings-setup
|
||||
;; (lambda ()
|
||||
;; ;; No splash screen
|
||||
;; (setq inhibit-startup-screen t)
|
||||
|
||||
;; ;; If the *scratch* buffer is the current one, then create a new
|
||||
;; ;; empty untitled buffer to hide *scratch*
|
||||
;; (if (string= (buffer-name) "*scratch*")
|
||||
;; (new-empty-buffer))
|
||||
;; )
|
||||
;; t) ;; append this hook to the tail
|
||||
|
||||
|
||||
;; auto revert buffer
|
||||
(when (fboundp 'global-auto-revert-mode)
|
||||
;; All the "reverting buffer foo" messages are _really_ distracting.
|
||||
(setq auto-revert-verbose nil)
|
||||
(global-auto-revert-mode 1)
|
||||
;; just as the docs warn, this can really make Emacs sluggish.
|
||||
(if running-on-windows
|
||||
(if (fboundp 'lwarn)
|
||||
(lwarn
|
||||
'global-auto-revert-mode
|
||||
:warning
|
||||
"`global-auto-revert-mode' is turned on. It's nifty,
|
||||
but it's REALLY SLOW when you have buffers that are visiting
|
||||
remote files. And despite its documentation, it does NOT ignore
|
||||
those files, if you're using windows, and the file name begins
|
||||
with a drive letter and a colon.")
|
||||
)
|
||||
(setq global-auto-revert-non-file-buffers t)
|
||||
)
|
||||
)
|
||||
(setq revert-without-query '(".*"))
|
||||
|
||||
(use-package uniquify
|
||||
:defer t
|
||||
:config
|
||||
(setq uniquify-buffer-name-style 'forward) ;; forward: bar/mumble/name insead of post-forward-angle-brackets: name<bar/mumble>
|
||||
)
|
||||
|
||||
;; overwrite selected text
|
||||
(delete-selection-mode t)
|
||||
|
||||
;; always use spaces, not tabs, when indenting
|
||||
(setq-default indent-tabs-mode nil)
|
||||
;; width for tabs
|
||||
(setq-default tab-width 2)
|
||||
|
||||
;; ignore case when searching
|
||||
(setq case-fold-search t)
|
||||
|
||||
;; require final newlines in files when they are saved
|
||||
(setq require-final-newline t)
|
||||
|
||||
;; don't show the startup screen
|
||||
(setq inhibit-startup-screen t)
|
||||
|
||||
;; each line of text gets one line on the screen (i.e., text will run
|
||||
;; off the right instead of wrapping around onto a new line)
|
||||
(setq-default truncate-lines t)
|
||||
;; truncate lines even in partial-width windows
|
||||
;;(setq truncate-partial-width-windows t)
|
||||
|
||||
;; display line numbers to the right of the window
|
||||
;; (global-linum-mode t) ;; deactivated because the DocView showing pdf files becomes extremly slow when global-linum-mode is on.
|
||||
|
||||
;; show the current line and column numbers in the stats bar as well
|
||||
(line-number-mode t)
|
||||
(column-number-mode t)
|
||||
|
||||
;; highlight parentheses when the cursor is next to them
|
||||
(use-package paren
|
||||
:defer 0.1
|
||||
:config
|
||||
(show-paren-mode t)
|
||||
)
|
||||
|
||||
;; emacs warning:
|
||||
;; ad-handle-definition: `text-scale-increase' got redefined
|
||||
;; these warnings are generated when functions are redefined with defadvice.
|
||||
(setq ad-redefinition-action 'accept)
|
||||
|
||||
;; gravatars from magit use this to store their cache
|
||||
(setq url-configuration-directory (concat user-cache-directory "url/"))
|
||||
|
||||
(setq bookmark-default-file (concat user-cache-directory "bookmarks"))
|
||||
|
||||
(use-package comint ;; parent mode of many shell modes
|
||||
:bind (:map comint-mode-map
|
||||
("<up>" . comint-previous-input)
|
||||
("<down>" . comint-next-input)))
|
||||
|
||||
(use-package transient
|
||||
:load-path (lambda() (concat user-emacs-directory "lisp/transient"))
|
||||
:defer t
|
||||
:config
|
||||
(setq transient-levels-file (concat user-cache-directory "transient/levels.el"))
|
||||
(setq transient-values-file (concat user-cache-directory "transient/values.el"))
|
||||
(setq transient-history-file (concat user-cache-directory "transient/history.el"))
|
||||
)
|
||||
|
||||
;;
|
||||
;; keyboard
|
||||
;;
|
||||
;; https://github.com/syl20bnr/spacemacs/blob/c7a103a772d808101d7635ec10f292ab9202d9ee/layers/%2Bdistributions/spacemacs-base/keybindings.el
|
||||
;; Make <escape> quit as much as possible
|
||||
(define-key minibuffer-local-map (kbd "<escape>") 'keyboard-escape-quit)
|
||||
(define-key minibuffer-local-ns-map (kbd "<escape>") 'keyboard-escape-quit)
|
||||
(define-key minibuffer-local-completion-map (kbd "<escape>") 'keyboard-escape-quit)
|
||||
(define-key minibuffer-local-must-match-map (kbd "<escape>") 'keyboard-escape-quit)
|
||||
(define-key minibuffer-local-isearch-map (kbd "<escape>") 'keyboard-escape-quit)
|
||||
;;
|
||||
(global-set-key (kbd "C-r") 'query-replace-regexp) ;; isearch-backward
|
||||
(global-set-key (kbd "C-x C-b") 'ibuffer) ;; list-buffers
|
||||
;; applications
|
||||
(global-set-key (kbd "M-m !") 'shell-command)
|
||||
(global-set-key (kbd "M-m a c") 'calc-dispatch)
|
||||
(global-set-key (kbd "M-m a P") 'proced)
|
||||
;; buffers
|
||||
(global-set-key (kbd "M-m b d") 'kill-this-buffer)
|
||||
(global-set-key (kbd "M-m b e") 'erase-buffer)
|
||||
(global-set-key (kbd "M-m b C-d") 'kill-matching-buffers)
|
||||
(global-set-key (kbd "M-m b n") 'next-buffer)
|
||||
(global-set-key (kbd "M-m b p") 'previous-buffer)
|
||||
(global-set-key (kbd "M-m b R") 'revert-buffer)
|
||||
(global-set-key (kbd "M-m b w") 'read-only-mode)
|
||||
;; compile/comments
|
||||
(global-set-key (kbd "M-m c C") 'compile)
|
||||
(global-set-key (kbd "M-m c k") 'kill-compilation)
|
||||
(global-set-key (kbd "M-m c r") 'recompile)
|
||||
;; (with-eval-after-load 'compile
|
||||
;; (define-key compilation-mode-map "r" 'recompile)
|
||||
;; (define-key compilation-mode-map "g" nil)
|
||||
;; )
|
||||
;; errors
|
||||
(global-set-key (kbd "M-m e n") 'next-error)
|
||||
(global-set-key (kbd "M-m e p") 'previous-error)
|
||||
;; files
|
||||
(global-set-key (kbd "M-m f c") 'copy-file)
|
||||
(global-set-key (kbd "M-m f D") 'delete-file)
|
||||
(global-set-key (kbd "M-m f g") 'rgrep)
|
||||
(global-set-key (kbd "M-m f l") 'find-file-literally)
|
||||
(global-set-key (kbd "M-m f R") 'rename-file)
|
||||
(global-set-key (kbd "M-m f s") 'save-buffer)
|
||||
(global-set-key (kbd "M-m f v d") 'add-dir-local-variable)
|
||||
(global-set-key (kbd "M-m f v f") 'add-file-local-variable)
|
||||
(global-set-key (kbd "M-m f v p") 'add-file-local-variable-prop-line)
|
||||
;; help
|
||||
(global-set-key (kbd "M-m h d b") 'describe-bindings)
|
||||
(global-set-key (kbd "M-m h d c") 'describe-char)
|
||||
(global-set-key (kbd "M-m h d C") 'describe-coding-system)
|
||||
(global-set-key (kbd "M-m h d C-c") 'describe-copying)
|
||||
(global-set-key (kbd "M-m h d M-c") 'describe-categories)
|
||||
(global-set-key (kbd "M-m h d f") 'describe-function)
|
||||
(global-set-key (kbd "M-m h d F") 'describe-face)
|
||||
(global-set-key (kbd "M-m h d C-f") 'describe-font)
|
||||
(global-set-key (kbd "M-m h d M-f") 'describe-fontset)
|
||||
(global-set-key (kbd "M-m h d k") 'describe-key)
|
||||
(global-set-key (kbd "M-m h d K") 'describe-keymap)
|
||||
(global-set-key (kbd "M-m h d m") 'describe-mode)
|
||||
(global-set-key (kbd "M-m h d M") 'describe-minor-mode)
|
||||
(global-set-key (kbd "M-m h d o") 'describe-symbol)
|
||||
(global-set-key (kbd "M-m h d p") 'describe-package)
|
||||
(global-set-key (kbd "M-m h d s") 'describe-syntax)
|
||||
(global-set-key (kbd "M-m h d t") 'describe-theme)
|
||||
(global-set-key (kbd "M-m h d v") 'describe-variable)
|
||||
(global-set-key (kbd "M-m h n") 'view-emacs-news)
|
||||
;; format
|
||||
(global-set-key (kbd "M-m j o") 'open-line)
|
||||
(global-set-key (kbd "M-m j =") 'indent-region)
|
||||
(global-set-key (kbd "M-m j S") 'split-line)
|
||||
;; navigation/jumping
|
||||
(global-set-key (kbd "M-m j f") 'find-function)
|
||||
(global-set-key (kbd "M-m j v") 'find-variable)
|
||||
;; narrow & widen
|
||||
(global-set-key (kbd "M-m n r") 'narrow-to-region)
|
||||
(global-set-key (kbd "M-m n p") 'narrow-to-page)
|
||||
(global-set-key (kbd "M-m n f") 'narrow-to-defun)
|
||||
(global-set-key (kbd "M-m n w") 'widen)
|
||||
;; quit
|
||||
(global-set-key (kbd "M-m q s") 'save-buffers-kill-emacs)
|
||||
(global-set-key (kbd "M-m q Q") 'kill-emacs)
|
||||
;; toggles
|
||||
(global-set-key (kbd "M-m t F") 'auto-fill-mode)
|
||||
(global-set-key (kbd "M-m t h h") 'global-hl-line-mode)
|
||||
(global-set-key (kbd "M-m t h s") 'font-lock-mode)
|
||||
(global-set-key (kbd "M-m t l") 'toggle-truncate-lines)
|
||||
(global-set-key (kbd "M-m t L") 'visual-line-mode)
|
||||
(global-set-key (kbd "M-m t m t") 'display-time-mode)
|
||||
(global-set-key (kbd "M-m t W") 'ace-window-display-mode)
|
||||
(global-set-key (kbd "M-m T f") 'fringe-mode)
|
||||
(global-set-key (kbd "M-m T F") 'toggle-frame-fullscreen)
|
||||
(global-set-key (kbd "M-m T m") 'menu-bar-mode)
|
||||
(global-set-key (kbd "M-m T M") 'toggle-frame-maximized)
|
||||
(global-set-key (kbd "M-m T S") 'semantic-stickyfunc-mode)
|
||||
(global-set-key (kbd "M-m T C-S") 'global-semantic-stickyfunc-mode)
|
||||
(global-set-key (kbd "M-m T t") 'tool-bar-mode)
|
||||
;; window
|
||||
(global-set-key (kbd "M-m w d") 'delete-window)
|
||||
(global-set-key (kbd "M-m w D") 'ace-delete-window)
|
||||
(global-set-key (kbd "M-m w f") 'follow-mode)
|
||||
(global-set-key (kbd "M-m w F") 'make-frame)
|
||||
(global-set-key (kbd "M-m w h") 'windmove-left)
|
||||
(global-set-key (kbd "M-m w j") 'windmove-down)
|
||||
(global-set-key (kbd "M-m w k") 'windmove-up)
|
||||
(global-set-key (kbd "M-m w l") 'windmove-right)
|
||||
(global-set-key (kbd "M-m w m") 'maximize-window)
|
||||
(global-set-key (kbd "M-m w M") 'ace-swap-window)
|
||||
(global-set-key (kbd "M-m w n") 'next-window)
|
||||
(global-set-key (kbd "M-m w o") 'other-frame)
|
||||
(global-set-key (kbd "M-m w p") 'previous-window)
|
||||
(global-set-key (kbd "M-m w s") 'split-window-below)
|
||||
(with-eval-after-load 'winner-mode
|
||||
(global-set-key (kbd "M-m w u") 'winner-undo)
|
||||
(global-set-key (kbd "M-m w U") 'winner-redo)
|
||||
)
|
||||
(global-set-key (kbd "M-m w v") 'split-window-right)
|
||||
(global-set-key (kbd "M-m w w") 'other-window)
|
||||
(global-set-key (kbd "M-m w W") 'ace-window) ;; same as ace-selct-window
|
||||
(global-set-key (kbd "M-m w -") 'split-window-below)
|
||||
(global-set-key (kbd "M-m w /") 'split-window-right)
|
||||
(global-set-key (kbd "M-m w =") 'balance-windows)
|
||||
(global-set-key (kbd "M-m w <left>") 'windmove-left)
|
||||
(global-set-key (kbd "M-m w <down>") 'windmove-down)
|
||||
(global-set-key (kbd "M-m w <up>") 'windmove-up)
|
||||
(global-set-key (kbd "M-m w <right>") 'windmove-right)
|
||||
(global-set-key (kbd "M-m w TAB") 'other-window)
|
||||
;; text
|
||||
(global-set-key (kbd "M-m x a a") 'align)
|
||||
(global-set-key (kbd "M-m x a c") 'align-current)
|
||||
(global-set-key (kbd "M-m x c") 'count-words-region)
|
||||
(global-set-key (kbd "M-m x d w") 'delete-trailing-whitespace)
|
||||
(global-set-key (kbd "M-m x j c") 'set-justification-center)
|
||||
(global-set-key (kbd "M-m x j f") 'set-justification-full)
|
||||
(global-set-key (kbd "M-m x j l") 'set-justification-left)
|
||||
(global-set-key (kbd "M-m x j n") 'set-justification-none)
|
||||
(global-set-key (kbd "M-m x j r") 'set-justification-right)
|
||||
(global-set-key (kbd "M-m x l s") 'sort-lines)
|
||||
(global-set-key (kbd "M-m x t c") 'transpose-chars)
|
||||
(global-set-key (kbd "M-m x t l") 'transpose-lines)
|
||||
(global-set-key (kbd "M-m x t w") 'transpose-words)
|
||||
(global-set-key (kbd "M-m x u") 'downcase-region)
|
||||
(global-set-key (kbd "M-m x U") 'upcase-region)
|
||||
(global-set-key (kbd "M-m x TAB") 'indent-rigidly)
|
||||
;; Bind commands to move around windows
|
||||
(global-set-key [(C-M-left)] 'windmove-left)
|
||||
(global-set-key [(C-M-right)] 'windmove-right)
|
||||
(global-set-key [(C-M-up)] 'windmove-up)
|
||||
(global-set-key [(C-M-down)] 'windmove-down)
|
||||
(defun toggle-window-split ()
|
||||
"Toggle between horizontal and vertical split with two windows."
|
||||
(interactive)
|
||||
(if (> (length (window-list)) 2)
|
||||
(error "Can't toggle with more than 2 windows!")
|
||||
(let ((func (if (window-full-height-p)
|
||||
#'split-window-vertically
|
||||
#'split-window-horizontally)))
|
||||
(delete-other-windows)
|
||||
(funcall func)
|
||||
(save-selected-window
|
||||
(other-window 1)
|
||||
(switch-to-buffer (other-buffer))))))
|
||||
(global-set-key (kbd "C-x |") 'toggle-window-split)
|
||||
;; move current line up and down
|
||||
(defun move-line-up()
|
||||
"Move up the current line."
|
||||
(interactive)
|
||||
(transpose-lines 1)
|
||||
(forward-line -2)
|
||||
(indent-according-to-mode))
|
||||
(defun move-line-down()
|
||||
"Move down the current line."
|
||||
(interactive)
|
||||
(forward-line 1)
|
||||
(transpose-lines 1)
|
||||
(forward-line -1)
|
||||
(indent-according-to-mode))
|
||||
(global-set-key [(M-up)] 'move-line-up)
|
||||
(global-set-key [(M-down)] 'move-line-down)
|
||||
|
||||
;;
|
||||
;; mouse
|
||||
;;
|
||||
;; Enable mouse support, https://stackoverflow.com/questions/5710334/how-can-i-get-mouse-selection-to-work-in-emacs-and-iterm2-on-mac
|
||||
(unless (display-graphic-p)
|
||||
(require 'mouse)
|
||||
(xterm-mouse-mode t)
|
||||
(global-set-key [mouse-4] (lambda () (interactive) (scroll-down 1)))
|
||||
(global-set-key [mouse-5] (lambda () (interactive) (scroll-up 1)))
|
||||
(defun track-mouse (e))
|
||||
(setq mouse-sel-mode t)
|
||||
)
|
||||
(setq mouse-wheel-progressive-speed nil)
|
||||
;; Turn on horizontal scrolling with mouse wheel
|
||||
(global-set-key (kbd "<mouse-6>") (lambda () (interactive) (scroll-right 1)))
|
||||
(global-set-key (kbd "<mouse-7>") (lambda () (interactive) (scroll-left 1)))
|
||||
(global-set-key (kbd "<mouse-8>") (lambda () (interactive) (previous-buffer)))
|
||||
(global-set-key (kbd "<mouse-9>") (lambda () (interactive) (next-buffer)))
|
||||
;; for scroll-all-mode add mouse wheel support
|
||||
;; https://www.emacswiki.org/emacs/ScrollAllMode
|
||||
(defun my-mwheel-scroll-all-function (func &optional arg)
|
||||
(if (and scroll-all-mode arg)
|
||||
(save-selected-window
|
||||
(walk-windows
|
||||
(lambda (win)
|
||||
(select-window win)
|
||||
(condition-case nil
|
||||
(funcall func arg)
|
||||
(error nil)))))
|
||||
(funcall func arg)))
|
||||
(defun my-mwheel-scroll-all-scroll-up (&optional arg)
|
||||
(my-mwheel-scroll-all-function 'scroll-up arg))
|
||||
(defun my-mwheel-scroll-all-scroll-down (&optional arg)
|
||||
(my-mwheel-scroll-all-function 'scroll-down arg))
|
||||
(setq mwheel-scroll-up-function 'my-mwheel-scroll-all-scroll-up)
|
||||
(setq mwheel-scroll-down-function 'my-mwheel-scroll-all-scroll-down)
|
||||
|
||||
;;; Scrolling.
|
||||
;; https://www.reddit.com/r/emacs/comments/8sw3r0/finally_scrolling_over_large_images_with_pixel/
|
||||
;; Good speed and allow scrolling through large images (pixel-scroll).
|
||||
;; Note: Scroll lags when point must be moved but increasing the number
|
||||
;; of lines that point moves in pixel-scroll.el ruins large image
|
||||
;; scrolling. So unfortunately I think we'll just have to live with
|
||||
;; this.
|
||||
;;(pixel-scroll-mode) ;; default off
|
||||
(setq pixel-dead-time 0) ; Never go back to the old scrolling behaviour.
|
||||
(setq pixel-resolution-fine-flag t) ; Scroll by number of pixels instead of lines (t = frame-char-height pixels).
|
||||
(setq mouse-wheel-scroll-amount '(1)) ; Distance in pixel-resolution to scroll each mouse wheel event.
|
||||
(setq mouse-wheel-progressive-speed nil) ; Progressive speed is too fast for me.
|
||||
|
||||
|
||||
;;
|
||||
;; Menu
|
||||
;;
|
||||
;; Creating a major menu pane in the menu bar in the “File” menu before the “Save” entry.
|
||||
;; Easy-Menu
|
||||
;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Easy-Menu.html
|
||||
;; https://stackoverflow.com/questions/26638015/elisp-easy-menu-positioning#29396939
|
||||
;; add menus to the global menu bar: map nil
|
||||
(use-package easymenu
|
||||
:config
|
||||
(easy-menu-add-item nil '("File") ["Kill Emacs" kill-emacs :help "Run function `kill-emacs'"] "Quit")
|
||||
|
||||
(easy-menu-define my-menu nil "My Menu"
|
||||
'("My"))
|
||||
(easy-menu-define my-major-menu nil "My Major Menu"
|
||||
'("Major Modes"
|
||||
["Unknown" (progn ()) :style radio :selected major-mode :active nil
|
||||
:label (concat "Current: " (prin1-to-string major-mode))]
|
||||
["Deft" (progn (deft)) :style radio :selected (eq major-mode 'deft-mode) :help "deft"]
|
||||
["Eshell [🅢e]" (progn (eshell-mode)) :style radio :selected (eq major-mode 'eshell-mode) :help "eshell-mode"]
|
||||
["Magit" (progn (magit)) :style radio :selected (eq major-mode 'magit-status-mode) :help "magit"]
|
||||
["Notmuch [🅝]" (progn (notmuch)) :style radio :selected (eq major-mode 'notmuch-mode) :help "notmuch"]
|
||||
["mu4e [Ⓜ]" (progn (mu4e)) :style radio :selected (eq major-mode 'mu4e-mode) :help "mu4e"]
|
||||
["Org Brain" (progn (call-interactively 'org-brain-visualize)) :style radio :selected (eq major-mode 'org-brain-visualize-mode) :help "org-brain-visualize"]
|
||||
["Org Drill" (progn (org-drill)) :style radio :selected (eq major-mode 'org-drill-mode) :help "org-drill"]
|
||||
["Powershell" (progn (powershell)) :style radio :selected (eq major-mode 'powershell-mode) :help "powershell"]
|
||||
["Shell" (progn (shell)) :style radio :selected (eq major-mode 'shell-mode) :help "shell"]
|
||||
["Treemacs" (progn (treemacs)) :style radio :selected (eq major-mode 'treemacs-mode) :help "treemacs"]
|
||||
))
|
||||
(easy-menu-define my-lang-menu nil "My Lang Menu"
|
||||
'("Language Modes"
|
||||
["Unknown" (progn ())
|
||||
:style radio :selected major-mode :active nil
|
||||
:label (concat "Current: " (prin1-to-string major-mode))]
|
||||
["Batch script" (progn (bat-mode))
|
||||
:style radio :selected (eq major-mode 'bat-mode) :help "bat-mode"]
|
||||
["C" (progn (c-mode))
|
||||
:style radio :selected (eq major-mode 'c-mode) :help "c-mode"]
|
||||
["C++" (progn (c++-mode))
|
||||
:style radio :selected (eq major-mode 'c++-mode) :help "c++-mode"]
|
||||
["CSS [🅒SS]" (progn (css-mode))
|
||||
:style radio :selected (eq major-mode 'css-mode) :help "css-mode"]
|
||||
["Emacs-Lisp [🅛e]" (progn (emacs-lisp-mode))
|
||||
:style radio :selected (eq major-mode 'emacs-lisp-mode) :help "emacs-lisp-mode"]
|
||||
["Gnuplot" (progn (gnuplot-mode))
|
||||
:style radio :selected (eq major-mode 'gnuplot-mode) :help "gnuplot-mode"]
|
||||
["HTML" (progn (html-mode))
|
||||
:style radio :selected (eq major-mode 'html-mode) :help "html-mode"]
|
||||
["Java" (progn (java-mode))
|
||||
:style radio :selected (eq major-mode 'java-mode) :help "java-mode"]
|
||||
;; js2-mode better than js-mode
|
||||
["Javascript" (progn (js2-mode))
|
||||
:style radio :selected (eq major-mode 'js2-mode) :help "js2-mode"]
|
||||
["LaTeX [🅛a]" (progn (latex-mode))
|
||||
:style radio :selected (eq major-mode 'latex-mode) :help "latex-mode"]
|
||||
["Ledger [🅛d]" (progn (ledger-mode))
|
||||
:style radio :selected (eq major-mode 'ledger-mode) :help "ledger-mode"]
|
||||
["Lisp Interaction [🅛i]" (progn (lisp-interaction-mode))
|
||||
:style radio :selected (eq major-mode 'lisp-interaction-mode) :help "lisp-interaction-mode"]
|
||||
["Markdown" (progn (markdown-mode))
|
||||
:style radio :selected (eq major-mode 'markdown-mode) :help "markdown-mode"]
|
||||
["Octave" (progn (octave-mode))
|
||||
:style radio :selected (eq major-mode 'octave-mode) :help "octave-mode"]
|
||||
["Org [🅞]" (progn (org-mode))
|
||||
:style radio :selected (eq major-mode 'org-mode) :help "org-mode"]
|
||||
;; cperl-mode offers much more features than perl-mode.
|
||||
["Perl" (progn (cperl-mode))
|
||||
:style radio :selected (eq major-mode 'cperl-mode) :help "cperl-mode"]
|
||||
["PHP" (progn (php-mode))
|
||||
:style radio :selected (eq major-mode 'php-mode) :help "php-mode"]
|
||||
["PlantUML" (progn (plantuml-mode))
|
||||
:style radio :selected (eq major-mode 'plantuml-mode) :help "plantuml-mode"]
|
||||
["Powershell script" (progn (powershell-mode))
|
||||
:style radio :selected (eq major-mode 'powershell-mode) :help "powershell-mode"]
|
||||
["Python [🅟]" (progn (python-mode))
|
||||
:style radio :selected (eq major-mode 'python-mode) :help "python-mode"]
|
||||
["Python-Web (Poly)" (progn (poly-python-web-mode-map))
|
||||
:style radio :selected (eq major-mode 'poly-python-web-mode-map) :help "poly-python-web-mode-map"]
|
||||
["R (ESS)" (progn (ess-r-mode))
|
||||
:style radio :selected (eq major-mode 'ess-r-mode) :help "ess-r-mode"]
|
||||
["reStructuredText (ReST)" (progn (rst-mode))
|
||||
:style radio :selected (eq major-mode 'rst-mode) :help "rst-mode"]
|
||||
["Ruby" (progn (ruby-mode))
|
||||
:style radio :selected (eq major-mode 'ruby-mode) :help "ruby-mode"]
|
||||
;; shell-mode is to run shell inside Emacs, sh-mode for shell script editing, shell-script-mode is an alias for sh-mode.
|
||||
["Shell script" (progn (sh-mode))
|
||||
:style radio :selected (eq major-mode 'sh-mode) :help "sh-mode"]
|
||||
["SQL" (progn (sql-mode))
|
||||
:style radio :selected (eq major-mode 'sql-mode) :help "sql-mode"]
|
||||
["Tcl" (progn (tcl-mode))
|
||||
:style radio :selected (eq major-mode 'tcl-mode) :help "tcl-mode"]
|
||||
["XML (nxml-mode)" (progn (nxml-mode))
|
||||
:style radio :selected (eq major-mode 'nxml-mode) :help "nxml-mode"]
|
||||
["XML (xml-mode)" (progn (xml-mode))
|
||||
:style radio :selected (eq major-mode 'xml-mode) :help "xml-mode"]
|
||||
))
|
||||
(easy-menu-define my-minor-menu nil "My Minor Menu"
|
||||
'("Minor Modes"
|
||||
["Ace Window Display" ace-window-display-mode
|
||||
:style toggle :selected ace-window-display-mode :help "ace-window-display-mode"]
|
||||
["Company [Ⓒ]" company-mode
|
||||
:style toggle :selected company-mode :help "company-mode"]
|
||||
["Compilation Shell [Ⓒs]" compilation-shell-minor-mode
|
||||
:style toggle :selected compilation-shell-minor-mode :help "compilation-shell-minor-mode"]
|
||||
["Diff Highlighting" diff-hl-mode
|
||||
:style toggle :selected diff-hl-mode :help "diff-hl-mode"]
|
||||
["Display Fill Column Indicator" display-fill-column-indicator-mode
|
||||
:style toggle :selected display-fill-column-indicator-mode :help "display-fill-column-indicator-mode"]
|
||||
["Eldoc [Ⓔ]" eldoc-mode
|
||||
:style toggle :selected eldoc-mode :help "eldoc-mode"]
|
||||
["Emojify" emojify-mode
|
||||
:style toggle :selected emojify-mode :help "emojify-mode"]
|
||||
["Flycheck [𝓕]" flycheck-mode
|
||||
:style toggle :selected flycheck-mode :help "flycheck-mode"] ;; flymake supports less languages
|
||||
["Flyspell" flyspell-mode
|
||||
:style toggle :selected flyspell-mode :help "flyspell-mode"] ;; uses ispell
|
||||
["HideShow" hs-minor-mode
|
||||
:style toggle :selected hs-minor-mode :help "hs-minor-mode"]
|
||||
["Horizontal Scroll Bar" horizontal-scroll-bar-mode
|
||||
:style toggle :selected horizontal-scroll-bar-mode :help "horizontal-scroll-bar-mode"]
|
||||
;; ["Ido" ido-mode
|
||||
;; :style toggle :selected ido-mode :help "ido-mode"]
|
||||
["Ivy [Ⓘ]" ivy-mode
|
||||
:style toggle :selected ivy-mode :help "ivy-mode"]
|
||||
["Line Numbers" linum-mode
|
||||
:style toggle :selected linum-mode :help "linum-mode"]
|
||||
("Line Wrapping"
|
||||
["Auto Fill Function [↵]" auto-fill-mode
|
||||
:style toggle :selected auto-fill-function :help "auto-fill-mode"]
|
||||
["Truncate Long Lines" toggle-truncate-lines ;; menu-bar--toggle-truncate-long-lines
|
||||
:style toggle :selected (or truncate-lines
|
||||
(truncated-partial-width-window-p))
|
||||
:help "toggle-truncate-lines"]
|
||||
["Virtual Auto Fill [Ⓥf]" virtual-auto-fill-mode
|
||||
:style toggle :selected virtual-auto-fill-mode :help "virtual-auto-fill-mode"]
|
||||
["Visual Line (Word Wrap) [↩]" visual-line-mode
|
||||
:style toggle :selected visual-line-mode :help "visual-line-mode"]
|
||||
)
|
||||
("Org"
|
||||
["Org Fancy Priorities [Ⓟ]" org-fancy-priorities-mode
|
||||
:style toggle :selected org-sticky-header-mode :help "org-sticky-header-mode"]
|
||||
["Org Num [#]" org-num-mode
|
||||
:style toggle :selected org-num-mode :help "org-num-mode"]
|
||||
["Org Sticky Header" org-sticky-header-mode
|
||||
:style toggle :selected org-sticky-header-mode :help "org-sticky-header-mode"]
|
||||
["Org Superstar" org-superstar-mode
|
||||
:style toggle :selected org-superstar-mode :help "org-superstar-mode"]
|
||||
["Org Table Sticky Header [Ⓣ]" org-table-sticky-header-mode
|
||||
:style toggle :selected org-table-sticky-header-mode :help "org-table-sticky-header-mode"]
|
||||
)
|
||||
["Pixel Scroll" pixel-scroll-mode
|
||||
:style toggle :selected pixel-scroll-mode :help "pixel-scroll-mode"]
|
||||
["Rainbow" rainbow-mode
|
||||
:style toggle :selected rainbow-mode :help "rainbow-mode"]
|
||||
["Scroll-All" scroll-all-mode
|
||||
:style toggle :selected scroll-all-mode :help "scroll-all-mode"]
|
||||
["Sphinx Doc [Ⓢ]" sphinx-doc-mode
|
||||
:style toggle :selected sphinx-doc-mode :help "sphinx-doc-mode"]
|
||||
["YASnippet [Ⓨ]" yas-minor-mode
|
||||
:style toggle :selected yas-minor-mode :help "yas-minor-mode"]
|
||||
["Which Key [Ⓚ]" which-key-mode
|
||||
:style toggle :selected which-key-mode :help "which-key-mode"]
|
||||
["Whitespace [␣]" whitespace-mode
|
||||
:style toggle :selected whitespace-mode :help "whitespace-mode"]
|
||||
;; "--" ;; separator
|
||||
;; ["--" 'ignore :visible (featurep 'bookmark+-lit)] ;; conditional separator
|
||||
;; ["How Many..." how-many]
|
||||
))
|
||||
;; add menus explicitly (required by XEmacs), after easy-menu-define
|
||||
(easy-menu-add my-major-menu nil)
|
||||
(easy-menu-add my-lang-menu nil)
|
||||
(easy-menu-add my-minor-menu nil)
|
||||
|
||||
(easy-menu-add-item nil () my-menu ;; add empty my menu to menu-bar
|
||||
;; "Edit" ;; before Edit
|
||||
)
|
||||
(easy-menu-add-item nil '("My") my-major-menu) ;; add submenu to my menu
|
||||
(easy-menu-add-item nil '("My") my-lang-menu)
|
||||
(easy-menu-add-item nil '("My") my-minor-menu)
|
||||
|
||||
(easy-menu-add-item nil '("My") '("--"))
|
||||
(easy-menu-define my-view-menu nil "My Views Menu"
|
||||
'("Views"
|
||||
["ELisp" my-view-elisp :help "my-view-elisp"]
|
||||
["Python" my-view-python :help "my-view-python"]
|
||||
["Org PDF" my-view-org-pdf :help "my-view-org-pdf"]
|
||||
))
|
||||
(easy-menu-add my-view-menu nil)
|
||||
(easy-menu-add-item nil '("My") my-view-menu)
|
||||
|
||||
(easy-menu-add-item nil '("My") '("--"))
|
||||
(with-eval-after-load 'org
|
||||
(easy-menu-define my-org-export-menu nil "My Org Export Menu"
|
||||
'("Org Export" :visible (eq major-mode 'org-mode)
|
||||
["HTML" my-org-export-html :help "my-org-export-html"]
|
||||
["HTML async" my-org-export-html-async :help "my-org-export-html-async"]
|
||||
["PDF (LaTeX)" my-org-export-pdf :help "my-org-export-pdf"]
|
||||
["PDF (LaTeX) async" my-org-export-pdf-async :help "my-org-export-pdf-async"]
|
||||
))
|
||||
(easy-menu-add my-org-export-menu nil)
|
||||
(easy-menu-add-item nil '("My") my-org-export-menu)
|
||||
(easy-menu-add-item nil '("My") '["Org Link Description Update" my-org-link-description-update :visible (eq major-mode 'org-mode)])
|
||||
)
|
||||
|
||||
(with-eval-after-load 'notmuch
|
||||
(easy-menu-add-item nil '("My") '["Notmuch Execute Offlineimap" my-mail-exec-offlineimap
|
||||
:visible (or (eq major-mode 'notmuch-hello-mode)
|
||||
(eq major-mode 'notmuch-message-mode)
|
||||
(eq major-mode 'notmuch-search-mode)
|
||||
(eq major-mode 'notmuch-show-mode)
|
||||
(eq major-mode 'notmuch-tree-mode))
|
||||
:help "my-mail-exec-offlineimap"])
|
||||
)
|
||||
)
|
||||
|
||||
(provide 'general-settings)
|
||||
;;; general-settings.el ends here
|
||||
366
settings/gui-settings.el
Normal file
366
settings/gui-settings.el
Normal file
@@ -0,0 +1,366 @@
|
||||
;;; gui-settings --- Summary
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Requirements:
|
||||
;; restart-emacs https://melpa.org/#/restart-emacs
|
||||
;; dashboard https://melpa.org/#/dashboard
|
||||
;; page-break-lines https://melpa.org/#/page-break-lines
|
||||
;; all-the-icons https://melpa.org/#/all-the-icons
|
||||
;; memoize https://melpa.org/#/memoize
|
||||
;; indent-guide https://melpa.org/#/indent-guide
|
||||
;; not highlight-indent-guides
|
||||
;; rainbow-mode https://elpa.gnu.org/packages/rainbow-mode.html
|
||||
;; focus https://melpa.org/#/focus
|
||||
;; virtual-auto-fill https://melpa.org/#/virtual-auto-fill
|
||||
|
||||
;;; Code:
|
||||
|
||||
(use-package emacs
|
||||
:delight
|
||||
(auto-fill-function "↵")
|
||||
(compilation-shell-minor-mode "Ⓒs")
|
||||
(eldoc-mode "Ⓔ") ;; Ⓔ e
|
||||
(visual-line-mode "↩") ;; " Wrap"
|
||||
(whitespace-mode "␣") ;; "␣ _ ws"
|
||||
;; major modes
|
||||
(calendar-mode "🅒al") ;; "Calendar" "📆"
|
||||
(css-mode "🅒SS") ;; "CSS"
|
||||
(emacs-lisp-mode "🅛e") ;; "EL 🅛⒠"
|
||||
(eshell-mode "🅢e") ;; "Esh 🅔⒮"
|
||||
(fundamental-mode "🅕") ;; "F " ;; not working
|
||||
(help-mode "🅗") ;; "H "
|
||||
(Info-mode "🅘") ;; "I " ;; not working
|
||||
(latex-mode "🅛a") ;; "LaTeX "
|
||||
(lisp-interaction-mode "🅛i") ;; "LI 🅛⒤"
|
||||
(messages-mode "🅜") ;; "M " ;; not working
|
||||
(messages-buffer-mode "🅜") ;; "M " ;; not working
|
||||
(inferior-python-mode "🅟i") ;; "IPy 🅟⒤"
|
||||
:hook
|
||||
(prog-mode . display-fill-column-indicator-mode)
|
||||
(help-mode . visual-line-mode)
|
||||
(messages-buffer-mode . visual-line-mode)
|
||||
:config
|
||||
(set-face-attribute 'fill-column-indicator nil :foreground "DarkSlateGray") ;; inherit shadow
|
||||
|
||||
;; `scroll-bar-mode' sets for all frames and all windows
|
||||
;; use `set-window-scroll-bars' for windows only
|
||||
(scroll-bar-mode 0) ;; 1st deactivate scrolling
|
||||
(add-hook 'visual-line-mode-hook 'my-visual-line-mode-hook)
|
||||
(defun my-visual-line-mode-hook ()
|
||||
"no `horizontal-scroll-bar' if `visual-line-mode'"
|
||||
(if visual-line-mode
|
||||
(set-window-scroll-bars (frame-selected-window) nil t nil nil)
|
||||
(set-window-scroll-bars (frame-selected-window) nil t nil 'bottom)
|
||||
))
|
||||
(add-hook 'window-state-change-hook
|
||||
(lambda () (my-window-state-change (window-buffer))))
|
||||
(defun my-window-state-change (frame-or-window)
|
||||
(let (window
|
||||
(vertical-type nil)
|
||||
(horizontal-type nil)
|
||||
buffer
|
||||
buffer-name)
|
||||
(when (framep frame-or-window)
|
||||
(setq window (frame-selected-window frame-or-window)))
|
||||
(setq buffer (window-buffer window))
|
||||
(setq buffer-name (buffer-name buffer))
|
||||
;; turn scrolling on
|
||||
(when visual-line-mode
|
||||
(setq vertical-type 'right)
|
||||
(setq horizontal-type nil))
|
||||
(when truncate-lines
|
||||
(setq vertical-type 'right)
|
||||
(setq horizontal-type 'bottom))
|
||||
;; turn off
|
||||
(cond
|
||||
((or (minibufferp buffer)
|
||||
(string-equal major-mode "doc-view-mode")
|
||||
(string-equal buffer-name " *Org tags*"))
|
||||
(setq vertical-type nil)
|
||||
(setq horizontal-type nil))
|
||||
((string-prefix-p "*mu4e" buffer-name)
|
||||
(setq vertical-type 'right)))
|
||||
;; (message "%s %s %s %s %s"
|
||||
;; buffer-name
|
||||
;; visual-line-mode
|
||||
;; truncate-lines
|
||||
;; vertical-type
|
||||
;; horizontal-type)
|
||||
(set-window-scroll-bars window nil vertical-type nil horizontal-type)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(use-package doc-view
|
||||
:defer t
|
||||
:delight (doc-view-mode "🅓oc") ;; "DocView"
|
||||
:config
|
||||
(setq doc-view-continuous t))
|
||||
|
||||
(use-package restart-emacs)
|
||||
|
||||
(use-package page-break-lines
|
||||
:delight (page-break-lines-mode "Ⓟb")
|
||||
:config
|
||||
(global-page-break-lines-mode))
|
||||
|
||||
(use-package memoize
|
||||
:defer t)
|
||||
|
||||
(use-package all-the-icons
|
||||
:load-path (lambda() (concat user-emacs-directory "lisp/all-the-icons"))
|
||||
:defer t
|
||||
:config
|
||||
(when (and (not (my-font-installed-p "all-the-icons"))
|
||||
(window-system))
|
||||
(all-the-icons-install-fonts t)
|
||||
;;(restart-emacs) ;; infinity loop?
|
||||
))
|
||||
|
||||
(use-package dashboard
|
||||
:load-path (lambda() (concat user-emacs-directory "lisp/dashboard"))
|
||||
:delight (dashboard-mode "🅓")
|
||||
:config
|
||||
(setq dashboard-startup-banner 'logo)
|
||||
(setq dashboard-set-navigator t)
|
||||
;; (setq dashboard-navigator-buttons ;; Format: "(icon title help action face prefix suffix)"
|
||||
;; (list (list ;; line1
|
||||
;; ;; "☆" "Star" "Show stars" (lambda (&rest _) (show-stars)) warning "[" "]")
|
||||
;; (list "?" "" "?/h" (lambda (&rest _) (describe-mode)) nil "<" ">") ;;#'show-help
|
||||
;; )))
|
||||
(setq dashboard-navigator-buttons ;; Format: "(icon title help action face prefix suffix)"
|
||||
`(( ;; views
|
||||
("" "Custom Views:" "custom views" nil default "" "")
|
||||
(,(all-the-icons-fileicon "elisp" :height 1.0 :v-adjust -0.1)
|
||||
"ELisp" "my-view-elisp" (lambda (&rest _) (my-view-elisp)))
|
||||
(,(all-the-icons-alltheicon "python" :height 1.0 :v-adjust 0.0)
|
||||
"Python" "my-view-python" (lambda (&rest _) (my-view-python)))
|
||||
)
|
||||
( ;; major modes
|
||||
("" "Major Modes:" "major modes" nil default "" "")
|
||||
(""
|
||||
"Deft" "deft" (lambda (&rest _) (deft)))
|
||||
(""
|
||||
"EShell" "eshell-mode" (lambda (&rest _) (eshell-mode)))
|
||||
(""
|
||||
"Magit" "magit" (lambda (&rest _) (magit)))
|
||||
(,(all-the-icons-octicon "mail" :height 1.0 :v-adjust 0.0)
|
||||
"Mu4e" "mu4e" (lambda (&rest _) (mu4e)))
|
||||
(,(all-the-icons-octicon "mail" :height 1.0 :v-adjust 0.0)
|
||||
"Notmuch" "notmuch" (lambda (&rest _) (notmuch)))
|
||||
(""
|
||||
"Org-Brain" "org-brain-visualize" (lambda (&rest _) (call-interactively 'org-brain-visualize)))
|
||||
)
|
||||
( ;; major modes second line
|
||||
(""
|
||||
"Org-Drill" "org-drill" (lambda (&rest _) (org-drill)))
|
||||
(""
|
||||
"Powershell" "powershell" (lambda (&rest _) (powershell)))
|
||||
(""
|
||||
"Shell" "shell" (lambda (&rest _) (shell)))
|
||||
(""
|
||||
"Treemacs" "treemacs" (lambda (&rest _) (treemacs)))
|
||||
)
|
||||
( ;; line1
|
||||
;; "☆" "Star" "Show stars" (lambda (&rest _) (show-stars)) warning "[" "]")
|
||||
(,(all-the-icons-material "help_outline" :height 1.1 :v-adjust -0.15) ;; all-the-icons-octicon "question"
|
||||
"Help" "?/h" (lambda (&rest _) (describe-mode)) nil) ;; #'show-help
|
||||
(,(all-the-icons-material "refresh" :height 1.1 :v-adjust -0.15) ;; all-the-icons-octicon "sync"
|
||||
"Restart" "restart-emacs" (lambda (&rest _) (restart-emacs)) nil)
|
||||
)))
|
||||
(setq dashboard-items '((recents . 5)
|
||||
(bookmarks . 5)
|
||||
;;(projects . 5)
|
||||
;;(agenda . 5)
|
||||
(registers . 5)))
|
||||
|
||||
;;custom widget
|
||||
(defun my-widget-item (icon icon-face title title-face help action)
|
||||
(let ((action (or action #'ignore)))
|
||||
(widget-create 'item
|
||||
:tag (concat
|
||||
(propertize icon 'face `(:inherit
|
||||
,(get-text-property 0 'face icon)
|
||||
:inherit
|
||||
,icon-face))
|
||||
(propertize " " 'face 'variable-pitch)
|
||||
(propertize title 'face title-face))
|
||||
:help-echo help
|
||||
:action action
|
||||
:button-face `(:underline nil)
|
||||
:mouse-face 'highlight
|
||||
;;:button-prefix (propertize "" 'face 'dashboard-navigator)
|
||||
;;:button-suffix (propertize "" 'face 'dashboard-navigator)
|
||||
:format "%[%t%]")))
|
||||
;; (defun dashboard-insert-custom (list-size)
|
||||
;; (dashboard-insert-shortcut "v" "Views" t)
|
||||
;; (when (display-graphic-p)
|
||||
;; (insert (all-the-icons-material "view_quilt" :height 1.6 :v-adjust -0.25
|
||||
;; :face 'dashboard-heading))
|
||||
;; (insert " "))
|
||||
;; (insert (propertize "Custom views:" 'face 'dashboard-heading))
|
||||
;; (insert " (v)")
|
||||
;; (insert " ")
|
||||
;; (my-widget-item (all-the-icons-fileicon "elisp" :height 1.0 :v-adjust -0.1)
|
||||
;; 'all-the-icons-purple "ELisp" 'default "my-view-elisp"
|
||||
;; (lambda (&rest _) (my-view-elisp)))
|
||||
;; (insert " ")
|
||||
;; (my-widget-item (all-the-icons-alltheicon "python" :height 1.0 :v-adjust 0.0)
|
||||
;; 'all-the-icons-dblue "Python" 'default "my-view-python"
|
||||
;; (lambda (&rest _) (my-view-python)))
|
||||
;; (insert " ")
|
||||
;; (my-widget-item (all-the-icons-octicon "mail" :height 1.0 :v-adjust 0.0)
|
||||
;; 'all-the-icons-dblue "Notmuch" 'default "notmuch"
|
||||
;; (lambda (&rest _) (notmuch)))
|
||||
;; )
|
||||
;; (add-to-list 'dashboard-item-generators '(custom . dashboard-insert-custom) t)
|
||||
;; see below add-to-list to dashboard-items
|
||||
|
||||
;; `clean-buffer-list'
|
||||
(defun my-buffer-name-list (&optional special internal)
|
||||
"If SPECIAL non-nil then include special buffers.
|
||||
If INTERNAL non-nil then include internal buffers."
|
||||
(let ((b-list (mapcar (function buffer-name) (buffer-list)))
|
||||
new-list head)
|
||||
(while b-list
|
||||
(setq head (car b-list))
|
||||
(when (or internal ;; check if no space is in the fron
|
||||
(not (string= " " (substring head 0 1))))
|
||||
(when (or special ;; check if no star are in the front and back
|
||||
(and (not (string= "*" (substring head 0 1)))
|
||||
(not (string= "*" (subseq head -1)))))
|
||||
(push head new-list)))
|
||||
(setq b-list (cdr b-list)))
|
||||
(nreverse new-list)))
|
||||
(defun my-buffer-name-list-special ()
|
||||
"List special buffers."
|
||||
(let ((b-list (mapcar (function buffer-name) (buffer-list)))
|
||||
new-list head)
|
||||
(while b-list
|
||||
(setq head (car b-list))
|
||||
(when (and (string= "*" (substring head 0 1))
|
||||
(string= "*" (subseq head -1)))
|
||||
(push head new-list))
|
||||
(setq b-list (cdr b-list)))
|
||||
(nreverse new-list)))
|
||||
;; overwrite with addition parameter to supress the logic to insert
|
||||
;; a pre-defined heading icon. This is used to include own icon.
|
||||
(defun dashboard-insert-heading (heading &optional shortcut suppress-icon)
|
||||
"Insert a widget HEADING in dashboard buffer, adding SHORTCUT if provided."
|
||||
(when (and (display-graphic-p)
|
||||
dashboard-set-heading-icons)
|
||||
;; Try loading `all-the-icons'
|
||||
(unless (or (fboundp 'all-the-icons-octicon)
|
||||
(require 'all-the-icons nil 'noerror))
|
||||
(error "Package `all-the-icons' isn't installed"))
|
||||
|
||||
(unless suppress-icon ;; ADDED
|
||||
(insert (cond
|
||||
((string-equal heading "Recent Files:")
|
||||
(all-the-icons-octicon (cdr (assoc 'recents dashboard-heading-icons))
|
||||
:height 1.2 :v-adjust 0.0 :face 'dashboard-heading))
|
||||
((string-equal heading "Bookmarks:")
|
||||
(all-the-icons-octicon (cdr (assoc 'bookmarks dashboard-heading-icons))
|
||||
:height 1.2 :v-adjust 0.0 :face 'dashboard-heading))
|
||||
((or (string-equal heading "Agenda for today:")
|
||||
(string-equal heading "Agenda for the coming week:"))
|
||||
(all-the-icons-octicon (cdr (assoc 'agenda dashboard-heading-icons))
|
||||
:height 1.2 :v-adjust 0.0 :face 'dashboard-heading))
|
||||
((string-equal heading "Registers:")
|
||||
(all-the-icons-octicon (cdr (assoc 'registers dashboard-heading-icons))
|
||||
:height 1.2 :v-adjust 0.0 :face 'dashboard-heading))
|
||||
((string-equal heading "Projects:")
|
||||
(all-the-icons-octicon (cdr (assoc 'projects dashboard-heading-icons))
|
||||
:height 1.2 :v-adjust 0.0 :face 'dashboard-heading))
|
||||
(t " ")))
|
||||
) ;; ADDED
|
||||
(insert " "))
|
||||
|
||||
(insert (propertize heading 'face 'dashboard-heading))
|
||||
(if shortcut (insert (format " (%s)" shortcut))))
|
||||
;; overwrite to supress the logic to insert a pre-defined heading
|
||||
;; icon. This is used to include own icon.
|
||||
(defmacro my-dashboard-insert-section (section-name list list-size shortcut action &rest widget-params)
|
||||
"Add a section with SECTION-NAME and LIST of LIST-SIZE items to the dashboard.
|
||||
SHORTCUT is the keyboard shortcut used to access the section.
|
||||
ACTION is theaction taken when the user activates the widget button.
|
||||
WIDGET-PARAMS are passed to the \"widget-create\" function."
|
||||
`(progn
|
||||
(dashboard-insert-heading ,section-name
|
||||
(if (and ,list dashboard-show-shortcuts) ,shortcut)
|
||||
t) ;; ADDED
|
||||
(if ,list
|
||||
(when (dashboard-insert-section-list
|
||||
,section-name
|
||||
(dashboard-subseq ,list 0 ,list-size)
|
||||
,action
|
||||
,@widget-params)
|
||||
(dashboard-insert-shortcut ,shortcut ,section-name))
|
||||
(insert "\n --- No items ---"))))
|
||||
(defun dashboard-insert-buffers (list-size)
|
||||
"Add the list of LIST-SIZE items from buffers list.
|
||||
|
||||
See also `dashboard-insert-section'."
|
||||
(when (display-graphic-p)
|
||||
(insert (all-the-icons-octicon
|
||||
"versions"
|
||||
:height 1.2 :v-adjust 0.0 :face 'dashboard-heading)))
|
||||
(my-dashboard-insert-section
|
||||
"Special Buffers:"
|
||||
;;(my-buffer-name-list)
|
||||
(my-buffer-name-list-special)
|
||||
list-size
|
||||
"b"
|
||||
`(lambda (&rest ignore) (switch-to-buffer ,el))
|
||||
(abbreviate-file-name el)))
|
||||
(add-to-list 'dashboard-item-generators '(buffers . dashboard-insert-buffers) t)
|
||||
;; see below add-to-list to dashboard-items
|
||||
|
||||
|
||||
(add-to-list 'dashboard-items '(buffers . 5) t)
|
||||
;; (add-to-list 'dashboard-items '(custom) t)
|
||||
|
||||
|
||||
;; needs package ‘all-the-icons’
|
||||
(setq dashboard-set-heading-icons t)
|
||||
(setq dashboard-set-file-icons t)
|
||||
(dashboard-setup-startup-hook))
|
||||
|
||||
(use-package indent-guide
|
||||
:delight (indent-guide-mode "Ⓘg")
|
||||
:hook (prog-mode . indent-guide-mode) ;; problem if used in notmuch
|
||||
:config
|
||||
(set-face-attribute 'indent-guide-face nil :foreground "DarkSlateGray") ;; foreground #535353
|
||||
;;(setq indent-guide-char ":")
|
||||
(setq indent-guide-char "\u2502")
|
||||
(setq indent-guide-recursive t) ;; NOT RECOMMENDED: To show not only one guide line but all guide lines recursively, set indent-guide-recursive non-nil.
|
||||
)
|
||||
|
||||
;; problem when using 'character in elisp it inserts the guide characters when inserting text before guide characters
|
||||
;; (use-package highlight-indent-guides
|
||||
;; :delight (highlight-indent-guides-mode "Ⓘg")
|
||||
;; :hook (prog-mode . highlight-indent-guides-mode)
|
||||
;; :config
|
||||
;; (setq highlight-indent-guides-method 'character) ;; 'fill 'character 'bitmap
|
||||
;; (setq highlight-indent-guides-character ?:) ;; ?:
|
||||
;; (setq highlight-indent-guides-auto-enabled nil) ;; deactivate auto colors
|
||||
;; (set-face-foreground 'highlight-indent-guides-character-face "gray30")
|
||||
;; )
|
||||
|
||||
(use-package rainbow-mode
|
||||
:delight (rainbow-mode "Ⓡ") ;; " Rbow"
|
||||
:commands rainbow-mode)
|
||||
|
||||
(use-package focus
|
||||
:commands focus-mode
|
||||
:custom-face (focus-unfocused ((t :inherit shadow))))
|
||||
|
||||
(use-package virtual-auto-fill
|
||||
:delight (virtual-auto-fill-mode "Ⓥf")
|
||||
:commands virtual-auto-fill-mode
|
||||
;;:hook (help-mode . virtual-auto-fill-mode)
|
||||
)
|
||||
|
||||
(provide 'gui-settings)
|
||||
;;; gui-settings.el ends here
|
||||
90
settings/which-key-settings.el
Normal file
90
settings/which-key-settings.el
Normal file
@@ -0,0 +1,90 @@
|
||||
;;; which-key-settings.el --- which-key settings -*- mode: emacs-lisp; lexical-binding: t -*-
|
||||
|
||||
;;; Commentary:
|
||||
;; https://melpa.org/#/which-key
|
||||
;; https://github.com/justbur/emacs-which-key
|
||||
|
||||
;;; Code:
|
||||
;; variables which needs to be set before loading which-key-mode
|
||||
;; https://github.com/justbur/emacs-which-key#manual-activation
|
||||
;;(setq which-key-show-early-on-C-h t) ;; Allow C-h to trigger which-key before it is done automatically
|
||||
(use-package which-key
|
||||
:delight (which-key-mode "Ⓚ") ;; Ⓚ K
|
||||
:init
|
||||
(setq which-key-idle-delay 1.0)
|
||||
(setq which-key-idle-secondary-delay 0.05)
|
||||
;;(setq which-key-unicode-correction 3)
|
||||
|
||||
(when (daemonp)
|
||||
;; problem if using unicodes and emacsclient, the last line of which-key side-frame is cropped.
|
||||
(setq which-key-dont-use-unicode t)
|
||||
)
|
||||
:config
|
||||
(which-key-mode)
|
||||
(unless (daemonp)
|
||||
;; problem if using unicodes and emacsclient, the last line of which-key side-frame is cropped.
|
||||
(add-to-list 'which-key-replacement-alist '(("TAB" . nil) . ("↹" . nil)))
|
||||
(add-to-list 'which-key-replacement-alist '(("RET" . nil) . ("⏎" . nil)))
|
||||
(add-to-list 'which-key-replacement-alist '(("DEL" . nil) . ("⇤" . nil)))
|
||||
(add-to-list 'which-key-replacement-alist '(("SPC" . nil) . ("␣" . nil)))
|
||||
(add-to-list 'which-key-replacement-alist '(("<up>" . nil) . ("↑" . nil)))
|
||||
(add-to-list 'which-key-replacement-alist '(("<down>" . nil) . ("↓" . nil)))
|
||||
;;(add-to-list 'which-key-replacement-alist '(("<left>" . nil) . ("←" . nil))) ; already in
|
||||
;;(add-to-list 'which-key-replacement-alist '(("<right>" . nil) . ("→" . nil))) ; already in
|
||||
(setq which-key-special-keys '("SPC" "TAB" "RET" "ESC" "DEL")) ;; automatically truncated to one character
|
||||
)
|
||||
|
||||
;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Creating-Keymaps.html#Creating-Keymaps
|
||||
(setq meta-m-map (make-sparse-keymap))
|
||||
(define-prefix-command 'meta-m-map) ;; define new prefix
|
||||
(global-set-key (kbd "M-m") 'meta-m-map) ;; set new prefix to M-m
|
||||
;;(global-set-key (kbd "M-m SPC") 'counsel-M-x) ;; TODO
|
||||
(global-set-key (kbd "M-m h k") 'which-key-show-top-level)
|
||||
(global-set-key (kbd "M-m t K") 'which-key-mode)
|
||||
|
||||
;; define prefix names
|
||||
;; formaly which-key-declare-prefixes
|
||||
;; blob/c7a103a772d808101d7635ec10f292ab9202d9ee/layers/%2Bdistributions/spacemacs-base/packages.el
|
||||
(which-key-add-key-based-replacements
|
||||
"M-m" '("root" . "My root")
|
||||
"M-m a" "applications"
|
||||
"M-m b" "buffers"
|
||||
"M-m c" "compile/comments"
|
||||
"M-m e" "errors"
|
||||
"M-m f" "files"
|
||||
"M-m f v" "variables"
|
||||
"M-m h" "help"
|
||||
"M-m h d" "describe"
|
||||
"M-m j" "jump/join/split"
|
||||
"M-m m" '("major-mode-cmd" . "Major mode commands")
|
||||
"M-m M-m" "M-x"
|
||||
"M-m n" "narrow/numbers"
|
||||
"M-m q" "quit"
|
||||
"M-m s" "misc."
|
||||
"M-m s m" "multiple-cursors"
|
||||
"M-m s m s" "specials"
|
||||
"M-m t" "toggles"
|
||||
"M-m t h" "highlight"
|
||||
"M-m t m" "modeline"
|
||||
"M-m T" "UI toggles/themes"
|
||||
"M-m w" "windows"
|
||||
"M-m x" "text"
|
||||
"M-m x a" "align"
|
||||
"M-m x d" "delete"
|
||||
"M-m x j" "justification"
|
||||
"M-m x l" "lines"
|
||||
"M-m x t" "transpose"
|
||||
)
|
||||
(which-key-add-major-mode-key-based-replacements 'python-mode
|
||||
"M-m m c" "execute"
|
||||
"M-m m d" "debug"
|
||||
"M-m m s" "REPL" ;; REPL read-eval-print-loop / interactive toplevel / language shell
|
||||
)
|
||||
|
||||
;;(set-face-foreground 'font-lock-keyword-face "Purple")
|
||||
;;(set-face-attribute 'which-key-group-description-face nil :inherit nil)
|
||||
;;(set-face-attribute 'which-key-group-description-face nil :inherit font-lock-keyword-face)
|
||||
)
|
||||
|
||||
(provide 'which-key-settings)
|
||||
;;; which-key-settings.el ends here
|
||||
Reference in New Issue
Block a user