Browse Source

Scrolling, search, and diff improvements

* I made magit-diff match the colors for diff-mode (for
consistency). I also switched the highlight colors for ediff
* Tooltips now go to the echo line. I never liked the frame-based
* Made isearch temporarily enable smooth-scrolling. This makes it so
you can see context above/below a search result which goes off the
* Use ido to select recent files instead of the recentf UI (yay!)
* Added bindings for Occur (which is amazing), specifically when used
in conjunction with isearch
master 4 years ago
  1. 11
  2. 1
  3. 4
  4. 24
  5. 34
  6. 25


@ -71,6 +71,7 @@
(lambda (buffer-to-kill)
@ -83,7 +84,15 @@
;; Store recently closed files so we can easily reopen them
(recentf-mode 1)
(global-set-key (kbd "C-S-t") 'recentf-open-files)
;; Use ido for recentf file selection
;; From
(defun ido-recentf-open ()
"Use `ido-completing-read' to \\[find-file] a recent file"
(find-file (ido-completing-read "Find recent file: " recentf-list))
(global-set-key (kbd "C-S-t") 'ido-recentf-open)
;; Smex: Smart M-x completion


@ -130,6 +130,7 @@
;; Use ediff-revision to easily manipulate working edits
;; Use re-builder to create a regex by seeing the results of it in the current buffer (super awesome)
;; Hit C-f while in ido to disable all completion (for when you're fighting it)
;; Amazing multiline editing: C-f to isearch-forward, then C-a to see all results, then e to edit all lines
;; Used to load separate configuration files I've created. Order matters so they're scattered a bit
(setq user-init-dir "~/.emacs.d/macoy")


@ -109,6 +109,10 @@
(global-set-key (kbd "M-r") 'insert-register)
(global-set-key (kbd "M-R") 'copy-to-register)
;; Occur
(define-key occur-mode-map (kbd "n") 'occur-next)
(define-key occur-mode-map (kbd "p") 'occur-prev)
;; Move to beginning/end of function
(global-set-key (kbd "M-<up>") 'beginning-of-defun)
(global-set-key (kbd "M-<down>") 'end-of-defun)


@ -261,10 +261,34 @@ If there's a string at point, offer that as a default."
;; Used for expanding the search by words
(define-key isearch-mode-map (kbd "C-'") 'isearch-yank-word-or-char)
;; Make it easier to just see all results when there are too many to scroll
(defun macoy-isearch-occur ()
;; Get all results
(call-interactively 'isearch-occur)
;; End the search
;; Select the results list buffer
(switch-to-buffer-other-window "*Occur*")
(define-key isearch-mode-map (kbd "C-a") 'macoy-isearch-occur)
;; We're going to use smooth scrolling only for isearch so there's a good margin between a search
;; result which would've ended up at the very bottom of the window without smooth scrolling
(require 'smooth-scrolling)
(defun macoy-isearch-end-hook ()
(smooth-scrolling-mode 0)
(setq isearch-mode-end-hook 'macoy-isearch-end-hook)
;; If marked, use swiper to search mark
(defun macoy-isearch-search-mark ()
"If marked, use isearch to search mark. Otherwise, isearch normally"
;; Make sure we can see several lines below a result near the bottom
;; This is then disabled in macoy-isearch-end-hook
(smooth-scrolling-mode 1)
(call-interactively 'isearch-forward)
(when (use-region-p)
;; (isearch-search)


@ -19,6 +19,11 @@
(toggle-scroll-bar -1)
(menu-bar-mode -1)
;; Don't display tooltips in separate windows; use the echo area instead.
;; Tooltips are ugly by default and sometimes get locked displaying on Windows
(tooltip-mode -1)
(setq tooltip-use-echo-area t)
;; Set cursor to I-beam
(modify-all-frames-parameters (list (cons 'cursor-type '(bar . 2))))
;; 4k monitor demands extra thicc cursor
@ -33,11 +38,32 @@
;; When the cursor scrolls off the screen, this makes the window scroll by a dozen or so lines
;; instead of jumping to the top of the window
;; Disabled because of poor performance
;; Disabled because of poor performance in general. We will use it for isearch later
;; so that results aren't right at the bottom of the buffer
;; (require 'smooth-scrolling)
;; (smooth-scrolling-mode 0)
;; Make scrolling less jumpy
;; (smooth-scrolling-mode 1)
;; This is a hack to work around smooth scrolling only being problematic on next-line and prev-line.
;; It's not really worth the effort, but I'm keeping this here in case I change my mind later
;; (defun macoy-prev-line ()
;; (interactive)
;; (smooth-scrolling-mode 0)
;; (forward-line -1)
;; (smooth-scrolling-mode 1)
;; )
;; (defun macoy-next-line ()
;; (interactive)
;; (smooth-scrolling-mode 0)
;; (forward-line)
;; (smooth-scrolling-mode 1)
;; )
;; (global-set-key (kbd "<up>") 'macoy-prev-line)
;; (global-set-key (kbd "<down>") 'macoy-next-line)
;; Make scrolling less jumpy: this makes it so emacs never centers the cursor if you go scroll off
;; screen, instead, it will scroll by one line. This isn't ideal (smooth-scrolling is ideal), but
;; performance is more important in this case
(setq scroll-step 1)
(setq scroll-conservatively 10000)
;; This causes next-line to be ridiculously slow when turned on, so I've disabled it


@ -50,10 +50,27 @@
(set-face-attribute 'diff-refine-removed nil :background "#4a2727")
(require 'ediff)
(set-face-attribute 'ediff-current-diff-A nil :background "#381e1e")
(set-face-attribute 'ediff-fine-diff-A nil :background "#4a2727")
(set-face-attribute 'ediff-current-diff-B nil :background "#2c4a27")
(set-face-attribute 'ediff-fine-diff-B nil :background "#21381e")
;; Added
(set-face-attribute 'ediff-current-diff-A nil :background "#4a2727")
(set-face-attribute 'ediff-fine-diff-A nil :background "#381e1e")
;; Removed
(set-face-attribute 'ediff-current-diff-B nil :background "#21381e")
(set-face-attribute 'ediff-fine-diff-B nil :background "#2c4a27")
;; Make magit's diff look similar/the same as diff-mode
(require 'magit)
(set-face-attribute 'magit-diff-added-highlight nil
:foreground (face-foreground 'diff-added)
:background "#2c4a27")
(set-face-attribute 'magit-diff-removed-highlight nil
:foreground (face-foreground 'diff-added)
:background "#4a2727")
(set-face-attribute 'magit-diff-added nil
:foreground (face-foreground 'diff-added)
:background "#21381e")
(set-face-attribute 'magit-diff-removed nil
:foreground (face-foreground 'diff-added)
:background "#381e1e")
;; I'm not sure why I had to do this, but make 100% sure links are underlined
(require 'org-faces)