;;; ergoemacs-themes.el --- ErgoEmacs keybindings and themes -*- lexical-binding: t -*-
;; Copyright © 2013-2018 Free Software Foundation, Inc.
;; Maintainer: Matthew L. Fidler
;; Authors: Matthew L. Fidler, Xah Lee, Drew Adams
;; Keywords: convenience
;; ErgoEmacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published
;; by the Free Software Foundation, either version 3 of the License,
;; or (at your option) any later version.
;; ErgoEmacs is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with ErgoEmacs. If not, see .
;;; Commentary:
;;
;; Todo:
;;
;;; Code:
(eval-when-compile
(require 'cl)
(require 'ergoemacs-macros))
(declare-function ergoemacs-theme-component--create-component "ergoemacs-theme")
(declare-function ergoemacs-component-struct--create-component "ergoemacs-component")
(declare-function ergoemacs-translate--create "ergoemacs-translate")
(declare-function ergoemacs-key-description--unicode-char "ergoemacs-key-description")
(declare-function ergoemacs-require "ergoemacs-lib")
(defvar ergoemacs-theme-hash)
(defvar ergoemacs-theme-component-hash)
(defvar ergoemacs-translation-hash)
(defvar ergoemacs-component-hash)
(defvar ergoemacs--component-file-mod-time-list)
(autoload 'dired-jump "dired-x" nil t)
(require 'advice)
(ergoemacs-package undo-tree
:ensure t
(global-undo-tree-mode 1))
(ergoemacs-package persistent-soft
:ensure t)
(ergoemacs-component standard-vars ()
"Enabled/changed variables/modes"
(setq org-CUA-compatible t
org-support-shift-select t
set-mark-command-repeat-pop t
org-special-ctrl-a/e t
ido-vertical-define-keys 'C-n-C-p-up-down-left-right
scroll-error-top-bottom t
initial-scratch-message (substitute-command-keys ";; This buffer is for notes you don't want to save, and for Lisp evaluation.\n;; If you want to create a file, visit that file with \\[find-file],\n;; then enter the text in that file's own buffer.")
;; Remove tutorial and guided tour, since the keys don't apply...
fancy-startup-text
`((:face (variable-pitch font-lock-comment-face)
"Welcome to "
:link ("GNU Emacs"
,(lambda (_button) (browse-url "http://www.gnu.org/software/emacs/"))
"Browse http://www.gnu.org/software/emacs/")
", one component of the "
:link
,(lambda ()
(if (eq system-type 'gnu/linux)
`("GNU/Linux"
,(lambda (_button) (browse-url "http://www.gnu.org/gnu/linux-and-gnu.html"))
"Browse http://www.gnu.org/gnu/linux-and-gnu.html")
`("GNU" ,(lambda (_button) (describe-gnu-project))
"Display info on the GNU project")))
" operating system.\n\n"
"\n"
;; :link ("Emacs Guided Tour"
;; ,(lambda (_button)
;; (browse-url "http://www.gnu.org/software/emacs/tour/"))
;; "Browse http://www.gnu.org/software/emacs/tour/")
;; "\tOverview of Emacs features at gnu.org\n"
:link ("View Emacs Manual" ,(lambda (_button) (info-emacs-manual)))
"\tView the Emacs manual using Info\n"
:link ("Absence of Warranty" ,(lambda (_button) (describe-no-warranty)))
"\tGNU Emacs comes with "
:face (variable-pitch (:slant oblique))
"ABSOLUTELY NO WARRANTY\n"
:face variable-pitch
:link ("Copying Conditions" ,(lambda (_button) (describe-copying)))
"\tConditions for redistributing and changing Emacs\n"
:link ("Ordering Manuals" ,(lambda (_button) (view-order-manuals)))
"\tPurchasing printed copies of manuals\n"
"\n"))
;;
fancy-about-text
`((:face (variable-pitch font-lock-comment-face)
"This is "
:link ("GNU Emacs"
,(lambda (_button) (browse-url "http://www.gnu.org/software/emacs/"))
"Browse http://www.gnu.org/software/emacs/")
", one component of the "
:link
,(lambda ()
(if (eq system-type 'gnu/linux)
`("GNU/Linux"
,(lambda (_button)
(browse-url "http://www.gnu.org/gnu/linux-and-gnu.html"))
"Browse http://www.gnu.org/gnu/linux-and-gnu.html")
`("GNU" ,(lambda (_button) (describe-gnu-project))
"Display info on the GNU project.")))
" operating system.\n"
:face (variable-pitch font-lock-builtin-face)
"\n"
,(lambda () (emacs-version))
"\n"
:face (variable-pitch (:height 0.8))
,(lambda () emacs-copyright)
"\n\n"
:face variable-pitch
:link ("Authors"
,(lambda (_button)
(view-file (expand-file-name "AUTHORS" data-directory))
(goto-char (point-min))))
"\tMany people have contributed code included in GNU Emacs\n"
:link ("Contributing"
,(lambda (_button)
(view-file (expand-file-name "CONTRIBUTE" data-directory))
(goto-char (point-min))))
"\tHow to contribute improvements to Emacs\n"
"\n"
:link ("GNU and Freedom" ,(lambda (_button) (describe-gnu-project)))
"\tWhy we developed GNU Emacs, and the GNU operating system\n"
:link ("Absence of Warranty" ,(lambda (_button) (describe-no-warranty)))
"\tGNU Emacs comes with "
:face (variable-pitch (:slant oblique))
"ABSOLUTELY NO WARRANTY\n"
:face variable-pitch
:link ("Copying Conditions" ,(lambda (_button) (describe-copying)))
"\tConditions for redistributing and changing Emacs\n"
:link ("Getting New Versions" ,(lambda (_button) (describe-distribution)))
"\tHow to obtain the latest version of Emacs\n"
:link ("Ordering Manuals" ,(lambda (_button) (view-order-manuals)))
"\tBuying printed manuals from the FSF\n"
"\n"
;; :link ("Emacs Guided Tour"
;; ,(lambda (_button)
;; (browse-url "http://www.gnu.org/software/emacs/tour/"))
;; "Browse http://www.gnu.org/software/emacs/tour/")
;; "\tSee an overview of Emacs features at gnu.org"
)))
(add-hook 'dirtrack-directory-change-hook 'ergoemacs-shell-here-directory-change-hook)
(add-hook 'kill-buffer-hook 'ergoemacs-save-buffer-to-recently-closed)
(add-hook 'shell-mode-hook 'ergoemacs-shell-here-hook)
(add-hook 'eshell-post-command-hook 'ergoemacs-shell-here-directory-change-hook)
;; (dolist (hook '(dired-after-readin-hook after-change-major-mode-hook))
;; (add-hook hook 'ergoemacs-setup-local-prefixes))
(shift-select-mode t)
(delete-selection-mode 1)
(setq recentf-menu-before "Close"
recentf-menu-items-for-commands
(list
["Open Last Closed"
ergoemacs-open-last-closed
:help "Remove duplicates, and obsoletes files from the recent list"
:active t]
["Cleanup list"
recentf-cleanup
:help "Remove duplicates, and obsoletes files from the recent list"
:active t]
["Edit list..."
recentf-edit-list
:help "Manually remove files from the recent list"
:active t]
["Save list now"
recentf-save-list
:help "Save the list of recently opened files now"
:active t]
["Options..."
(customize-group "recentf")
:help "Customize recently opened files menu and options"
:active t]))
(recentf-mode (if noninteractive -1 1))
;; (setq cua--rectangle-modifier-key ergoemacs-cua-rect-modifier)
;; (setq cua--rectangle-keymap (make-sparse-keymap))
;; (setq cua--rectangle-initialized nil)
;; (setq cua--keymap-alist
;; (progn
;; (cua--init-rectangles)
;; `((cua--ena-prefix-override-keymap . ,cua--prefix-override-keymap)
;; (cua--ena-prefix-repeat-keymap . ,cua--prefix-repeat-keymap)
;; (cua--ena-cua-keys-keymap . ,cua--cua-keys-keymap)
;; (cua--ena-global-mark-keymap . ,cua--global-mark-keymap)
;; (cua--rectangle . ,cua--rectangle-keymap)
;; (cua--ena-region-keymap . ,cua--region-keymap)
;; (cua-mode . ,cua-global-keymap))))
)
(ergoemacs-component save-options-on-exit ()
"Save emacs options on exit"
(add-hook 'kill-emacs-hook 'ergoemacs-exit-customize-save-customized))
;;; Fixed components
(ergoemacs-component standard-fixed ()
"Standard Fixed Shortcuts"
:variable-reg nil ;; No variable keys
(global-set-key [tool-bar kill-buffer] 'ergoemacs-close-current-buffer)
(global-set-key (kbd "C-n") 'ergoemacs-new-empty-buffer)
(global-set-key (kbd "C-x C-f") nil) ;; Remove Emacs Method
(global-set-key (kbd "C-o") ("C-o" :emacs))
(global-set-key (kbd "C-S-o") 'ergoemacs-open-in-desktop)
(global-set-key (kbd "C-S-t") 'ergoemacs-open-last-closed)
(global-set-key (kbd "C-w") 'ergoemacs-close-current-buffer)
(global-set-key (kbd "C-s") nil) ;; Search Forward
(global-set-key (kbd "C-f") ("C-s" :emacs))
(global-set-key (kbd "C-x C-s") nil) ;; Save File
(global-set-key (kbd "C-s") ("C-x C-s" :emacs))
(global-set-key (kbd "C-x C-w") nil) ;; Write File
(global-set-key (kbd "C-S-s") ("C-x C-w" :emacs))
(global-set-key (kbd "C-p") 'ergoemacs-print-buffer-confirm)
(global-set-key (kbd "C-x h") nil) ;; Mark whole buffer
(global-set-key (kbd "C-a") ("C-x h" :emacs))
(global-set-key (kbd "C-z") 'undo)
;; Take out undo-tree's redo bindings
(define-key undo-tree-map (kbd "C-?") nil)
(define-key undo-tree-map (kbd "M-_") nil)
(global-set-key (kbd "C-S-z") '(redo undo-tree-redo ergoemacs-redo))
(global-set-key (kbd "") 'ergoemacs-cut-line-or-region)
(global-set-key (kbd "C-c ") 'ergoemacs-copy-line-or-region)
(global-set-key (kbd "") 'ergoemacs-copy-line-or-region)
(global-set-key (kbd "C-S-v") 'ergoemacs-paste-cycle)
(global-set-key (kbd "") 'ergoemacs-paste)
(global-set-key (kbd "C-v") 'ergoemacs-paste)
;; Navigation
(global-set-key (kbd "C-S-n") 'make-frame-command)
;; Text editing
;; the Del key for forward delete. Needed if C-d is set to nil.
(global-set-key (kbd "") 'delete-char )
(global-set-key (kbd "") 'kill-word)
(global-set-key (kbd "") 'kill-word)
(global-set-key (kbd "") 'move-beginning-of-line)
(global-set-key (kbd "") 'move-end-of-line)
(global-set-key (kbd "") 'beginning-of-buffer)
(global-set-key (kbd "") 'end-of-buffer)
(global-set-key (kbd "") 'backward-word)
(global-set-key (kbd "") 'forward-word)
(global-set-key (kbd "") 'ergoemacs-backward-block)
(global-set-key (kbd "") 'ergoemacs-forward-block)
;; C-H is search and replace.
;; C-1 to C-9 should be switch tab... Same as in Google chrome.
;; C-T should be new tab.
;; Refresh should be ; erogemacs uses .
;; C-r also should be refresh
(global-set-key (kbd "") 'revert-buffer)
(global-set-key (kbd "C-r") 'revert-buffer)
;; Text Formatting
;; Upper/Lower case toggle.
;; Ergoemacs fixed keys...
(global-set-key (kbd "") 'ergoemacs-delete-frame) ;; Alt+f4 should work.
; Alt+→
;; Allow shift selection
(global-set-key (kbd "") 'mouse-save-then-kill)
(global-set-key (kbd "") 'ignore)
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "C-.") 'keyboard-quit)
(global-set-key (kbd "C-/") 'info)
(global-set-key (kbd "C-0") 'ergoemacs-text-scale-normal-size)
(global-set-key (kbd "C-") 'ergoemacs-next-user-buffer)
(global-set-key (kbd "C-") 'kill-compilation) ; stop compilation/find/grep
(global-set-key (kbd "C-") 'ergoemacs-previous-user-buffer)
(global-set-key (kbd "C-=") 'text-scale-increase)
(global-set-key (kbd "C-?") 'info)
(global-set-key (kbd "C-S-") 'ergoemacs-next-emacs-buffer)
(global-set-key (kbd "C-S-") 'ergoemacs-previous-emacs-buffer)
(global-set-key (kbd "C-S-f") 'occur)
(global-set-key (kbd "C-S-o") 'ergoemacs-open-in-external-app)
(global-set-key (kbd "C-S-s") 'write-file)
(global-set-key (kbd "C-S-t") 'ergoemacs-open-last-closed)
(global-set-key (kbd "C-S-w") 'delete-frame)
(global-set-key (kbd "C-`") 'other-frame)
(global-set-key (kbd "C-a") 'mark-whole-buffer)
(global-set-key (kbd "C-f") 'isearch-forward)
(global-set-key (kbd "C-l") 'goto-line)
(global-set-key (kbd "C-n") 'ergoemacs-new-empty-buffer)
(global-set-key (kbd "C-o") 'find-file)
(global-set-key (kbd "C-p") 'ergoemacs-print-buffer-confirm)
(global-set-key (kbd "C-x k") nil)
(global-set-key (kbd "C-w") 'ergoemacs-close-current-buffer)
(global-set-key (kbd "C-x ") 'ergoemacs-cut-line-or-region)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(global-set-key (kbd "C-y") '(redo undo-tree-redo ergoemacs-redo) "↷ redo")
(global-set-key (kbd "M-S-") 'forward-page)
(global-set-key (kbd "M-S-") 'backward-page)
;; Mode specific changes
(define-key org-mode-map (kbd "") 'ergoemacs-org-insert-heading-respect-content)
(define-key org-mode-map (kbd "") 'ergoemacs-org-metadown)
(define-key org-mode-map (kbd "") 'ergoemacs-org-metaup)
(define-key org-mode-map (kbd "") 'ergoemacs-org-metaleft)
(define-key org-mode-map (kbd "") 'ergoemacs-org-metaright)
(define-key org-mode-map (kbd "M-v") 'ergoemacs-org-yank)
(define-key org-mode-map (kbd "C-v") 'ergoemacs-org-yank)
(define-key browse-kill-ring-mode-map (kbd "C-f") 'browse-kill-ring-search-forward)
(define-key browse-kill-ring-mode-map (kbd "") 'browse-kill-ring-delete)
(define-key log-edit-mode-map [remap save-buffer] 'log-edit-done)
(define-key eshell-mode-map (kbd "") 'eshell-bol)
(define-key comint-mode-map (kbd "") 'comint-bol)
(define-key helm-map [remap mark-whole-buffer] 'helm-mark-all)
(define-key helm-map (kbd "C-w") 'helm-keyboard-quit)
(define-key helm-map (kbd "C-z") nil)
;; Compatibility with Icicle (allows the use of
;; `icicle-read-string-completing' directly)
(when icicle-mode
(global-set-key [remap ergoemacs-apropos-user-options] 'apropos-user-options))
(when icicle-ido-like-mode
(global-set-key [remap ergoemacs-apropos-user-options] 'apropos-user-options))
(define-key isearch-mode-map (kbd "C-S-f") 'isearch-occur)
(define-key isearch-mode-map (kbd "C-M-f") 'isearch-occur)
(define-key isearch-mode-map (kbd "") 'ergoemacs-paste)
(define-key isearch-mode-map (kbd "C-S-v") 'ergoemacs-paste-cycle)
(define-key isearch-mode-map (kbd "C-c") 'isearch-yank-word-or-char)
(define-key isearch-mode-map (kbd "M-c") 'isearch-yank-word-or-char)
(define-key isearch-mode-map (kbd "M-v") 'ergoemacs-paste)
(define-key isearch-mode-map (kbd "C-v") 'ergoemacs-paste))
(ergoemacs-component tab-indents-region ()
"Tab indents selected region"
(when mark-active
(global-set-key (kbd "TAB") 'indent-region)))
(ergoemacs-component fixed-bold-italic ()
"Fixed keys for bold and italic"
(define-key org-mode-map (kbd "C-b") 'ergoemacs-org-bold)
;; C-i is TAB... This seems to cause issues?
;; (define-key org-mode-map (kbd "C-i") 'ergoemacs-org-italic)
(define-key org-mode-map (kbd "") 'org-cycle)
(define-key org-mode-map (kbd "") 'org-cycle))
(ergoemacs-component backspace-is-back ()
"Backspace is back, as in browsers..."
(define-key Info-mode-map (kbd "") 'Info-history-back)
(define-key Info-mode-map (kbd "") 'Info-history-forward)
(define-key Info-mode-map (kbd "") 'Info-history-forward)
(define-key help-mode-map (kbd "") 'help-go-back)
(define-key help-mode-map (kbd "") 'help-go-forward)
(define-key eww-mode-map (kbd "") 'eww-back-url)
(define-key eww-mode-map (kbd "") 'eww-forward-url))
(ergoemacs-component fixed-newline ()
"Newline and indent"
(global-set-key (kbd "M-RET") ("C-j" :emacs))
(define-key helm-map (kbd "M-RET") 'helm-execute-persistent-action)
(define-key helm-map (kbd "") 'helm-execute-persistent-action)
(define-key helm-map (kbd "M-S-RET") "C-u M-RET")
(define-key helm-map (kbd "") "C-u M-RET")
(define-key helm-read-file-map [remap eshell] 'helm-ff-run-switch-to-eshell)
(define-key helm-read-file-map [remap ergoemacs-eshell-here] 'helm-ff-run-switch-to-eshell)
(define-key helm-read-file-map (kbd "RET") 'ergoemacs-helm-ff-persistent-expand-dir)
(define-key helm-read-file-map (kbd "") 'ergoemacs-helm-ff-persistent-expand-dir)
(define-key helm-read-file-map (kbd "M-RET") 'ergoemacs-helm-ff-execute-dired-dir)
(define-key helm-read-file-map (kbd "") 'ergoemacs-helm-ff-execute-dired-dir)
(define-key helm-read-file-map (kbd "DEL") 'ergoemacs-helm-ff-backspace)
(define-key helm-find-files-map [remap eshell] 'helm-ff-run-switch-to-eshell)
(define-key helm-find-files-map [remap ergoemacs-eshell-here] 'helm-ff-run-switch-to-eshell)
(define-key helm-find-files-map (kbd "DEL") 'ergoemacs-helm-ff-backspace)
(define-key helm-find-files-map (kbd "RET") 'ergoemacs-helm-ff-persistent-expand-dir)
(define-key helm-find-files-map (kbd "") 'ergoemacs-helm-ff-persistent-expand-dir)
(define-key helm-find-files-map (kbd "M-RET") 'ergoemacs-helm-ff-execute-dired-dir)
(define-key helm-find-files-map (kbd "") 'ergoemacs-helm-ff-execute-dired-dir)
(define-key helm-find-files-map (kbd "RET") 'ergoemacs-helm-ff-persistent-expand-dir)
(define-key helm-find-files-map (kbd "") 'ergoemacs-helm-ff-persistent-expand-dir)
(define-key helm-find-files-map (kbd "M-RET") 'ergoemacs-helm-ff-execute-dired-dir)
(define-key helm-find-files-map (kbd "") 'ergoemacs-helm-ff-execute-dired-dir))
(ergoemacs-component fn-keys ()
"Function Keys"
;; Modernize isearch and add back search-map to ergoemacs-mode
(global-set-key (kbd "") 'ergoemacs-cut-all)
(global-set-key (kbd "") 'ergoemacs-copy-all)
(global-set-key (kbd "") 'ergoemacs-paste-cycle)
(global-set-key (kbd "") '(redo undo-tree-redo ergoemacs-redo))
(global-set-key (kbd "") 'highlight-symbol-prev)
(global-set-key (kbd "") 'highlight-symbol-next)
(global-set-key (kbd "") 'ergoemacs-cut-all)
(global-set-key (kbd "") 'ergoemacs-copy-all)
(global-set-key (kbd "") '(redo undo-tree-redo ergoemacs-redo))
(global-set-key (kbd "") 'ergoemacs-toggle-letter-case)
(global-set-key (kbd "") 'previous-line)
(global-set-key (kbd "") 'next-line)
(global-set-key (kbd "") 'ergoemacs-copy-line-or-region)
(global-set-key (kbd "") 'ergoemacs-unchorded-alt-modal)
(global-set-key (kbd "") 'search-map)
(global-set-key (kbd " ") 'highlight-symbol-at-point)
(global-set-key (kbd " ") 'highlight-symbol-query-replace)
(global-set-key (kbd "") 'ergoemacs-cut-line-or-region)
(global-set-key (kbd "") 'ergoemacs-paste)
;; Mode Specific Changes
(define-key compilation-mode-map (kbd "") 'previous-error)
(define-key compilation-mode-map (kbd "") 'next-error)
(define-key browse-kill-ring-mode-map (kbd "") 'browse-kill-ring-previous)
(define-key browse-kill-ring-mode-map (kbd "") 'browse-kill-ring-next)
;; Comint
(define-key comint-mode-map (kbd "") 'comint-previous-input)
(define-key comint-mode-map (kbd "") 'comint-next-input)
(define-key comint-mode-map (kbd "S-") 'comint-previous-matching-input)
(define-key comint-mode-map (kbd "") 'comint-previous-matching-input)
(define-key comint-mode-map (kbd "S-") 'comint-next-matching-input)
(define-key comint-mode-map (kbd "") 'comint-next-matching-input)
;; Log Edit
(define-key log-edit-mode-map (kbd "") 'log-edit-previous-comment)
(define-key log-edit-mode-map (kbd "") 'log-edit-next-comment)
(define-key log-edit-mode-map (kbd "S-") 'log-edit-previous-comment)
(define-key log-edit-mode-map (kbd "") 'log-edit-previous-comment)
(define-key log-edit-mode-map (kbd "S-") 'log-edit-next-comment)
(define-key log-edit-mode-map (kbd "") 'log-edit-next-comment)
(define-key eshell-mode-map (kbd "") 'eshell-previous-matching-input-from-input)
(define-key eshell-mode-map (kbd "") 'eshell-next-matching-input-from-input)
(define-key eshell-mode-map (kbd "S-") 'eshell-previous-matching-input-from-input)
(define-key eshell-mode-map (kbd "") 'eshell-previous-matching-input-from-input)
(define-key eshell-mode-map (kbd "") 'eshell-previous-matching-input-from-input)
(define-key eshell-mode-map (kbd "S-") 'eshell-next-matching-input-from-input)
(define-key eshell-mode-map (kbd "") 'eshell-next-matching-input-from-input)
(define-key isearch-mode-map (kbd "") 'isearch-toggle-regexp)
(define-key isearch-mode-map (kbd "") 'isearch-ring-retreat)
(define-key isearch-mode-map (kbd "") 'isearch-ring-advance)
(define-key isearch-mode-map (kbd "S-") 'isearch-ring-advance)
(define-key isearch-mode-map (kbd "S-") 'isearch-ring-retreat)
(when icicle-minibuffer-setup-hook
:command-loop-unsupported-p t
(define-key minibuffer-local-map (kbd "") 'previous-history-element)
(define-key minibuffer-local-map (kbd "M-") 'icicle-insert-history-element)
(define-key minibuffer-local-map (kbd "") 'next-history-element)
(define-key minibuffer-local-map (kbd "S-") 'next-history-element)
(define-key minibuffer-local-map (kbd "M-") 'icicle-insert-history-element)
(define-key minibuffer-local-map (kbd "S-") 'previous-history-element))
(when iswitchb-define-mode-map-hook
:modify-map t
:always t
(define-key iswitchb-mode-map [remap previous-history-element] 'iswitchb-prev-match)
(define-key iswitchb-mode-map [remap next-history-element] 'iswitchb-next-match)))
(ergoemacs-component f2-edit ()
"Have edit"
(define-key ergoemacs-translate--parent-map [f2] 'ergoemacs-command-loop--force-universal-argument))
(ergoemacs-component backspace-del-seq ()
"Backspace deletes last key entered in command sequence"
(define-key ergoemacs-translate--parent-map (kbd "DEL") 'ergoemacs-command-loop--force-undo-last))
(ergoemacs-component help ()
"Help changes for ergoemacs-mode"
(global-set-key (kbd "C-h '") 'ergoemacs-describe-current-theme)
(global-set-key (kbd "C-h 1") 'describe-function)
(global-set-key (kbd "C-h 2") 'describe-variable)
(global-set-key (kbd "C-h 3") 'describe-key)
(global-set-key (kbd "C-h 4") 'describe-char)
(global-set-key (kbd "C-h 5") 'man)
(global-set-key (kbd "C-h 7") 'ergoemacs-lookup-google)
(global-set-key (kbd "C-h 8") 'ergoemacs-lookup-wikipedia)
(global-set-key (kbd "C-h 9") 'ergoemacs-lookup-word-definition)
(global-set-key (kbd "C-h `") 'elisp-index-search)
(global-set-key (kbd "C-h o") 'ergoemacs-where-is-old-binding)
(global-set-key (kbd "C-h z") 'ergoemacs-clean)
(global-set-key (kbd "C-h C-z") 'ergoemacs-clean-library)
(global-set-key (kbd " '") 'ergoemacs-describe-current-theme)
(global-set-key (kbd " 1") 'describe-function)
(global-set-key (kbd " 2") 'describe-variable)
(global-set-key (kbd " 3") 'describe-key)
(global-set-key (kbd " 4") 'describe-char)
(global-set-key (kbd " 5") 'man)
(global-set-key (kbd " 7") 'ergoemacs-lookup-google)
(global-set-key (kbd " 8") 'ergoemacs-lookup-wikipedia)
(global-set-key (kbd " 9") 'ergoemacs-lookup-word-definition)
(global-set-key (kbd " `") 'elisp-index-search)
(global-set-key (kbd " o") 'ergoemacs-where-is-old-binding))
;;; Variable Components
(ergoemacs-component move-char ()
"Movement by Characters & Set Mark"
(global-set-key (kbd "C-b") nil)
(global-set-key (kbd "M-j") ("C-b" :emacs))
(global-set-key (kbd "C-f") nil)
(define-key global-map (kbd "M-l") ("C-f" :emacs))
(global-set-key (kbd "C-p") nil)
(define-key (current-global-map) (kbd "M-i") ("C-p" :emacs))
(global-set-key (kbd "C-n") nil)
(define-key ergoemacs-keymap (kbd "M-k") ("C-n" :emacs))
;; These are here so that C-M-i will translate to C- for modes
;; like inferior R mode. That allows the command to be the last
;; command.
;; Not sure it belongs here or not...
(global-set-key (kbd "M-C-j") ("" :emacs))
(global-set-key (kbd "M-C-l") ("" :emacs))
(global-set-key (kbd "M-C-i") ("" :emacs))
(global-set-key (kbd "M-C-k") ("" :emacs))
(global-set-key (kbd "C-SPC") nil) ;; Set Mark
(global-set-key (kbd "M-SPC") ("C-SPC" :emacs))
;; Mode specific changes
(define-key browse-kill-ring-mode-map (kbd "M-i") 'browse-kill-ring-previous)
(define-key browse-kill-ring-mode-map (kbd "M-k") 'browse-kill-ring-forward)
;; Delete previous/next char.
(global-set-key (kbd "M-d") 'delete-backward-char)
(global-set-key (kbd "C-d") nil)
(global-set-key (kbd "M-f") 'delete-char)
;; Mode specific changes
(define-key browse-kill-ring-mode-map (kbd "M-i") 'browse-kill-ring-backward)
(define-key browse-kill-ring-mode-map (kbd "M-k") 'browse-kill-ring-forward)
(define-key browse-kill-ring-mode-map (kbd "M-f") 'browse-kill-ring-delete)
(when iswitchb-define-mode-map-hook
(define-key iswitchb-mode-map [remap backward-char] 'iswitchb-prev-match)
(define-key iswitchb-mode-map [remap forward-char] 'iswitchb-next-match))
:version 5.7.5
(global-set-key (kbd "C-SPC") 'set-mark-command) ;; Set Mark
)
(ergoemacs-component move-word ()
"Moving around and deleting words"
(global-set-key (kbd "M-b") nil)
(global-set-key (kbd "M-u") 'backward-word)
(global-set-key (kbd "M-f") nil)
(global-set-key (kbd "M-o") 'forward-word)
;; Delete previous/next word.
;; C-backspace is standard; don't change
(global-set-key (kbd "M-e") 'backward-kill-word)
(global-set-key (kbd "M-d") nil)
(global-set-key (kbd "M-r") 'kill-word))
(ergoemacs-component move-sexp ()
"Instead of moving around by words, use sexps."
(global-set-key [remap forward-word] 'forward-sexp)
(global-set-key [remap backward-word] 'backward-sexp))
(ergoemacs-component move-paragraph ()
"Move by Paragraph"
(global-unset-key (kbd "M-{"))
(global-unset-key (kbd "M-}"))
(global-set-key (kbd "M-U") ("M-{" :emacs))
(global-set-key (kbd "M-O") ("M-}" :emacs)))
(ergoemacs-component move-line ()
"Move by Line"
(global-unset-key (kbd "C-a"))
(global-unset-key (kbd "C-e"))
(global-set-key (kbd "M-h") ("C-a" :emacs))
(global-set-key (kbd "M-H") ("C-e" :emacs))
;; Mode specific movement
(define-key eshell-mode-map [remap move-beginning-of-line] 'eshell-bol)
(define-key comint-mode-map [remap move-beginning-of-line] 'comint-bol))
(ergoemacs-component move-and-transpose-lines ()
"Move Current line/selection down or up with Alt+up or Alt+down"
(global-set-key [\M-up] 'ergoemacs-move-text-up)
(global-set-key [\M-down] 'ergoemacs-move-text-down))
(ergoemacs-component alt-backspace-is-undo ()
"Alt+Backspace is Undo"
(global-set-key (kbd "") 'undo))
(ergoemacs-component move-page ()
"Move by Page"
(global-unset-key (kbd "M-v"))
(global-unset-key (kbd "C-v"))
(global-unset-key (kbd "C-M-v"))
;; Not sure I like the scroll other window placment... C+M+ argh.
(global-set-key (kbd "C-M-I") 'scroll-other-window-down)
(global-set-key (kbd "C-M-K") ("C-M-v" :emacs))
;; These are OK
(global-set-key (kbd "M-I") ("M-v" :emacs))
(global-set-key (kbd "M-K") ("C-v" :emacs)))
(ergoemacs-component move-buffer ()
"Move Beginning/End of buffer"
(global-unset-key (kbd "M->"))
(global-unset-key (kbd "M-<"))
(global-set-key (kbd "M-n") 'ergoemacs-beginning-or-end-of-buffer)
(global-set-key (kbd "M-N") 'ergoemacs-end-or-beginning-of-buffer)
:version 5.7.5
(global-reset-key (kbd "M->"))
(global-reset-key (kbd "M-<"))
(global-unset-key (kbd "M-n"))
(global-unset-key (kbd "M-N")))
(ergoemacs-component move-bracket ()
"Move By Bracket"
(global-set-key (kbd "M-J") 'ergoemacs-backward-open-bracket)
(global-set-key (kbd "M-L") 'ergoemacs-forward-close-bracket)
(global-set-key (kbd "") 'ergoemacs-backward-open-bracket) ; Alt+←
(global-set-key (kbd "") 'ergoemacs-forward-close-bracket))
(ergoemacs-component copy ()
"Copy, Cut, Paste, Redo and Undo"
(global-set-key (kbd "C-w") nil) ;; Kill region = Cut
(global-set-key (kbd "M-x") 'ergoemacs-cut-line-or-region)
(global-set-key (kbd "M-w") nil) ;; Kill ring save = Copy
(global-set-key (kbd "M-c") 'ergoemacs-copy-line-or-region)
(global-set-key (kbd "C-y") nil) ;; Yank = paste
(global-set-key (kbd "M-v") 'ergoemacs-paste)
(global-set-key (kbd "M-y") nil) ;; Yank-pop = paste cycle
(global-set-key (kbd "M-V") 'ergoemacs-paste-cycle)
(global-set-key (kbd "M-C") 'ergoemacs-copy-all)
(global-set-key (kbd "M-X") 'ergoemacs-cut-all)
(global-set-key (kbd "M-Z") '("C-_" :emacs))
;; Undo
(global-set-key (kbd "C-_") nil)
(global-set-key (kbd "C-/") nil)
(global-set-key (kbd "C-x u") nil)
(global-set-key (kbd "M-z") '("C-_" :emacs))
;; Fixed Component; Note that is the actual function.
(global-set-key (kbd "C-c ") 'ergoemacs-copy-line-or-region)
(global-set-key (kbd "C-x ") 'ergoemacs-cut-line-or-region)
(global-set-key (kbd "C-z") 'undo)
(global-set-key (kbd "C-S-z") '(redo undo-tree-redo ergoemacs-redo))
(global-set-key (kbd "C-y") '(redo undo-tree-redo ergoemacs-redo))
;; Mode specific changes
(define-key isearch-mode-map (kbd "C-c") 'isearch-yank-word-or-char)
(define-key isearch-mode-map (kbd "M-c") 'isearch-yank-word-or-char)
(define-key isearch-mode-map (kbd "M-v") 'ergoemacs-paste)
(define-key isearch-mode-map (kbd "M-V") 'ergoemacs-paste-cycle)
(define-key isearch-mode-map (kbd "C-v") 'ergoemacs-paste)
(define-key isearch-mode-map (kbd "C-S-v") 'ergoemacs-paste-cycle)
(define-key org-mode-map [remap ergoemacs-paste] 'ergoemacs-org-yank)
(define-key org-mode-map [remap ergoemacs-paste] 'ergoemacs-org-yank)
(define-key browse-kill-ring-mode-map [remap undo] 'browse-kill-ring-undo-other-window)
(define-key browse-kill-ring-mode-map [remap undo-tree-undo] 'browse-kill-ring-undo-other-window)
(define-key browse-kill-ring-mode-map [remap undo-tree-undo] 'browse-kill-ring-undo-other-window)
(define-key calc-mode-map [remap undo-tree-undo] 'calc-undo))
(ergoemacs-component search ()
"Search and Replace"
(global-set-key (kbd "C-s") nil)
(global-set-key (kbd "M-y") '("C-s" :emacs))
(global-set-key (kbd "C-r") nil)
(global-set-key (kbd "M-Y") '("C-r" :emacs))
(global-set-key (kbd "M-%") nil)
(global-set-key (kbd "M-5") '("M-%" :emacs))
(global-set-key (kbd "C-M-%") nil)
(global-set-key (kbd "M-%") '("C-M-%" :emacs))
;; Mode specific changes
(define-key dired-mode-map (kbd "M-5") 'dired-do-query-replace-regexp)
(define-key dired-mode-map (kbd "M-%") 'dired-do-query-replace-regexp)
;; Reclaim dired+ overrides.
(define-key dired-mode-map (kbd "M-u") 'backward-word)
(define-key dired-mode-map (kbd "C-b") 'diredp-do-bookmark)
(define-key browse-kill-ring-mode-map [remap isearch-forward] 'browse-kill-ring-search-forward)
(define-key browse-kill-ring-mode-map [remap isearch-backward] 'browse-kill-ring-search-backward)
:version 5.7.5
(global-set-key (kbd "M-;") 'isearch-forward)
(global-set-key (kbd "M-:") 'isearch-backward))
(ergoemacs-component search-reg ()
"Regular Expression Search/Replace"
(global-set-key [remap isearch-forward] 'isearch-forward-regexp)
(global-set-key [remap isearch-backward] 'isearch-backward-regexp)
(global-set-key (kbd "M-%") nil)
(global-set-key (kbd "M-5") '("C-M-%" :emacs))
(global-set-key (kbd "C-M-%") nil)
(global-set-key (kbd "M-%") '("M-%" :emacs)))
(ergoemacs-component switch ()
"Window/Frame/Tab Switching"
(global-set-key (kbd "M-s") 'ergoemacs-move-cursor-next-pane)
(global-set-key (kbd "M-S") 'ergoemacs-move-cursor-previous-pane)
(global-set-key (kbd "M-~") 'ergoemacs-switch-to-previous-frame)
(global-set-key (kbd "M-`") 'ergoemacs-switch-to-next-frame)
(global-unset-key (kbd "C-x 1"))
(global-set-key (kbd "M-3") 'delete-other-windows)
(global-unset-key (kbd "C-x 0"))
(global-set-key (kbd "M-2") 'delete-window)
(global-unset-key (kbd "C-x 3"))
(global-set-key (kbd "M-4") '(split-window-below split-window-horizontally))
(global-unset-key (kbd "C-x 2"))
(global-set-key (kbd "M-$") '(split-window-right split-window-vertically))
:version 5.7.5
(global-set-key (kbd "M-0") 'delete-window))
(ergoemacs-component execute ()
"Execute Commands"
(global-unset-key (kbd "M-x"))
(global-set-key (kbd "M-a") '("M-x" :emacs))
(global-unset-key (kbd "M-!"))
(global-set-key (kbd "M-A") '("M-!" :emacs)))
(ergoemacs-component misc ()
"Misc Commands"
(global-unset-key (kbd "C-l"))
(global-set-key (kbd "M-p") '("C-l" :emacs))
(global-set-key (kbd "M-b") 'avy-goto-word-or-subword-1))
(ergoemacs-component kill-line ()
"Kill Line"
(global-unset-key (kbd "C-k"))
(global-set-key (kbd "M-g") '("C-k" :emacs))
(global-set-key (kbd "M-G") 'ergoemacs-kill-line-backward))
(ergoemacs-component text-transform ()
"Text Transformation"
(global-unset-key (kbd "M-;"))
(global-set-key (kbd "M-'") '("M-;" :emacs))
(global-set-key (kbd "M-w") 'ergoemacs-shrink-whitespaces)
(global-set-key (kbd "M-?") 'ergoemacs-toggle-camel-case)
(global-set-key (kbd "M-/") 'ergoemacs-toggle-letter-case)
;; ;; keyword completion, because Alt+Tab is used by OS
(global-set-key (kbd "M-t") 'ergoemacs-call-keyword-completion)
(global-set-key (kbd "M-T") 'flyspell-auto-correct-word)
;; ;; Hard-wrap/un-hard-wrap paragraph
(global-set-key (kbd "M-q") 'ergoemacs-compact-uncompact-block)
(define-key isearch-mode-map (kbd "M-?") 'isearch-toggle-regexp)
(define-key isearch-mode-map (kbd "M-/") 'isearch-toggle-case-fold)
(when iswitchb-define-mode-map-hook
(define-key iswitchb-mode-map [remap ergoemacs-toggle-camel-case] 'iswitchb-toggle-case)
(define-key iswitchb-mode-map [remap ergoemacs-toggle-letter-case] 'iswitchb-toggle-regexp)))
(ergoemacs-component select-items ()
"Select Items"
(global-set-key (kbd "M-S-SPC") 'mark-paragraph)
(global-set-key (kbd "M-8") '(er/expand-region ergoemacs-extend-selection))
(global-set-key (kbd "M-*") '(er/mark-inside-quotes ergoemacs-select-text-in-quote))
(global-set-key (kbd "M-6") 'ergoemacs-select-current-block)
(global-set-key (kbd "M-7") 'ergoemacs-select-current-line))
(ergoemacs-component quit ()
"Escape exits"
(global-set-key (kbd "") 'keyboard-quit)
(define-key isearch-mode-map (kbd "") 'isearch-abort)
(when org-read-date-minibuffer-setup-hook
(define-key minibuffer-local-map (kbd "") 'minibuffer-keyboard-quit))
:version 5.3.7
(global-set-key (kbd "M-n") 'keyboard-quit))
(ergoemacs-component apps ()
"General Apps Key Sequence"
:just-first-keys (list [apps ?h] [menu ?h])
:bind (" '" ergoemacs-org-edit-src
" 2" delete-window
" 3" delete-other-windows
" 4" split-window-vertically
" 5" query-replace
" " ergoemacs-cut-all
" " ergoemacs-copy-all
" " execute-extended-command
" RET" execute-extended-command
" TAB" indent-region ;; Already in CUA
" SPC" set-mark-command
" a" mark-whole-buffer
" d" ("C-x" :ctl-to-alt)
" f" ("C-c" :unchorded-ctl)
" h" help-map
" h '" ergoemacs-describe-current-theme
" h 1" describe-function
" h 2" describe-variable
" h 3" describe-key
" h 4" describe-char
" h 5" man
" h 7" ergoemacs-lookup-google
" h 8" ergoemacs-lookup-wikipedia
" h 9" ergoemacs-lookup-word-definition
" h `" elisp-index-search
" h o" ergoemacs-where-is-old-binding
" h z" ergoemacs-clean
" h C-z" ergoemacs-clean-library
" h Z" ergoemacs-clean-nw
" m" (kbd "C-c C-c")
" s" save-buffer
" C-s" write-file
" o" find-file
" g" ergoemacs-read-key--universal-argument
" w" ergoemacs-close-current-buffer
" x" ergoemacs-cut-line-or-region
" c" ergoemacs-copy-line-or-region
" v" ergoemacs-paste
" b" (redo undo-tree-redo ergoemacs-redo)
" t" switch-to-buffer
" z" undo
" r" goto-map))
(ergoemacs-component apps-toggle ()
"Toggle States and applications"
:just-first-keys (list [apps ?i] [menu ?i])
(global-set-key (kbd " i c") 'column-number-mode)
(global-set-key (kbd " i d") 'toggle-debug-on-error)
(global-set-key (kbd " i e") 'toggle-debug-on-error)
(global-set-key (kbd " i f") 'auto-fill-mode)
(global-set-key (kbd " i l") 'toggle-truncate-lines)
(global-set-key (kbd " i q") 'toggle-debug-on-quit)
(global-set-key (kbd " i r") 'read-only-mode)
(global-set-key (kbd " i C-r") 'revert-buffer))
(ergoemacs-component apps-apps ()
"Applications"
:just-first-keys (list [apps ?n] [menu ?n])
(global-set-key (kbd " n a") 'org-agenda)
(global-set-key (kbd " n A") 'org-capture)
(global-set-key (kbd " n C-a") 'org-capture)
(global-set-key (kbd " n c") 'calc)
(global-set-key (kbd " n d") 'dired-jump)
(global-set-key (kbd " n e") 'eshell)
(global-set-key (kbd " n p") 'powershell)
(global-set-key (kbd " n f") 'ergoemacs-open-in-desktop)
(global-set-key (kbd " n g") 'grep)
(global-set-key (kbd " n m") 'magit-status)
(global-set-key (kbd " n o") 'ergoemacs-open-in-external-app)
(global-set-key (kbd " n r") 'R)
(global-set-key (kbd " n s") 'shell)
(global-set-key (kbd " n t") 'org-capture)
(global-set-key (kbd " n C-t") 'org-agenda)
(global-set-key (kbd " n T") 'org-agenda))
(ergoemacs-component apps-punctuation ()
"Punctuation"
;; Smart punctuation
;; `http://xahlee.info/comp/computer_language_char_distribution.html'
;; |------+-----------+---------+-----------------------|
;; | Rank | Character | Percent | Defined |
;; |------+-----------+---------+-----------------------|
;; | 1 | , | 12.1% | No; Already unchorded |
;; | 2 | _ | 8.0% | Yes |
;; | 3 | " | 8.0% | Yes |
;; | 4 | ( | 7.7% | Yes |
;; | 5 | ) | 7.7% | By pair |
;; | 6 | . | 7.4% | No; Already unchorded |
;; | 7 | ; | 4.8% | No; Already unchorded |
;; | 8 | - | 4.4% | Yes |
;; | 9 | = | 4.3% | Yes |
;; | 10 | ' | 3.9% | Yes (by pair) |
;; | 11 | / | 3.8% | No; Already unchorded |
;; | 12 | * | 3.5% | Yes |
;; | 13 | : | 3.2% | Yes |
;; | 14 | { | 3.2% | By pair |
;; | 15 | } | 3.2% | By pair |
;; | 16 | > | 2.4% | Yes |
;; | 17 | $ | 2.2% | Yes |
;; | 18 | # | 1.7% | Yes |
;; | 19 | + | 1.2% | Yes |
;; | 20 | \ | 1.1% | No; Already unchorded |
;; | 21 | [ | 1.0% | Yes (by pair) |
;; | 22 | ] | 1.0% | Yes |
;; | 23 | < | 1.0% | Yes |
;; | 24 | & | 0.9% | Yes |
;; | 25 | @ | 0.7% | Yes |
;; | 26 | | | 0.5% | Yes |
;; | 27 | ! | 0.5% | Yes |
;; | 28 | % | 0.3% | Yes |
;; | 29 | ? | 0.2% | Yes |
;; | 30 | ` | 0.1% | Yes |
;; | 31 | ^ | 0.1% | Yes |
;; | 32 | ~ | 0.1% | Yes |
;; |------+-----------+---------+-----------------------|
;; No pinkies are used in this setup.
(global-set-key (kbd " k o") "#")
(global-set-key (kbd " k l") "$")
(global-set-key (kbd " k .") ":")
(global-set-key (kbd " k w") "^")
(global-set-key (kbd " k s") "*")
(global-set-key (kbd " k x") "~")
(global-set-key (kbd " k i") 'ergoemacs-smart-bracket)
(global-set-key (kbd " k k") 'ergoemacs-smart-paren)
(global-set-key (kbd " k ,") 'ergoemacs-smart-curly)
(global-set-key (kbd " k j") 'ergoemacs-smart-quote)
(global-set-key (kbd " k u") 'ergoemacs-smart-apostrophe)
(global-set-key (kbd " k m") "`")
(global-set-key (kbd " k y") "?")
(global-set-key (kbd " k h") "%")
(global-set-key (kbd " k n") "@")
(global-set-key (kbd " k r") ">")
(global-set-key (kbd " k f") "_")
(global-set-key (kbd " k v") "<")
(global-set-key (kbd " k e") "+")
(global-set-key (kbd " k d") "=")
(global-set-key (kbd " k c") "-")
(global-set-key (kbd " k t") "&")
(global-set-key (kbd " k g") "|")
(global-set-key (kbd " k b") "!"))
(ergoemacs-component apps-swap ()
"Apps/Menu swaps key sequence translations"
(define-key ergoemacs-translate--parent-map (if (eq system-type 'windows-nt) [apps] [menu])
'ergoemacs-command-loop--swap-translation))
(ergoemacs-component dired-to-wdired ()
"C-c C-c enters wdired, exits."
(define-key dired-mode-map (kbd "C-c C-c") 'wdired-change-to-wdired-mode))
(ergoemacs-component dired-tab ()
"TAB expands a directory."
(define-key dired-mode-map (kbd "TAB") 'dired-maybe-insert-subdir))
(ergoemacs-component guru ()
"Unbind some commonly used keys such as and to get in the habit of using ergoemacs keybindings."
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd ""))
(global-unset-key (kbd "