X-Git-Url: https://iankelling.org/git/?p=dot-emacs;a=blobdiff_plain;f=init.el;fp=init.el;h=82a989f00cd528e1b1f59c98655b91e84b6a0a28;hp=4855c41e3683d550e0a02ef607eb35299e546e98;hb=7eb513e9af272398381074ed7792a9f40546b4b4;hpb=74067d92342d66f294e40d254bc4d13418f1b62e diff --git a/init.el b/init.el index 4855c41..82a989f 100644 --- a/init.el +++ b/init.el @@ -23,6 +23,7 @@ ;;(toggle-debug-on-error) ;uncomment to help debug + ;; stop from minimizing & freezing the gui ;; used to freeze emacs and was really annoying, ;; seems its changed now. no harm in keeping this though. @@ -346,9 +347,9 @@ (list (format "LC_INSIDE_EMACS=%s,comint" emacs-version)) process-environment)) (default-directory - (if (file-accessible-directory-p default-directory) - default-directory - "/")) + (if (file-accessible-directory-p default-directory) + default-directory + "/")) proc decoding encoding changed) (let ((exec-path (if (and command (file-name-directory command)) ;; If the command has slashes, make sure we @@ -513,8 +514,9 @@ A non-nil CURRENT-ONLY argument means save only current buffer." "Backup conditioned on some time passing since last one. Hooked into 'before-save-hook." (cl-flet ((b-time (minutes) - (< last-backup-time - (- (current-time) (* 60 minutes))))) + (< last-backup-time + ;; current-time is seconds, so convert minutes to seconds. + (- (current-time) (* 60 minutes))))) (when (or (not (boundp 'last-backup-time)) (and (< (buffer-size) 10000000) (b-time 5)) (b-time 30)) (setq buffer-backed-up nil) (setq-local last-backup-time (current-time))))) @@ -620,7 +622,6 @@ A non-nil CURRENT-ONLY argument means save only current buffer." - ;;; cross session settings (use-package recentf @@ -634,6 +635,8 @@ A non-nil CURRENT-ONLY argument means save only current buffer." (setq recentf-max-saved-items 400 recentf-max-menu-items 15) ) +;; save it every 5 minutes. https://www.emacswiki.org/emacs/RecentFiles +(run-at-time nil (* 5 60) 'recentf-save-list) (use-package saveplace :unless noninteractive @@ -661,6 +664,31 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ;; dired - reuse current buffer by pressing 'a' (put 'dired-find-alternate-file 'disabled nil) + +;; copied from dired-x info manual +(with-eval-after-load 'dired + (require 'dired-x) + ;; use e instead for find file. i would like + ;; dired-do-async-shell-command, except it pops open some async + ;; shell buffer. i should figure out how to get rid of that. + (define-key dired-mode-map "f" 'dired-do-shell-command) + ;; Set dired-x global variables here. For example: + ;; (setq dired-guess-shell-gnutar "gtar") + ;; (setq dired-x-hands-off-my-keys nil) + ) +(add-hook 'dired-mode-hook + (lambda () + ;; Set dired-x buffer-local variables here. For example: + ;; (dired-omit-mode 1) + )) + +;; the defaults are just some weird predefined list, like xpdf for pdf. +(setq dired-guess-shell-alist-user + (list + (list ".*" "xdg-open") + )) + + ;;; elisp settings ;; when manually evaluating lisp, go into debugger on error (setq eval-expression-debug-on-error t) @@ -754,11 +782,11 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ;; Activate occur easily inside isearch (define-key isearch-mode-map (kbd "C-o") - (lambda () (interactive) - (let ((case-fold-search isearch-case-fold-search)) - (occur (if isearch-regexp - isearch-string - (regexp-quote isearch-string)))))) + (lambda () (interactive) + (let ((case-fold-search isearch-case-fold-search)) + (occur (if isearch-regexp + isearch-string + (regexp-quote isearch-string)))))) ;;; lisp / elisp mode setings (add-hook 'emacs-lisp-mode-hook 'starter-kit-remove-elc-on-save) @@ -793,6 +821,8 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ;;; modes with little configuration needed + + (custom-set-variables '(css-indent-offset 2) '(sh-here-document-word "'EOF'") @@ -864,7 +894,10 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ;; be pasting whitespace significant things in here, so ;; just don't do anything. ;; todo: propose this upstream +;; fundamental mode for files like .asc (add-to-list 'ws-butler-global-exempt-modes 'message-mode) +(add-to-list 'ws-butler-global-exempt-modes 'dns-mode) +(add-to-list 'ws-butler-global-exempt-modes 'fundamental-mode) (ws-butler-global-mode) @@ -986,6 +1019,12 @@ A non-nil CURRENT-ONLY argument means save only current buffer." (customize-set-variable 'tramp-use-ssh-controlmaster-options nil) (setq + ;; avoid this stupid prompt when doing sudo-edit + ;; Save auth info to file ~/.authinfo? [y/n/N/e/?] + ;; which doesn't actually use the default N by pressing enter, + ;; and doesn't actually save the 'never' setting like it claims. + ;; todo: file a bug. + auth-source-save-behavior nil auto-revert-interval 2 ;; fix eof end of file newline mode-require-final-newline t @@ -1001,8 +1040,18 @@ A non-nil CURRENT-ONLY argument means save only current buffer." paragraph-start "\f\\|[ \t]*$\\|[ \t]*[-+*] " sh-basic-offset 2 vc-follow-symlinks t + dired-confirm-shell-command nil + dired-deletion-confirmer '(lambda (x) t) + dired-listing-switches "-alh" + dired-recursive-deletes 'always + dired-clean-confirm-killing-deleted-buffers nil + undo-outer-limit 100000000 ; per undo command + undo-limit 500000000 ; undo history limit + undo-strong-limit 600000000 ; undo history limit plus some extra ) + + (ivy-mode 1) (add-hook 'text-mode-hook (lambda () (auto-fill-mode t))) (setq counsel-find-file-at-point t) @@ -1052,7 +1101,6 @@ A non-nil CURRENT-ONLY argument means save only current buffer." (setq font-lock-maximum-decoration t inhibit-startup-message t transient-mark-mode t - delete-by-moving-to-trash t shift-select-mode nil truncate-partial-width-windows nil uniquify-buffer-name-style 'forward @@ -1081,7 +1129,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer." indicate-empty-lines t) ; mark end of buffer -(blink-cursor-mode '(-4)) +(blink-cursor-mode 0) (menu-bar-mode -1) (tool-bar-mode -1) @@ -1597,11 +1645,39 @@ or else the number of characters matched by `outline-regexp'." ;; if I could define overlay faces to use inverse foreground color +;; (setq comment-start "
 ") + (setq comment-padding " ") + (setq fill-column 50) + ;; (setq fill-column 30) + (mark-paragraph) + ;; (call-interactively 'uncomment-region) + (fill-paragraph) + (call-interactively 'comment-region) + (deactivate-mark) + (save-excursion + (goto-char (region-beginning)) + (next-line) + (comment-line 1) + ) + ) + +;; (chirp) +(defun chirp() + (message "chirp nothing")) ;;; znc/erc (defun chirp() (interactive) - (setq vol 20) - (when (string= (system-name) "kd") (setq vol 80)) + (setq vol 80) + (when (string= (system-name) "kd") (setq vol 60)) ;; speed is there so i can adjust and make it go slow so it plays long enough to adjust in pavucontrol (start-process-shell-command "ignoreme" nil (format "mpv --speed=1 --no-terminal --vo=null --volume=%d /a/bin/data/bird.mp3" vol))) ;; from https://www.emacswiki.org/emacs/ErcSound @@ -1678,26 +1754,27 @@ or else the number of characters matched by `outline-regexp'." undo-strong-limit 600000000) ; undo history limit plus some extra -;;; undo tree mode +;;; undo-fu mode + +;; thank god i'm done with undo-tree and the bug where my auto-saveing +;; would cause it to lose all undo history, strangely especially in +;; email buffers. it would claim the undo was outside the visible +;; buffer. -;; note, this has weird errors when it was before recentf-mode +(use-package undo-fu + :config + (global-unset-key (kbd "C-z"))) -(use-package undo-tree +(use-package undo-fu-session :config - ;; more resilient undo-tree-history if we have its location set up front. - (setq undo-tree-history-directory-alist '(("." . (concat user-emacs-directory ".undo-tree-history"))) - undo-outer-limit 100000000 ; per undo command - undo-limit 500000000 ; undo history limit - undo-strong-limit 600000000 ; undo history limit plus some extra - ;; Undo in region just happens accidentally, and throws me off - undo-tree-enable-undo-in-region nil) - ;; disabled due to bug, something like unknown entry in undo tree canary - ;; (setq undo-tree-auto-save-history t) - - ;; todo, send patch undo-tree-visualize should scroll with the scroll key, instead of just pgup pgdn (aka next/prior) - (global-undo-tree-mode) - ;; simple way to fix that enable undo-tree starts out disabled in org-mode - (defun undo-tree-overridden-undo-bindings-p() nil)) + (setq undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" "/git-rebase-todo\\'"))) + +(unless (equal (user-uid) 0) ; don't make root owned files + (global-undo-fu-session-mode) + (when (file-exists-p "/p/c/undo-fu-session") + (setq undo-fu-session-directory "/p/c/undo-fu-session")) + ) + ;;; keybinds @@ -1714,11 +1791,11 @@ or else the number of characters matched by `outline-regexp'." ;; from starter-kit (define-key isearch-mode-map (kbd "C-o") - (lambda () (interactive) - (let ((case-fold-search isearch-case-fold-search)) - (occur (if isearch-regexp - isearch-string - (regexp-quote isearch-string)))))) + (lambda () (interactive) + (let ((case-fold-search isearch-case-fold-search)) + (occur (if isearch-regexp + isearch-string + (regexp-quote isearch-string)))))) (defun my-isearch-toggle-regexp () @@ -1792,10 +1869,16 @@ or else the number of characters matched by `outline-regexp'." (global-set-key (kbd "") 'back-to-indentation-or-beginning) ;;;;; s-tab - indent-buffer -;; graphical -(global-set-key (kbd "") 'indent-buffer) -;; terminal +;; This is translated from S- in graphicsal mode. previously, I had +;; also set (kbd ""), +;; But I stopped because it overrides minor mode mappings, and i don't want to do that, at least not only in graphical mode. +;; (global-set-key (kbd "") 'indent-buffer) + +(add-hook 'org-mode-hook + (lambda () + (define-key org-mode-map (kbd "") nil))) + ;;;;; s-delete - send-shell (global-set-key (kbd "") 'send-shell) @@ -2119,7 +2202,7 @@ modes like org-mode which have their own yank function." (global-set-key (kbd "C-M-3") 'recenter-top-bottom) -;;;;; C-q org-cycle, comint previous arg +;;;;; C-q org/bicycle-cycle, comint previous arg (global-set-key (kbd "C-q") 'bicycle-cycle) (add-hook 'org-mode-hook @@ -2128,7 +2211,13 @@ modes like org-mode which have their own yank function." (add-hook 'comint-mode-hook (lambda () (define-key comint-mode-map (kbd "C-q") 'comint-insert-previous-argument))) -;;;;; M-q ?? unused +;;;;; M-q org/bicycle-cycle global + +(add-hook 'org-mode-hook + (lambda () + (define-key org-mode-map (kbd "M-q") 'org-shifttab))) +(global-set-key (kbd "M-q") 'bicycle-cycle-global) + ;;;;; C-M-q quoted-insert (global-set-key (kbd "C-M-q") 'quoted-insert) @@ -2287,7 +2376,8 @@ modes like org-mode which have their own yank function." (global-set-key (kbd "C-M-g") 'mu4e) ;;;;; C-z - undo-only -(global-set-key (kbd "C-z") 'undo-tree-undo) +;;(global-set-key (kbd "C-z") 'undo-tree-undo) +(global-set-key (kbd "C-z") 'undo-fu-only-undo) ;;;;; C-M-z - suspend-frame (global-set-key (kbd "C-M-z") 'suspend-frame) ;; this is never good in a gui @@ -2325,8 +2415,10 @@ modes like org-mode which have their own yank function." ;;;;; C-c - copy (global-set-key (kbd "C-d") 'kill-ring-save) -(add-hook 'c-mode-hook - (lambda () (define-key c-mode-map (kbd "C-d") nil))) +(add-hook 'c-mode-common-hook + (lambda () + (define-key c-mode-map (kbd "C-d") nil) + (define-key c++-mode-map (kbd "C-d") nil))) (add-hook 'comint-mode-hook (lambda () (define-key comint-mode-map (kbd "C-d") nil))) @@ -2654,8 +2746,6 @@ modes like org-mode which have their own yank function." (global-set-key (kbd "C-_") 'vim-style-join-line) ;; gui (global-set-key (kbd "C-/") 'vim-style-join-line) -(define-key undo-tree-map (kbd "C-/") nil) -(define-key undo-tree-map (kbd "C-_") nil) ;;;;; C-M-/ - copy-buffer-file-name @@ -2804,6 +2894,8 @@ modes like org-mode which have their own yank function." (lambda () (define-key org-mode-map (kbd "C-t") 'org-todo))) + + (defun my-comint-previous-input (arg) (interactive "*p") (if (comint-after-pmark-p) @@ -2850,7 +2942,7 @@ modes like org-mode which have their own yank function." ;;;;; C-home - start of buffer ;;;;; C-end - end of buffer ;;;; right secondary -;;;;; C-^ - save-buffers-kill-emacs +;;;;; C-^ - save-buffers-kill-emacs exit quit (global-set-key (kbd "C-^") 'save-buffers-kill-emacs) @@ -2927,7 +3019,8 @@ modes like org-mode which have their own yank function." ;;;;; C-M-- - org-edit-src-exit ;;;;; C-y - undo -(global-set-key (kbd "C-y") 'undo-tree-redo) +;;(global-set-key (kbd "C-y") 'undo-tree-redo) +(global-set-key (kbd "C-y") 'undo-fu-only-redo) (add-hook 'org-mode-hook (lambda () (define-key org-mode-map (kbd "C-y") nil)))