From 38ab2149c487ef7ea4c99d1cdc321fa9065ab2c3 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Fri, 4 Sep 2020 12:13:11 -0400 Subject: [PATCH] cleanup --- init.el | 449 +++++++++++------------------------------------ misc-disabled.el | 19 ++ 2 files changed, 123 insertions(+), 345 deletions(-) diff --git a/init.el b/init.el index 021fc6c..61e347e 100644 --- a/init.el +++ b/init.el @@ -1,4 +1,4 @@ -;; Copyright (C) 2019 Ian Kelling +;; Copyright (C) 2020 Ian Kelling ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ ;;; 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 @@ -49,8 +49,8 @@ ;; 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 @@ -210,14 +210,13 @@ ;; Ubiquitous Packages. these could go anywhere actually -(use-package saveplace - :unless noninteractive - :config - (save-place-mode 1)) + ;; find file at point (use-package ffap) + + (setq package-archives (quote (("gnu" . "https://elpa.gnu.org/packages/") @@ -412,7 +411,9 @@ ;; avoid window config hook saving too much, it can ;; get into loops in some random situations -(setq my-auto-save-last nil) +(defvar my-auto-save-last nil) +(defvar my-as nil) +(defvar my-auto-save-last nil) (defun my-auto-save-win () (unless (eq (current-buffer) my-auto-save-last) (my-auto-save (current-buffer)))) @@ -449,7 +450,7 @@ (defun my-as-on-local (&rest ignore) (interactive) - (setq-local my-as on)) + (setq-local my-as t)) ;; based on suggestion in the emacs docs, redefine these 2 functions ;; to avoid prompt spamming the user when we do auto-save @@ -505,6 +506,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ;; assume hard linked files are done on purpose, don't screw them up backup-by-copying-when-linked t) +(defvar last-backup-time 0) ;; todo, the time needs to be an integer, not a vector type thing (defun constant-backup () "Backup conditioned on some time passing since last one. @@ -549,18 +551,6 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ;; lowest bound of functionality is actually about 15 input events ;; (setq auto-save-interval ...) -;;; c-like settings -;; change last thing from gnu. -;; notably this avoids brace indent after if, and 4 space indent -(setq c-default-style '((java-mode . "java") - (awk-mode . "awk") - (other . "stroustrup"))) -;; for emacs itself, use -;; (setq c-default-style '((java-mode . "java") -;; (awk-mode . "awk") -;; (other . "gnu"))) -;; (setq-default c-basic-offset 2) - ;;; color theme ;; A Theme builder is available at http://elpa.gnu.org/themes/ along with @@ -573,7 +563,9 @@ A non-nil CURRENT-ONLY argument means save only current buffer." (while custom-enabled-themes (disable-theme (car custom-enabled-themes))) (load-theme arg t)) -(setq color-theme-is-global t) + +;; not a real var? remove when I see this again +;;(setq color-theme-is-global t) ;; temporary, make night be default @@ -645,9 +637,10 @@ A non-nil CURRENT-ONLY argument means save only current buffer." (use-package saveplace :unless noninteractive :config - save-place-version-control 'nospecial - save-place-limit 4000 - save-place-file "~/.emacs.d/places" + (setq + save-place-version-control 'nospecial + save-place-limit 4000 + save-place-file "~/.emacs.d/places") (save-place-mode 1)) @@ -667,202 +660,11 @@ 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) -;;; mu4e - -;; alsot tried notmuch, it had some glitches, and it's config has a list -;; of folders which i'd rather not publish, so it's config is archived. - -;;(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e") -;;(add-to-list 'load-path "/usr/share/emacs/site-lisp/mu4e") -;; (require 'mu4e) - -;; (setq mu4e-headers-results-limit 2000) - - - -(defun my-mu4e-init () - (setq mu4e-headers-fields (delq (assoc :mailing-list mu4e-headers-fields) mu4e-headers-fields)) - ;; it's implemented in mu4e, but not in the actions list for - ;; some reason. - (add-to-list 'mu4e-view-actions - '("browser view" . mu4e-action-view-in-browser) t) - - (add-to-list 'mu4e-headers-actions - '("from this sender" . mu4e-action-msgs-by-this-sender) t) - (add-to-list 'mu4e-view-actions - '("from this sender" . mu4e-action-msgs-by-this-sender) t) - ;; normally, you would add to this, but we want to - ;; modify unread messages. the first 4 are defined by default. - (setq mu4e-bookmarks - `( ,(make-mu4e-bookmark - :name "Unread messages" - ;; old less restrictive unread, for adapting in the future: - ;; flag:unread AND NOT flag:trashed AND NOT maildir:/Junk AND NOT maildir:/fwfw AND NOT maildir:/log - :query "flag:unread maildir:/INBOX" - :key ?u) - ,(make-mu4e-bookmark - :name "Today's messages" - :query "date:today..now" - :key ?t) - ,(make-mu4e-bookmark - :name "Last 7 days" - :query "date:7d..now" - :key ?w) - ,(make-mu4e-bookmark - :name "Messages with images" - :query "mime:image/*" - :key ?p)) - ) - ) - -(eval-after-load "mu4e" '(my-mu4e-init)) - -(setq - ;; message mode prompted me on first message. - ;; a function which describes options then sets this - ;; the other options were to use smtp directly or pass to another mail client - ;; here we use the standard sendmail interface. This applies for gnus too. - send-mail-function (quote sendmail-send-it) - ;; https://github.com/djcb/mu/issues/1025 - mail-user-agent 'mu4e-user-agent - ;; common to gnus. default sendmail-query-once asks us, then sets this via customize. - send-mail-function (quote sendmail-send-it) - ;; use the standard imap folders - mu4e-sent-folder "/Sent" - mu4e-drafts-folder "/Drafts" - mu4e-trash-folder "/Trash" - ;; reindex new mail this often in seconds - ;; show addresses instead of just names - mu4e-view-show-addresses t - mu4e-use-fancy-chars t - mu4e-confirm-quit nil - mu4e-headers-leave-behavior 'apply ;; dont ask, do whatever was marked - ;; default 500. - mu4e-headers-results-limit 1000 - ;; tell exim to use from: as envelope from. - ;; exim's default is use outgoing_msg_localpart@hostname. - mail-specify-envelope-from t - - ;; looking up the list of maildirs when doing jo from summary - ;; can take a few seconds if we have a ton of messages. - ;; Only take that time for the first lookup. - ;; if we add a new maildir, just restart mu4e for it to be in that list. - mu4e-cache-maildir-list t - ;; default is 8, way too small for my big monitors - mu4e-headers-visible-lines 50 - message-sendmail-envelope-from 'header - ;; trying this out - ;;mu4e-view-use-gnus t - ;; had problems where mu4e and gnus would hang verifying signatures, gnus man - ;; said this should help, but it didnt work. they still got verified. - ;; mm-verify-option 'never - ) - -;; fucks up reading unread bookmark. when that is fixed, enable it -;; (setq mu4e-update-interval 60) - - -;; this file includes setting up my email addresses, which are not public, -;; including -;; mu4e-user-mail-address-list -;; 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")) - -(defun my-decrypt () - ;; use for decrypting in mu4e - (interactive) - (beginning-of-buffer) - (when (search-forward "-----BEGIN PGP MESSAGE-----" nil t) - (read-only-mode 0) - (let ((start (match-beginning 0)) - (end (search-forward "-----END PGP MESSAGE-----" nil t))) - (shell-command-on-region start end "gpg2 -dq" nil t shell-command-default-error-buffer t) - ))) -(add-hook 'mu4e-view-mode-hook 'my-decrypt) - -(defun iank-set-from-name (regexes) - "If we find an address matching regex, then set that address as the to, -and whatever was used" - (when mu4e-compose-parent-message - (let ((found nil)) - (while (and regexes (not found)) - (setq re (car regexes) - regexes (cdr regexes) - found (mu4e-message-contact-field-matches - mu4e-compose-parent-message :to re))) - (when found - (setq user-full-name (car found)) - ;; we get an error unless we do this. that is a bug. I could - ;; send a patch... also a bug: setting message-from-style nil - ;; doesnt work in mu4e unless user-full-name is also nil. - (unless user-full-name - (setq message-from-style nil)) - (setq user-mail-address (cdr found) - mail-signature nil)) - found))) -(defun iank-set-from (regexes) - "If we find an address matching regex, then set that address as the to, -and Ian Kelling as the name" - (when mu4e-compose-parent-message - (let ((found nil)) - (while (and regexes (not found)) - (setq re (car regexes) - sig (cadr regexes) - regexes (cddr regexes) - found (cdr (mu4e-message-contact-field-matches - mu4e-compose-parent-message :to re)))) - (when found (setq user-mail-address found - user-full-name "Ian Kelling")) - found))) - - -(defun mu-exit-wait () - (interactive) - ;; taken from the mu source - (let* ((buf (get-buffer mu4e~proc-name)) - (proc (and (buffer-live-p buf) (get-buffer-process buf)))) - (mu4e-quit) - ;; without sleep, we get database locked by another process error when hitting u - ;; if another mu was running. - (if proc (sleep-for 0 1000)))) - -(defun fsf-mu4e () - (interactive) - (my-mu4e-commmon) - (setq - user-mail-address "iank@fsf.org" - iank-user-mail-address user-mail-address - ;; WARNING: be careful editing this, there needs to be a space after --, and my editor - ;; and git will automatically remove it unless i manually disable it. - mail-signature fsf-sig - ) ;; end setq - (add-hook 'mu4e-compose-pre-hook 'my-mu4e-to) - (mu4e)) - - - - -(defun mu4e-action-msgs-by-this-sender (msg) - "In header view, view messages by the sender of the message under point." - (let ((from (mu4e-message-field msg :from))) - (unless from - (mu4e-error "No from header for this message")) - ;; from is structured like: (("Anacron" . "root@x2.lan")) - (mu4e-headers-search (concat "f:" (cdar from))))) - - - ;;; elisp settings ;; when manually evaluating lisp, go into debugger on error (setq eval-expression-debug-on-error t) -(eval-after-load "python-mode" - '(progn - (define-key python-mode-map (kbd "C-j") nil))) - ;;; isearch (setq isearch-allow-scroll t @@ -987,50 +789,65 @@ and Ian Kelling as the name" ;; interactive modes don't need whitespace checks (defun interactive-lisp-coding-defaults () (whitespace-mode -1)) -(setq prelude-interactive-lisp-coding-hook 'prelude-interactive-lisp-coding-defaults) +;;; modes with little configuration needed -;; ielm is an interactive Emacs Lisp shell -(defun ielm-mode-defaults () - (run-hooks 'prelude-interactive-lisp-coding-hook) - (turn-on-eldoc-mode)) -(add-hook 'ielm-mode-hook 'ielm-mode-defaults) +(custom-set-variables + '(css-indent-offset 2) + '(sh-here-document-word "'EOF'") + '(outline-minor-mode-prefix "") + '(tramp-default-method "ssh") + ;; change last thing from gnu. + ;; notably this avoids brace indent after if, and 4 space indent + ;; for emacs itself, use + ;; (setq c-default-style '((java-mode . "java") + ;; (awk-mode . "awk") + ;; (other . "gnu"))) + ;; (setq-default c-basic-offset 2) + '(c-default-style '((java-mode . "java") + (awk-mode . "awk") + (other . "stroustrup"))) + ) -;;; modes with little configuration needed -(setq outline-minor-mode-prefix "" - css-indent-offset 2 - ;; auto indent shell script comments - sh-indent-comment t - sh-here-document-word "'EOF'" - tramp-default-method "ssh" - ;; ediff-buffers is the main command to use - ;; don't start another frame for the control panel - ;; unfortunately, this doesn't allow me to use 2 frames for the diff buffers - ;; so disable this temporarily with the next line if you want that - ;; sometime I should setup 2 functions to explicitly do each type - ediff-window-setup-function 'ediff-setup-windows-plain - ;;(setq ediff-window-setup-function 'ediff-setup-windows-default) - ;; do side by side diffs - ediff-split-window-function 'split-window-horizontally - ;; ediff things I tried which didn't work, which intuitively I think should - ;; work better: I can open the second diff buffer in a new frame, and - ;; close it's window in the first frame after starting ediff, but when I - ;; hit n to go to the next diff, it restores the window in the first - ;; frame. Another thing I tried is to open 2 new frames and set them up - ;; as I want. However, if I try to open the *Ediff Control Panel* buffer - ;; in a different window from its original one, my mouse jumps to one of - ;; the diff frames, or if that isn't visible, the buffer just hangs - ;; until I select the original ediff control panel window. This seems - ;; like a bug to me. I am using a very recent development version of - ;; emacs. - - ) +(setq + ;; ediff-buffers is the main command to use + ;; don't start another frame for the control panel + ;; unfortunately, this doesn't allow me to use 2 frames for the diff buffers + ;; so disable this temporarily with the next line if you want that + ;; sometime I should setup 2 functions to explicitly do each type + ediff-window-setup-function 'ediff-setup-windows-plain + ;;(setq ediff-window-setup-function 'ediff-setup-windows-default) + ;; do side by side diffs + ediff-split-window-function 'split-window-horizontally + ;; ediff things I tried which didn't work, which intuitively I think should + ;; work better: I can open the second diff buffer in a new frame, and + ;; close it's window in the first frame after starting ediff, but when I + ;; hit n to go to the next diff, it restores the window in the first + ;; frame. Another thing I tried is to open 2 new frames and set them up + ;; as I want. However, if I try to open the *Ediff Control Panel* buffer + ;; in a different window from its original one, my mouse jumps to one of + ;; the diff frames, or if that isn't visible, the buffer just hangs + ;; until I select the original ediff control panel window. This seems + ;; like a bug to me. I am using a very recent development version of + ;; emacs. + + ) ;; disabled temporarily. todo, look into it ;;(add-hook 'outline-minor-mode-hook 'outshine-mode) + +;; this file includes setting up my email addresses, which are not public, +;; including +;; mu4e-user-mail-address-list +;; 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")) + + (when (file-exists-p "/a/h/iank-mod.el") (load-file "/a/h/iank-mod.el")) @@ -1059,18 +876,24 @@ and Ian Kelling as the name" ;; todo, put this on a hook with prog mode ;;(highlight-indentation-mode 1) -(add-hook 'auto-revert-tail-mode-hook - (lambda () - (when (string= - buffer-file-name - "/var/log/cloudman/development/cm-service.log") - (setq-local prev-auto-revert-max 0) - ;; set buffer-local hook - (add-hook 'after-revert-hook 'tail-colorize nil t)))) -(defun tail-colorize () - (ansi-color-apply-on-region prev-auto-revert-max (point-max)) - (setq-local prev-auto-revert-max (point-max))) +;; example of a syntax highlighted tail +(use-package autorevert + :defer t + :config + (defvar prev-auto-revert-max) + (defun tail-colorize () + (ansi-color-apply-on-region prev-auto-revert-max (point-max)) + (setq-local prev-auto-revert-max (point-max))) + (add-hook 'auto-revert-tail-mode-hook + (lambda () + (when (string= + buffer-file-name + "/var/log/cloudman/development/cm-service.log") + (setq-local prev-auto-revert-max 0) + ;; set buffer-local hook + (add-hook 'after-revert-hook 'tail-colorize nil t)))) + ) ;; delete active selection with self-insert commands (delete-selection-mode t) @@ -1080,7 +903,7 @@ and Ian Kelling as the name" ;; dot mode, repeats last action (require 'dot-mode) -(add-hook 'find-file-hooks 'dot-mode-on) +(add-hook 'find-file-hook 'dot-mode-on) ;; clean up obsolete buffers automatically at midnight (require 'midnight) @@ -1245,9 +1068,6 @@ and Ian Kelling as the name" ring-bell-function 'ignore case-replace nil revert-without-query '(".*") - ;; don't pause display code on input. - ;; smoother display performance at slight cost of input performance - redisplay-dont-pause t font-lock-maximum-decoration t) ; probably default and not necesary @@ -1341,7 +1161,7 @@ and Ian Kelling as the name" (defun fill-buffer () (interactive) (save-mark-and-excursion - (beginning-of-buffer) + (goto-char (point-min)) (while (= (forward-line) 0) (fill-paragraph)))) @@ -1434,72 +1254,6 @@ Go to the next directory based on where the cursor is." ;; make window title be the buffer name (setq frame-title-format "%b") -;; ----------------------------- -;; fixing up the mode line -;; modified from mastering emacs blog -;; ---------------------------- - -(defvar mode-line-cleaner-alist - `((auto-complete-mode . "") - (yas/minor-mode . "") - (paredit-mode . "") - (auto-fill-function . "") - (eldoc-mode . "") - (abbrev-mode . "") - (flyspell-mode . "") - (glasses-mode . "") - (dot-mode . "") - (yas-global-mode . "") - (yas-minor-mode . "") - (undo-tree-mode . "") - (volatile-highlights-mode . "") - (highlight-symbol-mode . "") - ;; Major modes - (lisp-interaction-mode . "λ") - (hi-lock-mode . "") - (python-mode . "Py") - (emacs-lisp-mode . "EL") - (nxhtml-mode . "nx")) - "Alist for `clean-mode-line'. - - When you add a new element to the alist, keep in mind that you - must pass the correct minor/major mode symbol and a string you - want to use in the modeline *in lieu of* the original.") - - -(defun clean-mode-line () - (interactive) - (loop for cleaner in mode-line-cleaner-alist - do (let* ((mode (car cleaner)) - (mode-str (cdr cleaner)) - (old-mode-str (cdr (assq mode minor-mode-alist)))) - (when old-mode-str - (setcar old-mode-str mode-str)) - ;; major mode - (when (eq mode major-mode) - (setq mode-name mode-str))))) - - ; disabled - ; (add-hook 'after-change-major-mode-hook 'clean-mode-line) - - -;; alias the new `flymake-report-status-slim' to -;; `flymake-report-status' -(defalias 'flymake-report-status 'flymake-report-status-slim) -(defun flymake-report-status-slim (e-w &optional status) - "Show \"slim\" flymake status in mode line." - (when e-w - (setq flymake-mode-line-e-w e-w)) - (when status - (setq flymake-mode-line-status status)) - (let* ((mode-line " Φ")) - (when (> (length flymake-mode-line-e-w) 0) - (setq mode-line (concat mode-line ":" flymake-mode-line-e-w))) - (setq mode-line (concat mode-line flymake-mode-line-status)) - (setq flymake-mode-line mode-line) - (force-mode-line-update))) - - (defun my-after-change-major-mode-hook () (setq mode-line-mule-info nil minor-mode-alist nil @@ -1614,7 +1368,6 @@ Go to the next directory based on where the cursor is." (variable-pitch-mode 0)) (add-hook 'yaml-mode-hook 'variable-pitch-off) -(eval-after-load "org" '(my-org-face-init)) (defun my-org-face-init() (set-face-attribute 'org-table nil :family (face-attribute 'fixed-pitch :family)) @@ -1625,6 +1378,8 @@ Go to the next directory based on where the cursor is." (set-face-attribute 'org-date nil :family (face-attribute 'fixed-pitch :family)) ) +(eval-after-load "org" '(my-org-face-init)) + (defun remove-org-binds () (define-key org-mode-map (kbd "") nil) (define-key org-mode-map (kbd "C-'") nil) @@ -1789,15 +1544,19 @@ indent yanked text (with prefix arg don't indent)." ;;; tex -(setq-default TeX-PDF-mode t) ; use pdf -;; more sensible defaults based on info manual quickstart -(setq TeX-auto-save t - TeX-parse-self t - ;; not documented, but looking at the source, I find this - ;; stops me from being asked what command on every C-c-c - ;; when doing a latex document. - TeX-command-force "LaTeX" - ) + +(use-package latex-mode + :no-require t + :config + (setq-default TeX-PDF-mode t) ; use pdf + ;; more sensible defaults based on info manual quickstart + (setq TeX-auto-save t + TeX-parse-self t + ;; not documented, but looking at the source, I find this + ;; stops me from being asked what command on every C-c-c + ;; when doing a latex document. + TeX-command-force "LaTeX" + )) ;;; visible mark mode @@ -2537,7 +2296,7 @@ modes like org-mode which have their own yank function." (global-set-key (kbd "M-g") 'abort-recursive-edit) -;;;;; C-M-g - gnus +;;;;; C-M-g - mu4e (global-set-key (kbd "C-M-g") 'mu4e) diff --git a/misc-disabled.el b/misc-disabled.el index 2804aa6..ac5fea8 100644 --- a/misc-disabled.el +++ b/misc-disabled.el @@ -439,3 +439,22 @@ ;; Except in HTML (sp-local-pair 'html-mode "\"" nil :unless '(:rem sp-point-after-word-p)) + + + + +;; alias the new `flymake-report-status-slim' to +;; `flymake-report-status' +(defalias 'flymake-report-status 'flymake-report-status-slim) +(defun flymake-report-status-slim (e-w &optional status) + "Show \"slim\" flymake status in mode line." + (when e-w + (setq flymake-mode-line-e-w e-w)) + (when status + (setq flymake-mode-line-status status)) + (let* ((mode-line " Φ")) + (when (> (length flymake-mode-line-e-w) 0) + (setq mode-line (concat mode-line ":" flymake-mode-line-e-w))) + (setq mode-line (concat mode-line flymake-mode-line-status)) + (setq flymake-mode-line mode-line) + (force-mode-line-update))) -- 2.30.2