X-Git-Url: https://iankelling.org/git/?p=dot-emacs;a=blobdiff_plain;f=init.el;h=25d0445fb10b2a915f648e865207ba2057a5fe22;hp=61e347ecc8edfbf4c4a5654b8d923d40b436a663;hb=HEAD;hpb=38ab2149c487ef7ea4c99d1cdc321fa9065ab2c3 diff --git a/init.el b/init.el index 61e347e..e91121d 100644 --- a/init.el +++ b/init.el @@ -14,13 +14,14 @@ ;; along with this program. If not, see . ;; do m-x benchmark-init to see some benchmark stats -;;(add-to-list 'load-path "~/.emacs.d/src/benchmark-init-el/") +;;(add-to-list 'load-path (concat user-emacs-directory "src/benchmark-init-el/") ;;(require 'benchmark-init-loaddefs) ;;(benchmark-init/activate) ;;; init.el --- the start of customization -(toggle-debug-on-error) ;uncomment to help debug +;;(toggle-debug-on-error) ;uncomment to help debug + ;; stop from minimizing & freezing the gui @@ -46,11 +47,16 @@ ;; taken from wiegley, dunno why the t is there. t) +;; stuff to allow an alternate location for ~/.emacs.d +(setq user-emacs-directory (file-name-directory user-init-file)) +(when (getenv "EHOME") + (setenv "HOME" (getenv "EHOME"))) + ;; 2019-6-26, 1.26s ;; ; to profile init: ;; ; uncomment the following block -(require 'benchmark-init) -(add-hook 'after-init-hook 'benchmark-init/deactivate) +;;(require 'benchmark-init) +;;(add-hook 'after-init-hook 'benchmark-init/deactivate) ;; ; Then run: ;; ; emacs -f benchmark-init/show-durations-tabulated ;; ; emacs -f benchmark-init/show-durations-tree @@ -60,18 +66,13 @@ ;; these need to be done before the hook in order to satisfy the byte compiler or batch mode -;; this is the builtin org mode -;;(add-to-list 'load-path "~/.emacs.d/emacs/site-lisp/org") - -(add-to-list 'load-path "~/.emacs.d/src/readline-complete") +(add-to-list 'load-path (concat user-emacs-directory "src/readline-complete")) ;; disabled since not used. -;;(add-to-list 'load-path "~/.emacs.d/src/bbdb-csv-import") -;;(add-to-list 'load-path "~/.emacs.d/src/ghci-completion") -;;(add-to-list 'load-path "~/.emacs.d/src/mediawiki-el") -;;(add-to-list 'load-path "~/.emacs.d/src/spray") +;;(add-to-list 'load-path (concat user-emacs-directory "src/bbdb-csv-import")) +;;(add-to-list 'load-path (concat user-emacs-directory "src/spray")) -(add-to-list 'load-path "~/.emacs.d/src/visible-mark") +(add-to-list 'load-path (concat user-emacs-directory "src/visible-mark")) @@ -207,7 +208,8 @@ ;; from its README.md (eval-when-compile (require 'use-package)) - +(use-package use-package-ensure-system-package + :ensure t) ;; Ubiquitous Packages. these could go anywhere actually @@ -231,7 +233,7 @@ ;; keep our init.el clean, by moving customization elisp to it's own file -(setq custom-file "~/.emacs.d/custom.el") +(setq custom-file (concat user-emacs-directory "custom.el")) ;; empty atm ;;(load custom-file 'noerror) @@ -242,13 +244,15 @@ ;; disabled while I look for another alternative ;;(icomplete-mode) +(unless (string= (daemonp) "server") + (setq ac-use-comphist nil)) (require 'auto-complete-config) (ac-config-default) ;; complete after 1 char instead of default 2 -(setq ac-auto-start 1) -(setq ac-delay 0.001) +(setq ac-auto-start 1 + ac-delay 0.001) (add-to-list 'ac-modes 'org-mode 'sql-mode) @@ -345,9 +349,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 @@ -512,8 +516,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))))) @@ -572,17 +577,36 @@ A non-nil CURRENT-ONLY argument means save only current buffer." (defun toggle-night () (interactive) (cond ((equal (car custom-enabled-themes) 'naquadah) - (override-theme 'leuven)) + (override-theme 'ef-light)) (t (override-theme 'naquadah)))) +(setq ef-themes-mixed-fonts t + ef-themes-variable-pitch-ui t) + ;; in the leuven theme file, i made this change. will need to remake it ;; on package updates. I could fork, but its a pretty simple change ;; < `(default ((,class (:foreground "#333333" :background "#FFFFFF")))) ;; > `(default ((,class (:foreground "#333333" :background "#F6F6F0")))) -(override-theme 'leuven) +;; +;; < `(font-lock-comment-face ((,class (:slant italic :foreground "#8D8D84")))) ; #696969 +;; > `(font-lock-comment-face ((,class (:slant italic :foreground "#484848")))) ; #696969 + +;;(override-theme 'leuven) + +;; based on ef-themes README.org +(mapc #'disable-theme custom-enabled-themes) +;; the default blue is too dark and messes with erc colors +(setq ef-light-palette-overrides + '((bg-mode-line "#efefef"))) +(ef-themes-select 'ef-light) +;;(load-theme 'ef-light) + +;; for learning about faces, see +;; useful snippet +;; (byte-recompile-file "/home/iank/.emacs.d/elpa/leuven-theme-20220203.947/leuven-theme.el" nil 0) ;; disable color thing with this: ;;(disable-theme (car custom-enabled-themes)) @@ -619,12 +643,14 @@ A non-nil CURRENT-ONLY argument means save only current buffer." - ;;; cross session settings + + (use-package recentf ;; defer & commands from jwiegley :defer 10 + :if (string= (daemonp) "server") :commands (recentf-mode recentf-add-file recentf-apply-filename-handlers) @@ -634,25 +660,30 @@ A non-nil CURRENT-ONLY argument means save only current buffer." recentf-max-menu-items 15) ) +(when (string= (daemonp) "server") + ;; save it every 5 minutes. https://www.emacswiki.org/emacs/RecentFiles + (run-at-time nil (* 5 60) 'recentf-save-list)) + +;; less strong conditional: :unless noninteractive (use-package saveplace - :unless noninteractive + :if (string= (daemonp) "server") :config (setq save-place-version-control 'nospecial save-place-limit 4000 - save-place-file "~/.emacs.d/places") + save-place-file (concat user-emacs-directory "places")) (save-place-mode 1)) ;; savehist keeps track of some history search entries (use-package savehist - :unless noninteractive + :if (string= (daemonp) "server") :config (setq savehist-additional-variables '(kill-ring search-ring regexp-search-ring) ;; save every minute savehist-autosave-interval 60 ;; keep the home clean - savehist-file "~/.emacs.d/.savehist") + savehist-file (concat user-emacs-directory ".savehist")) (savehist-mode 1)) ;;; dired @@ -660,6 +691,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) @@ -753,11 +809,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) @@ -792,6 +848,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'") @@ -845,7 +903,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ;; and a function ;; inspired by mu4e info manual, search for mu4e-compose-pre-hook. (when (file-exists-p "/p/c/mymu4e.el") - (load "/p/c/mymu4e.el")) + (load "/p/c/mymu4e")) (when (file-exists-p "/a/h/iank-mod.el") @@ -863,7 +921,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) @@ -914,7 +975,6 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ;; show the name of the current function definition in the modeline -(setq which-func-modes t) (which-function-mode 1) ;; enable winner-mode to manage window configurations @@ -944,7 +1004,6 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ;; todo, turn on auto-fill just for txt files ;;(add-hook 'text-mode-hook 'turn-on-auto-fill) -(add-hook 'text-mode-hook 'turn-on-flyspell) ;; random extra highlights (require 'volatile-highlights) @@ -986,6 +1045,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 +1066,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,11 +1127,10 @@ 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 - oddmuse-directory "~/.emacs.d/oddmuse" + oddmuse-directory (concat user-emacs-directory "oddmuse") echo-keystrokes 0.1 mark-ring-max 160 sort-fold-case t ; case insensitive line sorting @@ -1080,20 +1154,8 @@ A non-nil CURRENT-ONLY argument means save only current buffer." imenu-auto-rescan t indicate-empty-lines t) ; mark end of buffer -(require 'smooth-scroll) -;; long gnus summary buffers lags too much with this, -;; but I like it enough to leave it enabled by default -;; and crank up the step size to be faster -;; and it doesn't have a way to enable it only for certain modes etc. -;; todo sometime, make it work for certain modes only -(smooth-scroll-mode t) -;; its too slow with the default of 2 -(setq smooth-scroll/vscroll-step-size 6) -;; sublimity doesn't work as good going fast by default -;; smooth-scrolling.el, does not do smooth scrolling. its about cursor location - -(blink-cursor-mode '(-4)) +(blink-cursor-mode 0) (menu-bar-mode -1) (tool-bar-mode -1) @@ -1277,7 +1339,7 @@ Go to the next directory based on where the cursor is." ;;; org mode -;; todo work on org-cycle-emulate-tab + ;; todo, this doesn't work for a non-standard keybind ;;(setq org-special-ctrl-k t) @@ -1327,6 +1389,8 @@ Go to the next directory based on where the cursor is." org-global-properties (quote (("STYLE_ALL" . "habit"))) org-special-ctrl-a/e t ;; home and end work special in headlines org-completion-use-ido t + ;; i had some problem with this in the past, but don't know what, so whatever. + org-cycle-emulate-tab nil org-catch-invisible-edits 'smart) (setq @@ -1367,6 +1431,7 @@ Go to the next directory based on where the cursor is." (defun variable-pitch-off () (variable-pitch-mode 0)) (add-hook 'yaml-mode-hook 'variable-pitch-off) +(add-hook 'dns-mode-hook 'variable-pitch-off) (defun my-org-face-init() @@ -1416,6 +1481,8 @@ Go to the next directory based on where the cursor is." ;; so that I can do completion before the dialog pops up ;;(local-set-key (kbd "") 'auto-complete) (local-set-key (kbd "TAB") 'auto-complete) + (define-key emacs-lisp-mode-map (kbd "M-q") nil) + ;; todo, this is causing error message on loading file, prolly not working ;;(flycheck-mode +1) (setq ac-sources (delq 'ac-source-dictionary ac-sources)) @@ -1435,8 +1502,6 @@ Go to the next directory based on where the cursor is." nil)))))) (add-hook 'prog-mode-hook 'prog-mode-defaults) -;; enable flyspell in prog mode. text mode is handled -(add-hook 'prog-mode-hook 'flyspell-prog-mode) ;;; yank auto-indent @@ -1485,6 +1550,23 @@ indent yanked text (with prefix arg don't indent)." ;; # eval: (outline-minor-mode) ;; # outline-regexp: "\\( *\\)# [*]\\{1,8\\} " +(defun outline-level () + "Return the depth to which a statement is nested in the outline. +Point must be at the beginning of a header line. +This is actually either the level specified in `outline-heading-alist' +or else the number of characters matched by `outline-regexp'." + (or (cdr (assoc (match-string 0) outline-heading-alist)) + (let ((whitespace-end (match-end 1)) + (match-begin (match-beginning 0))) + (if (= whitespace-end match-begin) + (- (match-end 0) match-begin) + (- (match-end 0) whitespace-end) + )))) +;; originally: +;;(or (cdr (assoc (match-string 0) outline-heading-alist)) +;; (- (match-end 0) (match-beginning 0)))) + + ;; avoid stupid git crap like "warning, terminal not fully functional" (setenv "PAGER" "cat") @@ -1533,6 +1615,10 @@ indent yanked text (with prefix arg don't indent)." :defer t) ;; rw-hunspell sets up hunspell dictionary automagically. +(use-package flyspell + :ensure-system-package hunspell + :hook ((prog-mode . flyspell-prog-mode) + (text-mode . turn-on-flyspell))) ;; Rant: Hunspell SHOULD be standard. its used by firefox and openoffice and ;; osx. In contrast, the first few words I added to aspell dictionary were @@ -1589,20 +1675,48 @@ indent yanked text (with prefix arg don't indent)." ;; 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 50) - (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))) + (start-process-shell-command "ignoreme" nil (format "mpv --speed=1 --no-terminal --vo=null --volume=%d /a/bin/data/d20.wav" vol))) ;; from https://www.emacswiki.org/emacs/ErcSound (defun chirp-slow() (interactive) (setq vol 50) (when (string= (system-name) "tp") (setq vol 80)) ;; 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=.2 --no-terminal --vo=null --volume=%d /a/bin/data/bird.mp3" vol))) + (start-process-shell-command "ignoreme" nil (format "mpv --speed=.2 --no-terminal --vo=null --volume=%d /a/bin/data/d20.wav" vol))) (defun erc-my-privmsg-sound (proc parsed) (let* ((tgt (car (erc-response.command-args parsed))) @@ -1616,9 +1730,18 @@ indent yanked text (with prefix arg don't indent)." (unless (string-match "Server:[0-9]+" nickuserhost) (chirp))) +(defun erc-sound-if-not-server (match-type nickuserhost msg) + ;; (message "d1 %s" nickuserhost) + (unless (or (string-match-p "Server:[0-9]+" nickuserhost) (string-match-p "leah" nickuserhost)) + (chirp))) + (use-package erc :defer t + :custom-face + (erc-current-nick-face ((t :weight bold :foreground "red"))) :init + (which-function-mode 0) + ;; fuck that default turquoise (setq erc-fill-prefix "" ;; consider invisible frames to be unseen. seems like an obvious default erc-track-visibility 'visible @@ -1626,13 +1749,78 @@ indent yanked text (with prefix arg don't indent)." erc-track-switch-direction 'importance ;; defaults minus fill. todo: modify the list instead of specifying it explicitly in case the defaults change erc-modules - '(autojoin button completion irccontrols list match menu move-to-prompt netsplit networks noncommands readonly ring stamp track) - ) ; end setq - :config - (add-hook 'erc-server-PRIVMSG-functions - 'erc-my-privmsg-sound) - (add-hook 'erc-text-matched-hook 'erc-sound-if-not-server) - (erc-track-mode 1)) + '(autojoin button completion imenu irccontrols list match menu move-to-prompt netsplit networks noncommands readonly ring stamp track) + ;; expanded from https://www.emacswiki.org/emacs/ErcChannelTracking, + ;; ignore various messages + erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE" + "324" "329" "332" "333" "353") + ;; seems good, i don't care about the server buffer generally + erc-track-exclude-server-buffer t + ;; dont highlight channels just cuz of new messages, except for pms or some new channel I haven't listed in my config. + + erc-track-shorten-cutoff 40 + ;; sed -rn 's/.*(#[^>]*).*/"\1"/p' /p/c/machine_specific/li/filesystem/var/lib/znc/configs/znc.conf + erc-track-priority-faces-only (list + "#conservancy" + "#fosdem" + "#fsf" + "#fsf-licensing" + "#fsfe" + "#fsfsys" + "#gnu" + "#librecmc" + "#libreplanet" + "#mnt-reform" + "#nouveau" + "#pump.io" + "#savannah" + "#seagl" + "#social" + "#spamassassin" + "#talos-workstation" + "#trisquel" + "#trisquel-dev" + "#overseers" + "#gdb" + "#gcc" + "#glibc" + "#binutils" + "#gnu-linux-libre" + "#parabola" + "#guix" + "#gnu-ops" + "#gcc" + ) + ;; so that we don't show channels where i havent been mmentioned + erc-track-faces-priority-list '(erc-current-nick-face + erc-keyword-face + erc-pal-face + erc-nick-msg-face + erc-direct-msg-face + erc-fool-face) + + + ) ; end setq + +:config +(add-hook 'erc-server-PRIVMSG-functions + 'erc-my-privmsg-sound) +(add-hook 'erc-text-matched-hook 'erc-sound-if-not-server) +(erc-track-mode 1) +(defun erc-track--switch-buffer (fun arg) + (if (not erc-track-mode) + (message (concat "Enable the ERC track module if you want to use the" + " tracking minor mode")) + (cond (erc-modified-channels-alist + ;; if we're not in erc-mode, set this buffer to return to + (if-let ((buf (erc-track-get-active-buffer arg)) + ((buffer-live-p buf))) + (funcall fun buf) + (erc-modified-channels-update) + (erc-track--switch-buffer fun arg))) + ;; if no active channels, switch back to what we were doing before + (t (switch-to-buffer "#fsfsys"))))) +) ;;; named commands (defun rm-file-and-buffer () "Removes file connected to current buffer and kills buffer." @@ -1655,8 +1843,8 @@ indent yanked text (with prefix arg don't indent)." ;; worth the benefit of only having one concept in my mind. (dolist (r `( - (?i (file . ,"~/.emacs.d/init.el")) - (?o (file . ,"/a/work.org")) + (?i (file . ,(concat user-emacs-directory "init.el"))) + (?o (file . ,"/b/w/work.org")) (?t (file . ,"/a/t.org")) (?s (file . ,"/usr/share/doc/exim4-base/spec.txt.gz")) (?w (file . ,"/p/w.org")) @@ -1670,26 +1858,29 @@ indent yanked text (with prefix arg don't indent)." undo-strong-limit 600000000) ; undo history limit plus some extra -;;; undo tree mode +;;; undo-fu mode -;; note, this has weird errors when it was before recentf-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. -(use-package undo-tree +(use-package undo-fu :config - ;; more resilient undo-tree-history if we have its location set up front. - (setq undo-tree-history-directory-alist '(("." . "~/.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)) + (global-unset-key (kbd "C-z"))) + +(use-package undo-fu-session + :if (string= (daemonp) "server") + :config + (setq undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" "/git-rebase-todo\\'"))) + +(when (string= (daemonp) "server") + (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 @@ -1706,11 +1897,11 @@ indent yanked text (with prefix arg don't indent)." ;; 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 () @@ -1784,10 +1975,16 @@ indent yanked text (with prefix arg don't indent)." (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) @@ -2111,7 +2308,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 @@ -2120,7 +2317,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) @@ -2170,6 +2373,8 @@ modes like org-mode which have their own yank function." (define-key comint-mode-map (kbd "C-r") 'comint-history-isearch-backward-regexp))) ;;;;; M-r ?? unused + + ;;;;; C-a copy buffer (defun copy-all () @@ -2233,34 +2438,10 @@ modes like org-mode which have their own yank function." (global-set-key (kbd "M-d") 'run) -;;;;; C-M-d - swap buffer across windows -;; from http://www.emacswiki.org/emacs/TransposeWindows +;;;;; C-M-d - split-window-horizontally + +(global-set-key (kbd "C-M-d") 'split-window-horizontally) -(setq swapping-buffer nil) -(setq swapping-window nil) -(defun swap-buffers-in-windows () - "Swap buffers between two windows" - (interactive) - (if (and swapping-window - swapping-buffer) - (let ((this-buffer (current-buffer)) - (this-window (selected-window))) - (if (and (window-live-p swapping-window) - (buffer-live-p swapping-buffer)) - (progn (switch-to-buffer swapping-buffer) - (select-window swapping-window) - (switch-to-buffer this-buffer) - (select-window this-window) - (message "Swapped buffers.")) - (message "Old buffer/window killed. Aborting.")) - (setq swapping-buffer nil) - (setq swapping-window nil)) - (progn - (setq swapping-buffer (current-buffer)) - (setq swapping-window (selected-window)) - (message "Buffer and window marked for swapping.")))) - -(global-set-key (kbd "C-M-d") 'swap-buffers-in-windows) ;;;;; C-f - kill-whole-line @@ -2301,7 +2482,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 @@ -2318,7 +2500,7 @@ modes like org-mode which have their own yank function." ;; todo; check out smex-show-unbound-commands shows frequently used commands that have no key bindings. ;; this must be before smex-initialize (setq - smex-save-file "~/.emacs.d/.smex-items") + smex-save-file (concat user-emacs-directory ".smex-items")) ;; this uses smex (global-set-key (kbd "M-x") 'counsel-M-x) @@ -2339,8 +2521,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))) @@ -2363,6 +2547,10 @@ modes like org-mode which have their own yank function." (global-set-key (kbd "C-v") 'yank-better) +(add-hook 'ivy-mode-hook + (lambda () + (define-key ivy-minibuffer-map (kbd "C-v") nil))) + (defun yank-better (arg) @@ -2483,8 +2671,7 @@ modes like org-mode which have their own yank function." (progn (basic-save-buffer) (delete-frame)) (save-buffers-kill-terminal t)))) -;;;;; C-* - split-window-horizontally -(global-set-key (kbd "C-*") 'split-window-horizontally) +;;;;; C-* - --- terminal ;;;;; C-M-* - calc-dispatch (global-set-key (kbd "C-M-*") 'calc-dispatch) @@ -2665,8 +2852,10 @@ modes like org-mode which have their own yank function." (defun vim-style-join-line () (interactive) (join-line '(4))) +;; terminal +(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) ;;;;; C-M-/ - copy-buffer-file-name @@ -2815,6 +3004,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) @@ -2861,7 +3052,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) @@ -2938,7 +3129,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)))