From: Ian Kelling Date: Tue, 12 Nov 2024 00:41:06 +0000 (-0500) Subject: various improvements X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=bba08891623527342304e2fb529f868a0184c7f4;p=dot-emacs various improvements --- diff --git a/init.el b/init.el index 0b7df73..9979636 100644 --- a/init.el +++ b/init.el @@ -29,6 +29,15 @@ ;; seems its changed now. no harm in keeping this though. (global-unset-key (kbd "C-z")) +;; emacs holds open files in the eln-cache, preventing umount, so move +;; it to its own directory in ~. docs say to do this early in init. +;; The boundp bit is needed for when emacs can't do native compilation +;; for some reason. +;; https://emacs.stackexchange.com/a/70478 +(when (boundp 'native-comp-eln-load-path) + (startup-redirect-eln-cache "../.emacs-eln-cache")) + + ;; speed up init https://www.reddit.com/r/emacs/comments/3kqt6e/2_easy_little_known_steps_to_speed_up_emacs_start/ ;; https://github.com/jwiegley/dot-emacs/blob/master/init.el (defvar file-name-handler-alist-old file-name-handler-alist) @@ -327,9 +336,35 @@ (set-process-coding-system proc decoding encoding)) proc)) -;;; auto-complete +;;; auto-complete , completion , company-mode + +(defun my-company-config () + (global-company-mode) + ;; annoying defaults from company.el, within + ;;(defvar company-active-map + ;;(define-key keymap [tab] 'company-complete-common) + (define-key company-active-map [tab] 'company-complete-selection) + ;;(define-key keymap [return] 'company-complete-selection) + (define-key company-active-map [return] nil) + ;;(define-key keymap (kbd "RET") 'company-complete-selection) + (define-key company-active-map (kbd "RET") nil) + ;; (define-key keymap (kbd "") 'company-select-next-or-abort) + (define-key company-active-map (kbd "") nil) + ;; (define-key keymap (kbd "") 'company-select-previous-or-abort) + (define-key company-active-map (kbd "") nil) + ;; (define-key keymap (kbd "C-h") 'company-show-doc-buffer) + (define-key company-active-map (kbd "C-h") nil) + ;;(define-key keymap "\C-w" 'company-show-location) + (define-key company-active-map "\C-w" nil) + ;;(define-key keymap "\C-s" 'company-search-candidates) + (define-key company-active-map "\C-s" nil) + ;;(define-key keymap "\C-\M-s" 'company-filter-candidates) + (define-key company-active-map "\C-\M-s" nil) + + ) + +(add-hook 'after-init-hook 'my-company-config) -(add-hook 'after-init-hook 'global-company-mode) ;;; auto save @@ -454,9 +489,16 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ;;; backups, separate from auto-save +(defun my-backup-enable-predicate (name) + (and + (not (string-prefix-p "/r/" name)) + (not (string-prefix-p "/mnt/" name)) + (normal-backup-enable-predicate name))) ;; set backup file location -(setq backup-directory-alist '(("." . "~/.editor-backups"))) +(setq backup-directory-alist '(("." . "~/.editor-backups")) + backup-enable-predicate 'my-backup-enable-predicate) + (setq auto-save-file-name-transforms '((".*" "~/.editor-backups/" t))) @@ -618,8 +660,8 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ) (when (string= (daemonp) "server") - ;; save it every 5 minutes. https://www.emacswiki.org/emacs/RecentFiles - (run-at-time nil (* 5 60) 'recentf-save-list)) + ;; save it every 2 minutes. https://www.emacswiki.org/emacs/RecentFiles + (run-at-time nil (* 2 60) 'recentf-save-list)) ;; less strong conditional: :unless noninteractive (use-package saveplace @@ -988,13 +1030,17 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ;; not part of the emacs interactive customize stuff, but didn't see one ;; in the faces documentation. -(custom-set-faces - ;; custom-set-faces was added by Custom. - ;; If you edit it by hand, you could mess it up, so be careful. - ;; Your init file should contain only one such instance. - ;; If there is more than one, they won't work right. - '(header-line ((t (:background "default" :foreground "default" :overline nil :underline nil)))) - '(region ((t nil)))) + +;; custom-set-faces was added by Custom. +;; If you edit it by hand, you could mess it up, so be careful. +;; Your init file should contain only one such instance. +;; If there is more than one, they won't work right. + +;; iank: commented for now as this breaks artist mode +;;(custom-set-faces + +;;'(header-line ((t (:background "default" :foreground "default" :overline nil :underline nil)))) +;; '(region ((t nil)))) ;; from tramp manual, use the same ssh controlmaster. I was having problems with @@ -1145,7 +1191,9 @@ A non-nil CURRENT-ONLY argument means save only current buffer." ;; based on save-buffers-kill-emacs help string, don't ask about clients when exiting ;; apparently this would need to be in some later hook. dunno where is best, but this works (defadvice save-buffers-kill-emacs (before no-client-prompt-advice activate) - (setq kill-emacs-query-functions (delq 'server-kill-emacs-query-function kill-emacs-query-functions))) + ;;(recentf-save-list) + (setq kill-emacs-query-functions + (delq 'server-kill-emacs-query-function kill-emacs-query-functions))) @@ -1708,7 +1756,7 @@ or else the number of characters matched by `outline-regexp'." ;; defaults minus fill. you can find defaults by searching for ;; defcustom erc-modules in erc.el, or customize group erc. erc-modules '(autojoin button completion imenu irccontrols list match menu - move-to-prompt netsplit networks readonly ring stamp track) + move-to-prompt netsplit networks readonly ring stamp track) ;; expanded from https://www.emacswiki.org/emacs/ErcChannelTracking, ;; ignore various messages erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE" @@ -1720,66 +1768,66 @@ or else the number of characters matched by `outline-regexp'." 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"))))) -) + "#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." @@ -2401,9 +2449,20 @@ modes like org-mode which have their own yank function." ;;;;; C-f - kill-whole-line (global-set-key (kbd "C-f") 'kill-whole-line-wrapper) +(setq-default + kill-whole-line-accumulate nil + kill-whole-line-accumulate-engage nil + ) (defun kill-whole-line-wrapper (&optional arg) "If we are at the end of the file, kill backwards instead of doing nothing." (interactive "P") + (when kill-whole-line-accumulate + ;; set last-command the 2nd time we run this function with + ;; accumulate on. + (if kill-whole-line-accumulate-engage + (setq last-command 'kill-region) + (setq kill-whole-line-accumulate-engage t)) + ) (if (= (point) (point-max)) (kill-whole-line -1) (kill-whole-line arg))) @@ -3001,6 +3060,21 @@ modes like org-mode which have their own yank function." (eval-after-load "message" '(define-key message-mode-map (kbd "C-t") 'mail-signature)) +(defun kill-whole-line-toggle-accumulate () + (interactive) + (setq kill-whole-line-accumulate-engage nil) + (message "c-t %s" (setq kill-whole-line-accumulate (not kill-whole-line-accumulate))) + ) + +(global-set-key (kbd "C-t") 'kill-whole-line-toggle-accumulate) + +(defun my-ansi-color-file () + (interactive) + (when (string= (buffer-file-name) "/home/iank/tmp-fs.log") + (ansi-color-apply-on-region (point-min) (point-max)) + )) +(add-hook 'find-file-hook 'my-ansi-color-file) + ;;;;; C-M-t - org timestamp