From: rearman Date: Wed, 12 Jun 2024 18:43:27 +0000 (-0400) Subject: Add recentf, dired auto-revert, search with region X-Git-Url: https://git.earman.xyz/?a=commitdiff_plain;h=3adc704afc398c284904f1eea7ff83312cf223c0;p=emacsinit.git Add recentf, dired auto-revert, search with region --- diff --git a/init.org b/init.org index df25862..20102c3 100644 --- a/init.org +++ b/init.org @@ -68,7 +68,7 @@ Set the GC threshold to max during startup, then set it back to a value that is #+END_SRC ** Basic UI preferences -I want no menus, no tool-bars, left-side scroll-bars, no blinking cursor, no messages when starting up, make resizing work properly, and start up maximized. I just want the scratch buffer with a report on =emacs-init-time=. +I want no menus, no tool-bars, left-side scroll-bars, no blinking cursor, no messages when starting up, and to make resizing work properly. I just want the scratch buffer with a report on =emacs-init-time=. #+BEGIN_SRC emacs-lisp :tangle ./early-init.el (menu-bar-mode -1) (tool-bar-mode -1) @@ -78,7 +78,6 @@ I want no menus, no tool-bars, left-side scroll-bars, no blinking cursor, no mes inhibit-startup-buffer-menu t server-client-instructions nil frame-resize-pixelwise t - default-frame-alist '((fullscreen . maximized)) initial-scratch-message (message ";;; Emacs loaded in %s.\n\n" (emacs-init-time))) #+END_SRC @@ -111,13 +110,13 @@ Avoid a weird issue on windows where opening emacs via an [[https://www.autohotk Load packages first, so there is no question about dependencies later in the file. *** Package Repositories Non-gnu is in the defaults now, so I only need to add melpa. - #+BEGIN_SRC emacs-lisp (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) #+END_SRC + *** almost-mono-themes -Exactly what they say they are +Exactly what they say they are! #+BEGIN_SRC emacs-lisp (use-package almost-mono-themes :ensure t @@ -164,7 +163,6 @@ I used =company-mode= for a long time. I tried corfu and haven't looked back. **** Main Corfu The basics for corfu. Auto popup after one letter, enable globally. - #+BEGIN_SRC emacs-lisp (use-package corfu :ensure t @@ -178,7 +176,6 @@ The basics for corfu. Auto popup after one letter, enable globally. **** corfu-popupinfo This comes with base corfu, but is configured separately. - #+BEGIN_SRC emacs-lisp (use-package corfu-popupinfo :ensure nil ; Part of corfu @@ -195,7 +192,6 @@ This comes with base corfu, but is configured separately. *** expand-region Seldom used, but nothing else does it. - #+BEGIN_SRC emacs-lisp (use-package expand-region :ensure t) (keymap-global-set "C-=" 'er/expand-region) @@ -213,6 +209,16 @@ I use magit occasionally. I put this sparse configuration here mostly for a spe ((:map ctl-x-map ("g" . magit-status)))) #+END_SRC +*** Recentf +#+BEGIN_SRC emacs-lisp +(use-package recentf + :ensure t + :config + (recentf-mode 1)) + +(keymap-global-set "C-c r" 'recentf-open) +#+END_SRC + *** openwith I need to open binary files with their own editor. Disgusting. @@ -322,9 +328,10 @@ I want to avoid ever seeing an error about missing newlines at the end of a file #+END_SRC **** Auto Revert -When files change on disk, and there are no changes in the open buffer, revert to the on-disk version. +When files (or folders in dired) change on disk, and there are no changes in the open buffer, revert to the on-disk version. #+BEGIN_SRC emacs-lisp (global-auto-revert-mode t) +(setq global-auto-revert-non-file-buffers t) #+END_SRC **** Segfault recovery @@ -593,6 +600,12 @@ I Bind the previous functions to =C-o= and =M-o=. (keymap-global-set "M-o" 're/open-line-above) #+END_SRC +**** Line sorting +Stolen from [[https:github.com/magnars/emacsd-reboot/blob/main/settings/editing.el]] +#+BEGIN_SRC emacs-lisp +(keymap-global-set "C-c s" 'sort-lines) +#+END_SRC + **** Commenting I stole this directly from [[https://depp.brause.cc/dotemacs][depp.brause.cc/dotemacs]]. Very good, simple solution. #+BEGIN_SRC emacs-lisp @@ -732,16 +745,39 @@ I ripped this defun and binding from [[https://github.com/lem-project/lem][lem]] (keymap-global-set "C-M-o" 're/other-window-or-split-window) #+END_SRC **** Search and Replace +***** Search with region +#+BEGIN_SRC emacs-lisp +(defun re/isearch-forward-use-region () + (interactive) + (when (use-region-p) + (add-to-history 'search-ring (buffer-substring (region-beginning) + (region-end))) + (deactivate-mark)) + (call-interactively 'isearch-forward)) + +(defun re/isearch-backward-use-region () + (interactive) + (when (use-region-p) + (add-to-history 'search-ring (buffer-substring (region-beginning) + (region-end))) + (deactivate-mark)) + (call-interactively 'isearch-backward)) + + +#+END_SRC + +***** Bindings I made these bindings to put my more-used commands on better keys, and swap them with the less-used ones. Also add bindings for ~isearch-*-regexp~. #+BEGIN_SRC emacs-lisp (keymap-global-set "M-s ." 'isearch-forward-thing-at-point) (keymap-global-set "M-s M-." 'isearch-forward-symbol-at-point) (keymap-global-set "M-%" 'replace-regexp) (keymap-global-set "C-%" 'replace-string) +(keymap-global-set "C-s" 're/isearch-forward-use-region) +(keymap-global-set "C-r" 're/isearch-backward-use-region) (keymap-global-set "C-S-S" 'isearch-forward-regexp) (keymap-global-set "C-S-R" 'isearch-backward-regexp) #+END_SRC - **** Insert Key I keep accidentally enabling ~overwrite-mode~, so disable the ~insert~ key #+BEGIN_SRC emacs-lisp @@ -1149,7 +1185,7 @@ Resume clocking when emacs restarts, save&load running clock and history on exit Capture Templates per my proclivities. #+BEGIN_SRC emacs-lisp (setq org-capture-templates '(("n" "Note" entry (file org-default-notes-file) - "* %? %u" + "* %?" :clock-in t :clock-resume t) ("t" "TODO" entry (file org-default-notes-file) @@ -1364,7 +1400,7 @@ Make dired use the same switches I prefer for =ls=, give me a simpler listing, a Here are the various customizations I have for eshell. *** Binding to start eshell #+BEGIN_SRC emacs-lisp -(keymap-global-set "C-c s" 'eshell) +(keymap-global-set "C-c e" 'eshell) #+END_SRC *** Make it play nice with corfu