Browse Source

Added conditional configuration

I wrapped much of the configuration code in (when (require 'blah))
blocks so that one could have a subset of the installed packages
without getting any errors. Because I maintain the package list, this
shouldn't make it hard to find why something isn't working, because
you're probably just missing the package.

I didn't want to use something like use-package because making my
dependency management require a dependency seemed like a bad idea. I
also like having a slightly less magical approach so I know what's
going on.

There are some files I haven't gotten to yet
master
macoymadson@gmail.com 3 years ago
parent
commit
e88cd8f6b7
  1. 3
      Emacs/build-systems.el
  2. 211
      Emacs/clipboard.el
  3. 71
      Emacs/code-formatting.el
  4. 114
      Emacs/core-settings.el
  5. 5
      Emacs/dotEmacs.el
  6. 80
      Emacs/keybinds.el
  7. 52
      Emacs/navigation.el
  8. 10
      Emacs/org-customizations.el
  9. 65
      Emacs/search.el
  10. 108
      Emacs/visual-late.el

3
Emacs/build-systems.el

@ -42,7 +42,8 @@
"Build the build system defined in `macoy-build-system-default'"
(interactive)
(unless macoy-build-system-default
(message "No default build system selected. Run macoy-build-system-select-then-build")
;; (message "No default build system selected. Run macoy-build-system-select-then-build")
(call-interactively 'macoy-build-system-select-then-build)
)
(when macoy-build-system-default
(message "Building %s" (car macoy-build-system-default))

211
Emacs/clipboard.el

@ -1,125 +1,126 @@
;;
;; Custom multiple cursors cut/copy/paste handling
;;
(require 'multiple-cursors)
(when (and (require 'simpleclip) (require 'multiple-cursors))
(setq macoy-multiple-cursors-buffers nil)
(setq macoy-mc-buffer-index 0)
(setq macoy-multiple-cursors-buffers nil)
(setq macoy-mc-buffer-index 0)
(defun macoy-mc-copy ()
(interactive)
(if (use-region-p)
(push (buffer-substring (region-beginning) (region-end)) macoy-multiple-cursors-buffers)
;; TODO: Copy whole line if no region
(message "TODO: Copy whole line if no region selected")
(defun macoy-mc-copy ()
(interactive)
(if (use-region-p)
(push (buffer-substring (region-beginning) (region-end)) macoy-multiple-cursors-buffers)
;; TODO: Copy whole line if no region
(message "TODO: Copy whole line if no region selected")
)
)
)
(defun macoy-mc-cut ()
(interactive)
;; TODO: Cut whole line if no region
(unless (use-region-p)
(message "TODO: Cut whole line if no region selected")
(defun macoy-mc-cut ()
(interactive)
;; TODO: Cut whole line if no region
(unless (use-region-p)
(message "TODO: Cut whole line if no region selected")
)
(when (use-region-p)
(push (buffer-substring (region-beginning) (region-end)) macoy-multiple-cursors-buffers)
(kill-region (region-beginning) (region-end)))
)
(when (use-region-p)
(push (buffer-substring (region-beginning) (region-end)) macoy-multiple-cursors-buffers)
(kill-region (region-beginning) (region-end)))
)
(defun macoy-mc-paste ()
(interactive)
;; Delete selected text before insert if necessary
(when (use-region-p)
(delete-region (region-beginning) (region-end))
)
;; If no macoy-multiple-cursors-buffers the user probably did a simple copy so paste that
(unless macoy-multiple-cursors-buffers
(call-interactively 'simpleclip-paste)
(defun macoy-mc-paste ()
(interactive)
;; Delete selected text before insert if necessary
(when (use-region-p)
(delete-region (region-beginning) (region-end))
)
;; If no macoy-multiple-cursors-buffers the user probably did a simple copy so paste that
(unless macoy-multiple-cursors-buffers
(call-interactively 'simpleclip-paste)
)
(when macoy-multiple-cursors-buffers
(insert (nth macoy-mc-buffer-index macoy-multiple-cursors-buffers))
;; Set up next cursor buffer index
;; Ensure we don't go out of range of the buffers
;; Sublime's behavior is to just paste all buffers at all marks, so our solution is different here
(setq macoy-mc-buffer-index (min
(+ macoy-mc-buffer-index 1)
(- (length macoy-multiple-cursors-buffers) 1)))
)
)
(when macoy-multiple-cursors-buffers
(insert (nth macoy-mc-buffer-index macoy-multiple-cursors-buffers))
;; Set up next cursor buffer index
;; Ensure we don't go out of range of the buffers
;; Sublime's behavior is to just paste all buffers at all marks, so our solution is different here
(setq macoy-mc-buffer-index (min
(+ macoy-mc-buffer-index 1)
(- (length macoy-multiple-cursors-buffers) 1)))
)
)
;; For versions newer than 25.3 or something :(
(defun string-join (sl delim)
(mapconcat 'identity sl delim))
;; For versions newer than 25.3 or something :(
(defun string-join (sl delim)
(mapconcat 'identity sl delim))
(defun macoy-multiple-cursors-copy()
"Copy at multiple cursors using `macoy-multiple-cursors-buffers'"
(interactive)
(setq macoy-multiple-cursors-buffers nil)
(mc/for-each-cursor-ordered
(mc/execute-command-for-fake-cursor 'macoy-mc-copy cursor))
;; Append happens in reverse
(setq macoy-multiple-cursors-buffers (reverse macoy-multiple-cursors-buffers))
;; Adding newline isn't correct but emacs won't copy the newline. It is slightly more useful
;; to paste things with the newlines when collapsing multiple selections
(simpleclip-set-contents (string-join macoy-multiple-cursors-buffers "\n"))
)
(defun macoy-multiple-cursors-copy()
"Copy at multiple cursors using `macoy-multiple-cursors-buffers'"
(interactive)
(setq macoy-multiple-cursors-buffers nil)
(mc/for-each-cursor-ordered
(mc/execute-command-for-fake-cursor 'macoy-mc-copy cursor))
;; Append happens in reverse
(setq macoy-multiple-cursors-buffers (reverse macoy-multiple-cursors-buffers))
;; Adding newline isn't correct but emacs won't copy the newline. It is slightly more useful
;; to paste things with the newlines when collapsing multiple selections
(simpleclip-set-contents (string-join macoy-multiple-cursors-buffers "\n"))
)
(defun macoy-multiple-cursors-cut()
"Cut at multiple cursors using `macoy-multiple-cursors-buffers'"
(interactive)
(setq macoy-multiple-cursors-buffers nil)
(mc/for-each-cursor-ordered
(mc/execute-command-for-fake-cursor 'macoy-mc-cut cursor))
(setq macoy-multiple-cursors-buffers (reverse macoy-multiple-cursors-buffers))
;; Adding newline isn't correct but emacs won't copy the newline. It is slightly more useful
;; to paste things with the newlines when collapsing multiple selections
(simpleclip-set-contents (string-join macoy-multiple-cursors-buffers "\n"))
)
(defun macoy-multiple-cursors-cut()
"Cut at multiple cursors using `macoy-multiple-cursors-buffers'"
(interactive)
(setq macoy-multiple-cursors-buffers nil)
(mc/for-each-cursor-ordered
(mc/execute-command-for-fake-cursor 'macoy-mc-cut cursor))
(setq macoy-multiple-cursors-buffers (reverse macoy-multiple-cursors-buffers))
;; Adding newline isn't correct but emacs won't copy the newline. It is slightly more useful
;; to paste things with the newlines when collapsing multiple selections
(simpleclip-set-contents (string-join macoy-multiple-cursors-buffers "\n"))
)
(defun macoy-multiple-cursors-paste()
"Paste at multiple cursors using `macoy-multiple-cursors-buffers'"
(interactive)
(setq macoy-mc-buffer-index 0)
(mc/for-each-cursor-ordered
(mc/execute-command-for-fake-cursor 'macoy-mc-paste cursor))
)
(defun macoy-multiple-cursors-paste()
"Paste at multiple cursors using `macoy-multiple-cursors-buffers'"
(interactive)
(setq macoy-mc-buffer-index 0)
(mc/for-each-cursor-ordered
(mc/execute-command-for-fake-cursor 'macoy-mc-paste cursor))
)
(defun macoy-test-multiple-cursors-print-list()
"Print buffers"
(interactive)
(message "%d in buffer" (length macoy-multiple-cursors-buffers))
(dolist (buffer macoy-multiple-cursors-buffers)
(message "Buffer: %s" buffer))
)
(defun macoy-test-multiple-cursors-print-list()
"Print buffers"
(interactive)
(message "%d in buffer" (length macoy-multiple-cursors-buffers))
(dolist (buffer macoy-multiple-cursors-buffers)
(message "Buffer: %s" buffer))
)
;;
;; Custom copy/cut/paste functions so one key can work for simpleclip and multiple-cursors
;; Make sure to add these to mc/cmds-to-run-once and restart Emacs
;;
;; Custom copy/cut/paste functions so one key can work for simpleclip and multiple-cursors
;; Make sure to add these to mc/cmds-to-run-once and restart Emacs
(defun macoyCopy ()
(interactive)
;; Clear buffers here in case they aren't using multiple cursors
;; Then, if they paste in multiple-cursors-mode it will paste simpleclip
(setq macoy-multiple-cursors-buffers nil)
(if (bound-and-true-p multiple-cursors-mode)
(call-interactively 'macoy-multiple-cursors-copy) ;; Was kill-ring-save
(call-interactively 'simpleclip-copy))
)
(defun macoyCopy ()
(interactive)
;; Clear buffers here in case they aren't using multiple cursors
;; Then, if they paste in multiple-cursors-mode it will paste simpleclip
(setq macoy-multiple-cursors-buffers nil)
(if (bound-and-true-p multiple-cursors-mode)
(call-interactively 'macoy-multiple-cursors-copy) ;; Was kill-ring-save
(call-interactively 'simpleclip-copy))
)
(defun macoyCut ()
(interactive)
;; Clear buffers here in case they aren't using multiple cursors
;; Then, if they paste in multiple-cursors-mode it will paste simpleclip
(setq macoy-multiple-cursors-buffers nil)
(if (bound-and-true-p multiple-cursors-mode)
(call-interactively 'macoy-multiple-cursors-cut) ;; Was kill-region
(call-interactively 'simpleclip-cut))
)
(defun macoyCut ()
(interactive)
;; Clear buffers here in case they aren't using multiple cursors
;; Then, if they paste in multiple-cursors-mode it will paste simpleclip
(setq macoy-multiple-cursors-buffers nil)
(if (bound-and-true-p multiple-cursors-mode)
(call-interactively 'macoy-multiple-cursors-cut) ;; Was kill-region
(call-interactively 'simpleclip-cut))
)
(defun macoyPaste ()
(interactive)
(if (bound-and-true-p multiple-cursors-mode)
(call-interactively 'macoy-multiple-cursors-paste) ;; Was yank
(call-interactively 'simpleclip-paste))
(defun macoyPaste ()
(interactive)
(if (bound-and-true-p multiple-cursors-mode)
(call-interactively 'macoy-multiple-cursors-paste) ;; Was yank
(call-interactively 'simpleclip-paste))
)
)

71
Emacs/code-formatting.el

@ -29,49 +29,50 @@
;; Clang format
;; Looks for .clang-format in project dir
(require 'clang-format)
(when (require 'clang-format)
(defun macoy-clang-format-region-or-buffer ()
"Format the region if one is selected, otherwise format the buffer"
(interactive)
(save-excursion
(if (use-region-p)
(call-interactively 'clang-format-region)
(call-interactively 'clang-format-buffer)
(defun macoy-clang-format-region-or-buffer ()
"Format the region if one is selected, otherwise format the buffer"
(interactive)
(save-excursion
(if (use-region-p)
(call-interactively 'clang-format-region)
(call-interactively 'clang-format-buffer)
)
)
)
)
(defun macoy-clang-format-paragraph ()
"Format the block/paragraph"
(interactive)
(save-excursion
(unless (use-region-p)
(mark-paragraph)
)
(when (use-region-p)
(call-interactively 'clang-format-region)
(defun macoy-clang-format-paragraph ()
"Format the block/paragraph"
(interactive)
(save-excursion
(unless (use-region-p)
(mark-paragraph)
)
(when (use-region-p)
(call-interactively 'clang-format-region)
)
)
)
)
(defun macoy-clang-format-function ()
"Format the function"
(interactive)
(save-excursion
(unless (use-region-p)
(mark-defun)
)
(when (use-region-p)
(call-interactively 'clang-format-region)
(defun macoy-clang-format-function ()
"Format the function"
(interactive)
(save-excursion
(unless (use-region-p)
(mark-defun)
)
(when (use-region-p)
(call-interactively 'clang-format-region)
)
)
)
)
(global-set-key (kbd "C-M-a") 'macoy-clang-format-region-or-buffer)
(global-set-key (kbd "C-.") 'macoy-clang-format-paragraph)
(global-set-key (kbd "C->") 'macoy-clang-format-function)
(global-set-key (kbd "C-M-a") 'macoy-clang-format-region-or-buffer)
(global-set-key (kbd "C-.") 'macoy-clang-format-paragraph)
(global-set-key (kbd "C->") 'macoy-clang-format-function)
;; Not sure if this actually does anything
;; https://www.reddit.com/r/emacs/comments/7uq9w1/replace_emacs_c_autoformatting_with_clangformat/
;; (fset 'c-indent-region 'clang-format-region)
;; Not sure if this actually does anything
;; https://www.reddit.com/r/emacs/comments/7uq9w1/replace_emacs_c_autoformatting_with_clangformat/
;; (fset 'c-indent-region 'clang-format-region)
)

114
Emacs/core-settings.el

@ -88,78 +88,84 @@
;; Store recently closed files so we can easily reopen them
(recentf-mode 1)
;; Use ido for recentf file selection
;; From https://masteringemacs.org/article/find-files-faster-recent-files-package
(defun ido-recentf-open ()
"Use `ido-completing-read' to \\[find-file] a recent file"
(interactive)
(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
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
;; This is your old M-x.
(global-set-key (kbd "C-M-x") 'execute-extended-command)
(when (require 'smex)
(smex-initialize)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "M-X") 'smex-major-mode-commands)
;; This is your old M-x.
(global-set-key (kbd "C-M-x") 'execute-extended-command)
)
;; Ido enable (this might be unnecessary as Emacs comes with it by default now)
(require 'ido)
(ido-mode t)
;; Ido display vertically (closer to Sublime)
(ido-vertical-mode 1)
;; Ido vertical use up and down to navigate options, left-right for history/directories
(setq ido-vertical-define-keys 'C-n-C-p-up-down-left-right)
;; Don't try searching other directories when there are no matches
(setq ido-auto-merge-work-directories-length -1)
;; Ido flx settings: make ido have fuzzy sublime-like matching
(require 'flx-ido)
(ido-mode 1)
(ido-everywhere 1)
(flx-ido-mode 1)
;; disable ido faces to see flx highlights.
(setq ido-enable-flex-matching t)
(setq ido-use-faces nil)
(when (require 'ido)
(ido-mode t)
;; Ido display vertically (closer to Sublime)
(ido-vertical-mode 1)
;; Ido vertical use up and down to navigate options, left-right for history/directories
(setq ido-vertical-define-keys 'C-n-C-p-up-down-left-right)
;; Don't try searching other directories when there are no matches
(setq ido-auto-merge-work-directories-length -1)
;; Ido flx settings: make ido have fuzzy sublime-like matching
(when (require 'flx-ido)
(ido-mode 1)
(ido-everywhere 1)
(flx-ido-mode 1)
;; disable ido faces to see flx highlights.
(setq ido-enable-flex-matching t)
(setq ido-use-faces nil)
)
;; Use ido for recentf file selection
;; From https://masteringemacs.org/article/find-files-faster-recent-files-package
(defun ido-recentf-open ()
"Use `ido-completing-read' to \\[find-file] a recent file"
(interactive)
(find-file (ido-completing-read "Find recent file: " recentf-list))
)
(global-set-key (kbd "C-S-t") 'ido-recentf-open)
)
;; Projectile: this does "project" stuff like quick find https://github.com/bbatsov/projectile
;; C-p for ctrl-p-like find
(require 'projectile)
;; Ignore autogenerated files. Doesn't work. I used customize-group projectile for ignored dirs
;; which can be found near the bottom of this file
(setq projectile-globally-ignored-files
(when (require 'projectile)
;; Ignore autogenerated files. Doesn't work. I used customize-group projectile for ignored dirs
;; which can be found near the bottom of this file
(setq projectile-globally-ignored-files
(append '("AutoGen"
"*_ast.*"
"3rdparty/Node/*")
projectile-globally-ignored-files))
(projectile-mode 1)
;; Make projectile mode-line more minimal
(when (string-equal (user-login-name) "macoy")
(defun macoy-projectile-mode-line ()
(format " [%s]" (projectile-project-name))
(projectile-mode 1)
;; Make projectile mode-line more minimal
(when (string-equal (user-login-name) "macoy")
(defun macoy-projectile-mode-line ()
(format " [%s]" (projectile-project-name))
)
(setq projectile-mode-line-function 'macoy-projectile-mode-line)
)
(setq projectile-mode-line-function 'macoy-projectile-mode-line)
)
(when (string-equal (user-login-name) "mmadson")
;; Older version syntax
(setq projectile-mode-line '(:eval (format " [%s]" (projectile-project-name))))
(when (string-equal (user-login-name) "mmadson")
;; Older version syntax
(setq projectile-mode-line '(:eval (format " [%s]" (projectile-project-name))))
)
)
;;
;; File-related shortcuts
;;
(defun macoy-copy-buffer-filename-to-clipboard ()
(interactive)
(simpleclip-set-contents buffer-file-name)
)
(when (require 'simpleclip)
(defun macoy-copy-buffer-filename-to-clipboard ()
(interactive)
(simpleclip-set-contents buffer-file-name)
)
(defun macoy-org-copy-file-line-link-to-clipboard ()
(interactive)
(simpleclip-set-contents (format "[[file:%s::%d][" buffer-file-name (line-number-at-pos)))
(defun macoy-org-copy-file-line-link-to-clipboard ()
(interactive)
(simpleclip-set-contents (format "[[file:%s::%d][" buffer-file-name (line-number-at-pos)))
)
)
;; Open file in explorer

5
Emacs/dotEmacs.el

@ -161,8 +161,9 @@
;; Simpleclip makes system clipboard and emacs kill ring separate
;; This is sane copy paste behavior
;; I keep this near the top because many of my utilities rely on simpleclip
(require 'simpleclip)
(simpleclip-mode 1)
(when (require 'simpleclip)
(simpleclip-mode 1)
)
;; Settings which affect the core behavior of Emacs as well as interface-changing things like ido
;; This also has random utilities for managing buffers and files

80
Emacs/keybinds.el

@ -131,13 +131,14 @@
(global-set-key (kbd "C-<prior>") 'beginning-of-defun)
(global-set-key (kbd "C-<next>") 'end-of-defun)
(require 'expand-region)
;; I don't like it creating temporary binds (what if I want to type those symbols?)
(setq expand-region-fast-keys-enabled nil)
(global-set-key (kbd "C-'") 'er/expand-region)
(global-set-key (kbd "C-\"") 'er/contract-region)
(global-set-key (kbd "M-'") 'er/mark-defun)
(global-set-key (kbd "M-\"") 'er/mark-paragraph)
(when (require 'expand-region)
;; I don't like it creating temporary binds (what if I want to type those symbols?)
(setq expand-region-fast-keys-enabled nil)
(global-set-key (kbd "C-'") 'er/expand-region)
(global-set-key (kbd "C-\"") 'er/contract-region)
(global-set-key (kbd "M-'") 'er/mark-defun)
(global-set-key (kbd "M-\"") 'er/mark-paragraph)
)
;; Window management
;; Split horizonal (was transpose-chars)
@ -152,28 +153,30 @@
(global-set-key (kbd "M-a") 'tags-query-replace)
;; Dired customizations
(require 'dired)
;; Hide details by default (show with '(')
;; See http://ergoemacs.org/emacs/emacs_dired_tips.html
(defun macoy-dired-mode-setup ()
"To be run as a hook for `dired-mode'."
(dired-hide-details-mode 1))
(add-hook 'dired-mode-hook 'macoy-dired-mode-setup)
;; Reuse buffer (from http://ergoemacs.org/emacs/emacs_dired_tips.html)
;; Was dired-find-file
(define-key dired-mode-map (kbd "<return>") 'dired-find-alternate-file)
(define-key dired-mode-map (kbd "S-<return>") 'dired-find-file)
;; Was dired-up-directory
(define-key dired-mode-map (kbd "<backspace>") (lambda () (interactive) (find-alternate-file "..")))
(when (require 'dired)
;; Hide details by default (show with '(')
;; See http://ergoemacs.org/emacs/emacs_dired_tips.html
(defun macoy-dired-mode-setup ()
"To be run as a hook for `dired-mode'."
(dired-hide-details-mode 1))
(add-hook 'dired-mode-hook 'macoy-dired-mode-setup)
;; Reuse buffer (from http://ergoemacs.org/emacs/emacs_dired_tips.html)
;; Was dired-find-file
(define-key dired-mode-map (kbd "<return>") 'dired-find-alternate-file)
(define-key dired-mode-map (kbd "S-<return>") 'dired-find-file)
;; Was dired-up-directory
(define-key dired-mode-map (kbd "<backspace>") (lambda () (interactive) (find-alternate-file "..")))
)
;; Compilation mode customizations
(define-key compilation-mode-map (kbd "n") 'compilation-next-error)
(define-key compilation-mode-map (kbd "p") 'compilation-previous-error)
;; Re Builder customizations
(require 're-builder)
(define-key reb-mode-map (kbd "C-<up>") 'reb-prev-match)
(define-key reb-mode-map (kbd "C-<down>") 'reb-next-match)
(when (require 're-builder)
(define-key reb-mode-map (kbd "C-<up>") 'reb-prev-match)
(define-key reb-mode-map (kbd "C-<down>") 'reb-next-match)
)
;;
;; Make bindings work with org-mode
@ -196,22 +199,21 @@
;;
;; Multiple cursors
;;
(require 'multiple-cursors)
;; Make sure to change this in my-keys-minor-mode-map too
(global-set-key (kbd "C-d") 'mc/mark-next-like-this)
;;(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "M-<f3>") 'mc/mark-all-like-this)
;; Make <return> insert a newline; multiple-cursors-mode can still be disabled with C-g.
(define-key mc/keymap (kbd "<return>") nil)
;; Clear these so that expand-region can have them
(define-key mc/keymap (kbd "C-'") nil)
(define-key mc/keymap (kbd "C-\"") nil)
(define-key mc/keymap (kbd "C-SPC") 'mc-hide-unmatched-lines-mode)
;; Adds one cursor to each line in the current region.
(global-set-key (kbd "C-S-l") 'mc/edit-lines)
;; Note that in my-keys I define cut, copy, and paste overrides which work with simpleclip & mc
(when (require 'multiple-cursors)
;; Make sure to change this in my-keys-minor-mode-map too
(global-set-key (kbd "C-d") 'mc/mark-next-like-this)
;;(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "M-<f3>") 'mc/mark-all-like-this)
;; Make <return> insert a newline; multiple-cursors-mode can still be disabled with C-g.
(define-key mc/keymap (kbd "<return>") nil)
;; Clear these so that expand-region can have them
(define-key mc/keymap (kbd "C-'") nil)
(define-key mc/keymap (kbd "C-\"") nil)
(define-key mc/keymap (kbd "C-SPC") 'mc-hide-unmatched-lines-mode)
;; Adds one cursor to each line in the current region.
(global-set-key (kbd "C-S-l") 'mc/edit-lines)
;; Note that in my-keys I define cut, copy, and paste overrides which work with simpleclip & mc
)
;;
;;
;; Macoy's keybinds which require better override

52
Emacs/navigation.el

@ -41,33 +41,35 @@
;; Quick jumping. Ace-jump-mode didn't work for me
;; Hit keybind, then type first letter of word. Type letter for correct word to jump to
(require 'avy)
(global-set-key (kbd "C-S-g") (lambda () (interactive) (macoy-save-place-then-call
'avy-goto-line)))
(global-set-key (kbd "C-S-j") (lambda () (interactive) (macoy-save-place-then-call
'avy-goto-char)))
(global-set-key (kbd "C-j") (lambda () (interactive) (macoy-save-place-then-call
'avy-goto-word-or-subword-1)))
(when (require 'avy)
(global-set-key (kbd "C-S-g") (lambda () (interactive) (macoy-save-place-then-call
'avy-goto-line)))
(global-set-key (kbd "C-S-j") (lambda () (interactive) (macoy-save-place-then-call
'avy-goto-char)))
(global-set-key (kbd "C-j") (lambda () (interactive) (macoy-save-place-then-call
'avy-goto-word-or-subword-1)))
(defun macoy-quick-jump-copy-paste ()
"Use Avy to jump to a position, select something, then jump back and paste it"
(interactive)
(setq paste-point (point))
(setq copied-str "")
(save-excursion
(call-interactively 'avy-goto-word-or-subword-1)
;; TODO: Push a mode which lets the user select until they hit enter
(setq copy-start (point))
(right-word)
(setq copied-str (buffer-substring copy-start (point)))
(defun macoy-quick-jump-copy-paste ()
"Use Avy to jump to a position, select something, then jump back and paste it"
(interactive)
(setq paste-point (point))
(setq copied-str "")
(save-excursion
(call-interactively 'avy-goto-word-or-subword-1)
;; TODO: Push a mode which lets the user select until they hit enter
(setq copy-start (point))
(right-word)
(setq copied-str (buffer-substring copy-start (point)))
)
(goto-char paste-point)
(insert copied-str)
)
(goto-char paste-point)
(insert copied-str)
)
(global-set-key (kbd "M-c") 'macoy-quick-jump-copy-paste)
(global-set-key (kbd "M-c") 'macoy-quick-jump-copy-paste)
)
;; Go to char. This is like avy quick jump but instead just goes to the next one, not any onscreen
(require 'iy-go-to-char)
(global-set-key (kbd "C-n") 'iy-go-to-char)
(global-set-key (kbd "C-S-n") 'iy-go-to-char-backward)
(when (require 'iy-go-to-char)
(global-set-key (kbd "C-n") 'iy-go-to-char)
(global-set-key (kbd "C-S-n") 'iy-go-to-char-backward)
)

10
Emacs/org-customizations.el

@ -1,8 +1,10 @@
(defun macoy-create-copy-org-link-from-point (link-text)
"Create a link from the file and line at point and copy it to the clipboard"
(interactive "sLink text: ")
(simpleclip-set-contents (format "[[%s::%d][%s]]" buffer-file-name (line-number-at-pos) link-text))
(when (require 'simpleclip)
(defun macoy-create-copy-org-link-from-point (link-text)
"Create a link from the file and line at point and copy it to the clipboard"
(interactive "sLink text: ")
(simpleclip-set-contents (format "[[%s::%d][%s]]" buffer-file-name (line-number-at-pos) link-text))
)
)
(with-eval-after-load 'org

65
Emacs/search.el

@ -305,39 +305,42 @@ If there's a string at point, offer that as a default."
(global-set-key (kbd "C-f") 'macoy-isearch-search-mark)
;; Swiper customizations
;; If marked, use swiper to search mark
(defun macoy-swiper-search-mark ()
"If marked, use swiper to search mark. Otherwise, open swiper normally"
(interactive)
;; This isn't sufficient for my purposes; it's nice to search e.g. thing->thing
;;(swiper (thing-at-point 'symbol))
(if (use-region-p)
(swiper (buffer-substring (region-beginning) (region-end)))
(swiper)
))
;; If marked, use swiper to search mark
(defun macoy-swiper-all-search-mark ()
"If marked, use swiper-all to search mark. Otherwise, open swiper-all normally"
(interactive)
;; This isn't sufficient for my purposes; it's nice to search e.g. thing->thing
;;(swiper (thing-at-point 'symbol))
(if (use-region-p)
(swiper-all (buffer-substring (region-beginning) (region-end)))
(swiper-all)
))
;; Use swiper for search instead of isearch (use e.g. space to fuzzy search)
;; (global-set-key (kbd "C-f") 'macoy-swiper-search-mark)
(global-set-key (kbd "M-f") 'macoy-swiper-all-search-mark)
(when (require 'swiper)
;; If marked, use swiper to search mark
(defun macoy-swiper-search-mark ()
"If marked, use swiper to search mark. Otherwise, open swiper normally"
(interactive)
;; This isn't sufficient for my purposes; it's nice to search e.g. thing->thing
;;(swiper (thing-at-point 'symbol))
(if (use-region-p)
(swiper (buffer-substring (region-beginning) (region-end)))
(swiper)
))
;; If marked, use swiper to search mark
(defun macoy-swiper-all-search-mark ()
"If marked, use swiper-all to search mark. Otherwise, open swiper-all normally"
(interactive)
;; This isn't sufficient for my purposes; it's nice to search e.g. thing->thing
;;(swiper (thing-at-point 'symbol))
(if (use-region-p)
(swiper-all (buffer-substring (region-beginning) (region-end)))
(swiper-all)
))
;; Use swiper for search instead of isearch (use e.g. space to fuzzy search)
;; (global-set-key (kbd "C-f") 'macoy-swiper-search-mark)
(global-set-key (kbd "M-f") 'macoy-swiper-all-search-mark)
)
;; Quickly search the web
;; See https://github.com/hrs/engine-mode for more browsers
(require 'engine-mode)
;; (engine-mode t)
(when (require 'engine-mode)
;; (engine-mode t)
(defengine duckduckgo
"https://duckduckgo.com/?q=%s"
:keybinding "d")
(defengine duckduckgo
"https://duckduckgo.com/?q=%s"
:keybinding "d")
(global-set-key (kbd "M-l") 'engine/search-duckduckgo)
(global-set-key (kbd "M-l") 'engine/search-duckduckgo)
)

108
Emacs/visual-late.el

@ -27,67 +27,75 @@
;; Make avy faces beautiful
;; Note that we swap foreground and background to emulate the inverse-video setting (there's probably
;;; a cleaner way of doing this, but oh well)
(set-face-foreground 'avy-lead-face (face-background 'match))
(set-face-background 'avy-lead-face (face-foreground 'match))
(set-face-foreground 'avy-lead-face-0 (face-background 'match))
(set-face-background 'avy-lead-face-0 (face-foreground 'match))
(set-face-foreground 'avy-lead-face-1 (face-background 'match))
(set-face-background 'avy-lead-face-1 (face-foreground 'match))
(set-face-foreground 'avy-lead-face-2 (face-background 'match))
(set-face-background 'avy-lead-face-2 (face-foreground 'match))
(when (require 'avy)
(set-face-foreground 'avy-lead-face (face-background 'match))
(set-face-background 'avy-lead-face (face-foreground 'match))
(set-face-foreground 'avy-lead-face-0 (face-background 'match))
(set-face-background 'avy-lead-face-0 (face-foreground 'match))
(set-face-foreground 'avy-lead-face-1 (face-background 'match))
(set-face-background 'avy-lead-face-1 (face-foreground 'match))
(set-face-foreground 'avy-lead-face-2 (face-background 'match))
(set-face-background 'avy-lead-face-2 (face-foreground 'match))
)
;; Make dsvn marked face match theme
(require 'dsvn)
(set-face-foreground 'svn-mark-face (face-foreground 'region))
(set-face-background 'svn-mark-face (face-background 'region))
(when (require 'dsvn)
(set-face-foreground 'svn-mark-face (face-foreground 'region))
(set-face-background 'svn-mark-face (face-background 'region))
)
;; Make sure diff-mode colors are theme-appropriate:
;; - No stark white text for context
;; - Make refine* backgrounds much more muted and darker. This is for style and higher contrast
;; between foreground and background of highlighted text
(require 'diff-mode)
(set-face-foreground 'diff-context (face-foreground 'font-lock-comment-face))
(set-face-attribute 'diff-refine-added nil :background "#2c4a27")
(set-face-attribute 'diff-refine-removed nil :background "#4a2727")
(when (require 'diff-mode)
(set-face-foreground 'diff-context (face-foreground 'font-lock-comment-face))
(set-face-attribute 'diff-refine-added nil :background "#2c4a27")
(set-face-attribute 'diff-refine-removed nil :background "#4a2727")
)
(require 'ediff)
;; 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")
(when (require 'ediff)
;; 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")
(when (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)
(set-face-underline 'org-link t)
(when (require 'org-faces)
(set-face-underline 'org-link t))
;; Hide these modes completely (for a more minimal look)
;; Diminish things down here so that we're sure we catch all modes
(require 'diminish)
(diminish 'abbrev-mode)
(diminish 'my-keys-minor-mode)
(diminish 'yas-minor-mode)
(diminish 'auto-complete-mode)
(diminish 'visual-line-mode)
(diminish 'org-indent-mode)
;; The following might not do anything/are unnecessary
(diminish 'adaptive-wrap-prefix-mode)
(diminish 'wrap-region-mode)
(diminish 'auto-revert-mode)
;; TODO: This needs to be in a hook somewhere for org mode. It doesn't work currently
(diminish 'org-indent-mode)
(when (require 'diminish)
(diminish 'abbrev-mode)
(diminish 'my-keys-minor-mode)
(diminish 'yas-minor-mode)
(diminish 'auto-complete-mode)
(diminish 'visual-line-mode)
(diminish 'org-indent-mode)
;; The following might not do anything/are unnecessary
(diminish 'adaptive-wrap-prefix-mode)
(diminish 'wrap-region-mode)
(diminish 'auto-revert-mode)
;; TODO: This needs to be in a hook somewhere for org mode. It doesn't work currently
(diminish 'org-indent-mode)
)

Loading…
Cancel
Save