diff --git a/.emacs b/.emacs index 1d2ea8b..8d81979 100644 --- a/.emacs +++ b/.emacs @@ -1,3 +1,5 @@ +(require 'cl) + (mapcar (lambda (x) (add-to-list 'load-path (expand-file-name x))) '("~/.emacs.d" )) @@ -6,7 +8,6 @@ (mapcar #'require packages)) (require-all '( - linum ido color-theme gentooish @@ -32,13 +33,19 @@ (setq indent-tabs-mode nil) (setq make-backup-files nil) (set-language-environment "UTF-8") +(set-input-method "japanese-ascii") (winner-mode t) +(display-battery-mode t) +(setq display-time-24hr-format t) +(display-time-mode t) (tooltip-mode nil) -(setq line-number-mode nil) +(setq midnight-mode t) +(setq show-trailing-whitespace t) (setq column-number-mode nil) (setq size-indication-mode nil) (setq mode-line-position nil) +(mouse-avoidance-mode 'animate) (ido-mode t) (global-set-key "\C-m" 'reindent-then-newline-and-indent) ;No tabs @@ -63,6 +70,12 @@ (setq-default save-place t) ;; activate it for all buffers (require 'saveplace) ;; get the package + +;; Enable ergoemacs layout +(setenv "ERGOEMACS_KEYBOARD_LAYOUT" "dv") ; US Dvorak layout +(load "~/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-mode") +(ergoemacs-mode 1) + ;; Make % work like vi (global-set-key "%" 'match-paren) (defun match-paren (arg) @@ -95,6 +108,14 @@ (list (line-beginning-position) (line-beginning-position 2))))) +;; Set my location sunrise-sunset +;; (setq calendar-latitude 40.1) +;; (setq calendar-longitude -88.2) +;; (setq calendar-location-name "Portland, OR") +(setq calendar-latitude 17.5) +(setq calendar-longitude 78.5) +(setq calendar-location-name "Hyderabad, India") + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Haskell mode ;; @@ -177,11 +198,10 @@ '(ido-decorations (quote ("" "" " | " " | ..." "[" "]" " [No match]" " [Matched]" " [Not readable]" " [Too big]" " [Confirm]"))) '(ido-everywhere t) '(inhibit-startup-screen t) - '(line-number-mode nil) '(lisp-loop-forms-indentation 6) '(lisp-loop-keyword-indentation 6) '(lisp-simple-loop-indentation 6) - '(mode-line-format (quote ("%e--[" mode-line-buffer-identification "]" (vc-mode vc-mode) " " mode-line-modes global-mode-string " %-"))) + '(mode-line-format (quote ("%e--[" mode-line-buffer-identification "]" (vc-mode vc-mode) " " mode-line-modes " " global-mode-string " %-"))) '(mode-line-in-non-selected-windows t) '(mode-line-modes (quote ("%[" "(" (:propertize ("" mode-name)) ("" mode-line-process) (:propertize ("" minor-mode-alist)) "%n" ")" "%]"))) '(require-final-newline t) diff --git a/.emacs.d/ergoemacs-keybindings-5.1/_HISTORY.txt b/.emacs.d/ergoemacs-keybindings-5.1/_HISTORY.txt new file mode 100755 index 0000000..030e26a --- /dev/null +++ b/.emacs.d/ergoemacs-keybindings-5.1/_HISTORY.txt @@ -0,0 +1,89 @@ +-*- coding: utf-8 -*- + +Note: When the context is about keys on the keyboard hardware, then QWERTY is used to indicate the key. For example, “Changed M+y to something”, that “y” means the key that is under the key 7. (which is Dvorak's “f”). + +version 5, 2009-09-15 • A much improved version, by David Capello. This version is now a full featured minor mode. It supports 3 different keyboard layout: US QWERTY, US Dvorak, and “Spanish (Spain)” (aka “Spanish (International sort)”). Also supports a new command where-is-old-binding (with shortcut Ctrl+h o). + +version 4.3.13, 2009-08-28 • improved shrink-whitespaces. Now, when called twice, it removes the remaining single space. Thanks to David Capello for the code. + +version 4.3.12.2, 2009-08-15 • Fixed a bug where delete-selection-mode migth be turned off. Changed “(delete-selection-mode t)” to “(delete-selection-mode 1)”. + +version 4.3.12.1, 2009-08-14 • A minor implementation improvement. In one place, changed the use of functionp to fboundp for checking the existing of a emacs 23 feature recenter-top-bottom. Was using functionp because i forgot about fboundp. + +version 4.3.12, 2009-08-13 • Alt+p is now “recenter-top-bottom” for emacs 23 users. In emacs 22, it is “recenter”. + +version 4.3.11, 2009-08-05 • Added a hook to fix message-mode. + +version 4.3.10, 2009-06-14 • fixed a previous/next reversal for f11/f12 keys in rcirc-mode-hook. • diff-mode uses some bindings in M-‹key› space. Fixed by adding a diff-mode-hook. (thanks to lwarxx) + +version 4.3.9, 2009-06-14 • unbind C-x 3 (use Alt+@ for split-window-horizontally) • unbind C-M-% (use Alt+% for query-replace-regexp). • unbind C-@ (use Alt+SPACE for set-mark-command). • unbind M-{ (use Alt+U for backward-paragraph). • unbind M-} (use Alt+O for forward-paragraph). Thanks to marciomazza + +version 4.3.8, 2009-06-14 • added 【】 to select-text-in-quote. + +version 4.3.7, 2009-05-27 • ibuffer's M-s changed in emacs 23, such that M-s is now a prefix. For Dvorak users, M-s should be isearch. This is reclaimed to be isearch. For qwerty users, M-s should be other-window. Fixed. + +version 4.3.6, 2009-05-26 • dired's M-s changed in emacs 23, such that M-s is now a prefix. For Dvorak users, M-s should be isearch. This is reclaimed to be isearch. For qwerty users, M-s should be other-windox. Fixed. + +version 4.3.5, 2009-05-10 • experimental modification to shrink-whitespaces. + +version 4.3.4, 2009-04-19 • Added Alt+Shift+PageDown for forward-page (move cursor to the next ascii formfeed char (often displayed as ^L)). Same for PageDown key. + +version 4.3.3, 2009-03-16 • Added Ctrl+Shift+n for opening a new window (make-frame-command). Removed “C-x 5 2”. Added Ctrl+Shift+w for closing window (delete-frame), removed “C-x 5 0”. + +version 4.3.2, 2009-03-11 • Removed C-x o for other-window. (use Alt+s and Alt+Shift+s instead.) + +version 4.3.1, 2009-03-04 • A better implementation for making M-t call M-TAB. So that, describe-key on M-t will show better documentation. + +version 4.3.0, 2009-03-02 • Added Alt+Shift+x for cut-all and Alt+Shift+c for copy-all. + +version 4.2.4, 2009-03-01 • Removed Ctrl+x Ctrl+w for write-file. Use Ctrl+Shift+s. • Fixed Ctrl+o for ibuffer to run find-file instead of ibuffer-visit-buffer-other-window-noselect. + +version 4.2.3, 2009-03-01 • fixed a dired binding so that Ctrl+o runs find-file instead of dired-display-file + +version 4.2.2, 2009-03-01 • Removed the default keybinding for split-window-vertically (Ctrl+x 2). Use Alt+2 instead. • The key “Ctrl+x Ctrl+b” is now ibuffer, instead of list-buffers. • “Ctrl+h m” now calls describe-major-mode. + +version 4.2.1, 2009-02-28 Changed the keybinding for previous-user-buffer from Ctrl+← to Ctrl+PageUp. And previous-emacs-buffer from Ctrl+Shift+← to Ctrl+Shift+PageUp. Similar for the “next” versions. Rationale: The Ctrl+Arrow are standard editing shortcuts commond in Windows, Mac, Linux. + +version 4.2.0, 2009-02-27 Added Alt+t for keyword completion. Rationale: The default M-TAB is used by Windows, Mac, Linux, to switch apps. + +version 4.1.8, 2009-02-15 Corrected the keybinding for Save As (write-file) + +version 4.1.7, 2008-12-10 Made compact-uncompact-block to work on text selection if there's one. + +version 4.1.6, 2008-12-09. Added select-text-in-quote. + +version 4.1.5, 2008-10-21. Added extend-selection by Nikolaj Schumacher. + +version 4.1.4, 2008-10-20. Fixed close-current-buffer: sometimes when closing a buffer not associated with a file, it'll prompt whether to kill instead of whether to save. + +version 4.1.3, 2008-10-18. Fixed minor bug in toggle-letter-case. It now works non-english letters such as éÉ and single letter word “a teapot” or words starting with a number “1st timer”. Thanks to Andreas Politz and Nikolaj Schumacher. • next-frame-command is renamed to switch-to-next-frame. Similar for previous-frame-command. + +version 4.1.2, 2008-10-16. Removed C-x h for mark-whole-buffer. (use Ctrl+a instead) Improved compact-uncompact-block and shrink-whitespaces. + +version 4.1.1, 2008-10-07. Removed unfill-paragraph and unfill-region because they are defined in ourcomments-util.el bundled with emacs 22, also because they are not used in this file now (compact-uncompact-block replaced most of their functionality). + +version 4.1, 2008-10-06. Added keys for previous-user-buffer, next-user-buffer, next-frame-command, previous-frame-command, query-replace and query-replace-regexp, move-cursor-to-next-pane, move-cursor-to-previous-pane, split-window-horizontally, toggle-letter-case. Combined delete-blank-lines and just-one-space to shrink-whitespaces. Moved delete-window to be with delete-other-window. + +version 4.0.1, 2008-09-23. Fixed C-o in dired mode. + +version 4, 2008-09-21. Unbind almost all Meta-‹key› and Ctrl-‹key› space bindings. Added about 11 commands, such as next-user-buffer, close-current-buffer etc. + +version 3.6, 2008-09-18. Reclaimed keybindings in text-mode. + +version 3.5, 2008-09-16. Reclaimed keybindings in ibuffer. + +version 3.4, 2008-09-06. Fixed key bindings in the Meta-‹key› space in about 10 modes. + +version 3.3, 2008-09-05. Fixed cua-mode-hook by setting symbol property 'CUA to nil, so that a bunch of no-select-* functions kludge is no longer needed. Thanks to Lennart Borgman. + +version 3.2, 2008-09-02. Moved cua fix functions to modern_operations.el. The functinos are: no-select-cua-scroll-down, no-select-cua-scroll-up, no-select-backward-paragraph, no-select-forward-paragraph, no-select-beginning-of-buffer, no-select-end-of-buffer, no-select-move-end-of-line. + +version 3.1, 2008-09-02. Added just-one-space, delete-blank-lines. Added fill-paragraph, unfill-paragraph. Added comment-dwim. + +version 3, 2008-08-31. Added isearch. Added redo, kill-line-backward, shell-command. Added bug fix for cua-mode. Now, commands with Shift keys won't go into a selection mode. + +version 2, 2008-08-29. Somewhat major change. Positions for undo, cut, copy, paste, paste previous, has been moved. Added delete-char, delete-backward-char, kill-word, backward-kill-word. Removed the now redundant binding of kill-word and backward-kill-word using the backspace key. Removed the other-frame binding. + +version 1.1, 2007-12-18. changed keycode to consistantly use kbd syntax. Fixed a scroll-up and scroll-down mixup. + +version 1.0, 2007-08-01. first version, by Xah Lee diff --git a/.emacs.d/ergoemacs-keybindings-5.1/_INSTALL.txt b/.emacs.d/ergoemacs-keybindings-5.1/_INSTALL.txt new file mode 100755 index 0000000..2a7f091 --- /dev/null +++ b/.emacs.d/ergoemacs-keybindings-5.1/_INSTALL.txt @@ -0,0 +1,64 @@ +-*- coding: utf-8 -*- + +INSTALLATION INSTRUCTIONS + +------------------------------ +1. Unzip the folder. + +If you downloaded a file named “ergoemacs-keybindings_v123.zip”, unzip it. +Now you should have a folder named “ergoemacs-keybindings_v123”. + +------------------------------ +2. Place the folder somewhere in your home directory. For examples: + +On Windows: +C:\Users\mary\.emacs.d\ergoemacs-keybindings_v123 + +On Mac OS X or Linux: +/Users/mary/.emacs.d/ergoemacs-keybindings_v123 + +------------------------------ +3. Specify your keyboard layout. + +Place one of the following line in your emacs init file (~/.emacs): + +(setenv "ERGOEMACS_KEYBOARD_LAYOUT" "us") ; US layout + +(setenv "ERGOEMACS_KEYBOARD_LAYOUT" "dv") ; US Dvorak layout + +(setenv "ERGOEMACS_KEYBOARD_LAYOUT" "sp") ; Spanish (Spain) (aka “Spanish (International sort)”) + +(setenv "ERGOEMACS_KEYBOARD_LAYOUT" "it") ; Italian layout + +(setenv "ERGOEMACS_KEYBOARD_LAYOUT" "colemak") ; Colemak layout + +------------------------------ +4. Make Emacs load the file, and turn on the mode. + +Place the following lines in your emacs init file. Make sure that the path points to your file is correct. You do not need to have the file path end in “.el”. + +;; load ErgoEmacs keybinding +(load "~/.emacs.d/ergoemacs-keybindings/ergoemacs-mode") + +;; turn on minor mode ergoemacs-mode +(ergoemacs-mode 1) + +These lines should be placed below your keyboard layout in step 3. + +------------------------------ +5. Restart emacs. + +Now, your will be using the new keybinding. The shortcut for emacs's “M-x” is now “Alt+a”. + +To turn off the mode, type “Alt+a” then “ergoemacs-mode”. After that, your keybinding is the same as GNU Emacs's default keybinding. + +The command “ergoemacs-mode” toggles the minor mode. + +-------------------------------------------------- +Byte Compile Elisp Files (Optional) + +If you like, you can byte-compile the elisp files. To byte compile them, call the command byte-compile-file, then the elisp file name. Once you do that, emacs will create a file with “.elc” ending, and will automatically load byte compiled file if there is one. + +Byte compiled files makes loading and running programs about 5 or more times faster, but for small elisp files, the speed increse is probably not noticeable. + +You do not need to change any lines in the emacs initialization given above. diff --git a/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-colemak.el b/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-colemak.el new file mode 100644 index 0000000..32f127c --- /dev/null +++ b/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-colemak.el @@ -0,0 +1,106 @@ +;-*- coding: utf-8 -*- +;; Shortcuts for ERGOEMACS_KEYBOARD_LAYOUT=colemak + +;;; -------------------------------------------------- +;;; CURSOR MOVEMENTS + +;; Single char cursor movement +(defconst ergoemacs-backward-char-key (kbd "M-n")) +(defconst ergoemacs-forward-char-key (kbd "M-i")) +(defconst ergoemacs-previous-line-key (kbd "M-u")) +(defconst ergoemacs-next-line-key (kbd "M-e")) + +;; Move by word +(defconst ergoemacs-backward-word-key (kbd "M-l")) +(defconst ergoemacs-forward-word-key (kbd "M-y")) + +;; Move by paragraph +(defconst ergoemacs-backward-paragraph-key (kbd "M-L")) +(defconst ergoemacs-forward-paragraph-key (kbd "M-Y")) + +;; Move to beginning/ending of line +(defconst ergoemacs-move-beginning-of-line-key (kbd "M-h")) +(defconst ergoemacs-move-end-of-line-key (kbd "M-H")) + +;; Move by screen (page up/down) +(defconst ergoemacs-scroll-down-key (kbd "M-U")) +(defconst ergoemacs-scroll-up-key (kbd "M-E")) + +;; Move to beginning/ending of file +(defconst ergoemacs-beginning-of-buffer-key (kbd "M-N")) +(defconst ergoemacs-end-of-buffer-key (kbd "M-I")) + +;; isearch +(defconst ergoemacs-isearch-forward-key (kbd "M-o")) +(defconst ergoemacs-isearch-backward-key (kbd "M-O")) + +(defconst ergoemacs-recenter-key (kbd "M-;")) + +;;; MAJOR EDITING COMMANDS + +;; Delete previous/next char. +(defconst ergoemacs-delete-backward-char-key (kbd "M-s")) +(defconst ergoemacs-delete-char-key (kbd "M-t")) + +; Delete previous/next word. +(defconst ergoemacs-backward-kill-word-key (kbd "M-f")) +(defconst ergoemacs-kill-word-key (kbd "M-p")) + +; Copy Cut Paste, Paste previous +(defconst ergoemacs-kill-region-key (kbd "M-x")) +(defconst ergoemacs-kill-ring-save-key (kbd "M-c")) +(defconst ergoemacs-yank-key (kbd "M-v")) +(defconst ergoemacs-yank-pop-key (kbd "M-V")) +(defconst ergoemacs-copy-all-key (kbd "M-C")) +(defconst ergoemacs-cut-all-key (kbd "M-X")) + +;; undo and redo +(defconst ergoemacs-redo-key (kbd "M-Z")) +(defconst ergoemacs-undo-key (kbd "M-z")) + +; Kill line +(defconst ergoemacs-kill-line-key (kbd "M-d")) +(defconst ergoemacs-kill-line-backward-key (kbd "M-D")) + +;;; Textual Transformation + +(defconst ergoemacs-mark-paragraph-key (kbd "M-S-SPC")) +(defconst ergoemacs-shrink-whitespaces-key (kbd "M-w")) +(defconst ergoemacs-comment-dwim-key (kbd "M-'")) +(defconst ergoemacs-toggle-letter-case-key (kbd "M-/")) + +; keyword completion, because Alt+Tab is used by OS +(defconst ergoemacs-call-keyword-completion-key (kbd "M-g")) + +; Hard-wrap/un-hard-wrap paragraph +(defconst ergoemacs-compact-uncompact-block-key (kbd "M-q")) + +;;; EMACS'S SPECIAL COMMANDS + +; Mark point. +(defconst ergoemacs-set-mark-command-key (kbd "M-SPC")) + +(defconst ergoemacs-execute-extended-command-key (kbd "M-a")) +(defconst ergoemacs-shell-command-key (kbd "M-A")) + +;;; WINDOW SPLITING +(defconst ergoemacs-move-cursor-next-pane-key (kbd "M-r")) +(defconst ergoemacs-move-cursor-previous-pane-key (kbd "M-R")) + +;;; -------------------------------------------------- +;;; OTHER SHORTCUTS + +(defconst ergoemacs-switch-to-previous-frame-key (kbd "M-~")) +(defconst ergoemacs-switch-to-next-frame-key (kbd "M-`")) + +(defconst ergoemacs-query-replace-key (kbd "M-5")) +(defconst ergoemacs-query-replace-regexp-key (kbd "M-%")) + +(defconst ergoemacs-delete-other-windows-key (kbd "M-1")) +(defconst ergoemacs-delete-window-key (kbd "M-!")) + +(defconst ergoemacs-split-window-vertically-key (kbd "M-2")) +(defconst ergoemacs-split-window-horizontally-key (kbd "M-@")) + +(defconst ergoemacs-extend-selection-key (kbd "M-8")) +(defconst ergoemacs-select-text-in-quote-key (kbd "M-*")) diff --git a/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-dv.el b/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-dv.el new file mode 100755 index 0000000..7fde12a --- /dev/null +++ b/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-dv.el @@ -0,0 +1,106 @@ +;-*- coding: utf-8 -*- +;; Shortcuts for ERGOEMACS_KEYBOARD_LAYOUT=dv | us_dvorak + +;;; -------------------------------------------------- +;;; CURSOR MOVEMENTS + +;; Single char cursor movement +(defconst ergoemacs-backward-char-key (kbd "M-h")) +(defconst ergoemacs-forward-char-key (kbd "M-n")) +(defconst ergoemacs-previous-line-key (kbd "M-c")) +(defconst ergoemacs-next-line-key (kbd "M-t")) + +;; Move by word +(defconst ergoemacs-backward-word-key (kbd "M-g")) +(defconst ergoemacs-forward-word-key (kbd "M-r")) + +;; Move by paragraph +(defconst ergoemacs-backward-paragraph-key (kbd "M-G")) +(defconst ergoemacs-forward-paragraph-key (kbd "M-R")) + +;; Move to beginning/ending of line +(defconst ergoemacs-move-beginning-of-line-key (kbd "M-d")) +(defconst ergoemacs-move-end-of-line-key (kbd "M-D")) + +;; Move by screen (page up/down) +(defconst ergoemacs-scroll-down-key (kbd "M-C")) +(defconst ergoemacs-scroll-up-key (kbd "M-T")) + +;; Move to beginning/ending of file +(defconst ergoemacs-beginning-of-buffer-key (kbd "M-H")) +(defconst ergoemacs-end-of-buffer-key (kbd "M-N")) + +;; isearch +(defconst ergoemacs-isearch-forward-key (kbd "M-s")) +(defconst ergoemacs-isearch-backward-key (kbd "M-S")) + +(defconst ergoemacs-recenter-key (kbd "M-l")) + +;;; MAJOR EDITING COMMANDS + +;; Delete previous/next char. +(defconst ergoemacs-delete-backward-char-key (kbd "M-e")) +(defconst ergoemacs-delete-char-key (kbd "M-u")) + +; Delete previous/next word. +(defconst ergoemacs-backward-kill-word-key (kbd "M-.")) +(defconst ergoemacs-kill-word-key (kbd "M-p")) + +; Copy Cut Paste, Paste previous +(defconst ergoemacs-kill-region-key (kbd "M-q")) +(defconst ergoemacs-kill-ring-save-key (kbd "M-j")) +(defconst ergoemacs-yank-key (kbd "M-k")) +(defconst ergoemacs-yank-pop-key (kbd "M-K")) +(defconst ergoemacs-copy-all-key (kbd "M-J")) +(defconst ergoemacs-cut-all-key (kbd "M-Q")) + +;; undo and redo +(defconst ergoemacs-redo-key (kbd "M-:")) +(defconst ergoemacs-undo-key (kbd "M-;")) + +; Kill line +(defconst ergoemacs-kill-line-key (kbd "M-i")) +(defconst ergoemacs-kill-line-backward-key (kbd "M-I")) + +;;; Textual Transformation + +(defconst ergoemacs-mark-paragraph-key (kbd "M-S-SPC")) +(defconst ergoemacs-shrink-whitespaces-key (kbd "M-,")) +(defconst ergoemacs-comment-dwim-key (kbd "M--")) +(defconst ergoemacs-toggle-letter-case-key (kbd "M-z")) + +; keyword completion, because Alt+Tab is used by OS +(defconst ergoemacs-call-keyword-completion-key (kbd "M-y")) + +; Hard-wrap/un-hard-wrap paragraph +(defconst ergoemacs-compact-uncompact-block-key (kbd "M-'")) + +;;; EMACS'S SPECIAL COMMANDS + +; Mark point. +(defconst ergoemacs-set-mark-command-key (kbd "M-SPC")) + +(defconst ergoemacs-execute-extended-command-key (kbd "M-a")) +(defconst ergoemacs-shell-command-key (kbd "M-A")) + +;;; WINDOW SPLITING +(defconst ergoemacs-move-cursor-next-pane-key (kbd "M-o")) +(defconst ergoemacs-move-cursor-previous-pane-key (kbd "M-O")) + +;;; -------------------------------------------------- +;;; OTHER SHORTCUTS + +(defconst ergoemacs-switch-to-previous-frame-key (kbd "M-~")) +(defconst ergoemacs-switch-to-next-frame-key (kbd "M-`")) + +(defconst ergoemacs-query-replace-key (kbd "M-5")) +(defconst ergoemacs-query-replace-regexp-key (kbd "M-%")) + +(defconst ergoemacs-delete-other-windows-key (kbd "M-1")) +(defconst ergoemacs-delete-window-key (kbd "M-!")) + +(defconst ergoemacs-split-window-vertically-key (kbd "M-2")) +(defconst ergoemacs-split-window-horizontally-key (kbd "M-@")) + +(defconst ergoemacs-extend-selection-key (kbd "M-8")) +(defconst ergoemacs-select-text-in-quote-key (kbd "M-*")) diff --git a/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-it.el b/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-it.el new file mode 100644 index 0000000..873e0e1 --- /dev/null +++ b/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-it.el @@ -0,0 +1,106 @@ +;-*- coding: utf-8 -*- +;; Shortcuts for ERGOEMACS_KEYBOARD_LAYOUT=it + +;;; -------------------------------------------------- +;;; CURSOR MOVEMENTS + +;; Single char cursor movement +(defconst ergoemacs-backward-char-key (kbd "M-j")) +(defconst ergoemacs-forward-char-key (kbd "M-l")) +(defconst ergoemacs-previous-line-key (kbd "M-i")) +(defconst ergoemacs-next-line-key (kbd "M-k")) + +;; Move by word +(defconst ergoemacs-backward-word-key (kbd "M-u")) +(defconst ergoemacs-forward-word-key (kbd "M-o")) + +;; Move by paragraph +(defconst ergoemacs-backward-paragraph-key (kbd "M-U")) +(defconst ergoemacs-forward-paragraph-key (kbd "M-O")) + +;; Move to beginning/ending of line +(defconst ergoemacs-move-beginning-of-line-key (kbd "M-h")) +(defconst ergoemacs-move-end-of-line-key (kbd "M-H")) + +;; Move by screen (page up/down) +(defconst ergoemacs-scroll-down-key (kbd "M-I")) +(defconst ergoemacs-scroll-up-key (kbd "M-K")) + +;; Move to beginning/ending of file +(defconst ergoemacs-beginning-of-buffer-key (kbd "M-J")) +(defconst ergoemacs-end-of-buffer-key (kbd "M-L")) + +;; isearch +(defconst ergoemacs-isearch-forward-key (kbd "M-ò")) +(defconst ergoemacs-isearch-backward-key (kbd "M-ç")) + +(defconst ergoemacs-recenter-key (kbd "M-p")) + +;;; MAJOR EDITING COMMANDS + +;; Delete previous/next char. +(defconst ergoemacs-delete-backward-char-key (kbd "M-d")) +(defconst ergoemacs-delete-char-key (kbd "M-f")) + +; Delete previous/next word. +(defconst ergoemacs-backward-kill-word-key (kbd "M-e")) +(defconst ergoemacs-kill-word-key (kbd "M-r")) + +; Copy Cut Paste, Paste previous +(defconst ergoemacs-kill-region-key (kbd "M-x")) +(defconst ergoemacs-kill-ring-save-key (kbd "M-c")) +(defconst ergoemacs-yank-key (kbd "M-v")) +(defconst ergoemacs-yank-pop-key (kbd "M-V")) +(defconst ergoemacs-copy-all-key (kbd "M-C")) +(defconst ergoemacs-cut-all-key (kbd "M-X")) + +;; undo and redo +(defconst ergoemacs-redo-key (kbd "M-Z")) +(defconst ergoemacs-undo-key (kbd "M-z")) + +; Kill line +(defconst ergoemacs-kill-line-key (kbd "M-g")) +(defconst ergoemacs-kill-line-backward-key (kbd "M-G")) + +;;; Textual Transformation + +(defconst ergoemacs-mark-paragraph-key (kbd "M-S-SPC")) +(defconst ergoemacs-shrink-whitespaces-key (kbd "M-w")) +(defconst ergoemacs-comment-dwim-key (kbd "M-à")) +(defconst ergoemacs-toggle-letter-case-key (kbd "M--")) + +; keyword completion, because Alt+Tab is used by OS +(defconst ergoemacs-call-keyword-completion-key (kbd "M-t")) + +; Hard-wrap/un-hard-wrap paragraph +(defconst ergoemacs-compact-uncompact-block-key (kbd "M-q")) + +;;; EMACS'S SPECIAL COMMANDS + +; Mark point. +(defconst ergoemacs-set-mark-command-key (kbd "M-SPC")) + +(defconst ergoemacs-execute-extended-command-key (kbd "M-a")) +(defconst ergoemacs-shell-command-key (kbd "M-A")) + +;;; WINDOW SPLITING +(defconst ergoemacs-move-cursor-next-pane-key (kbd "M-s")) +(defconst ergoemacs-move-cursor-previous-pane-key (kbd "M-S")) + +;;; -------------------------------------------------- +;;; OTHER SHORTCUTS + +(defconst ergoemacs-switch-to-previous-frame-key (kbd "M-|")) +(defconst ergoemacs-switch-to-next-frame-key (kbd "M-\\")) + +(defconst ergoemacs-query-replace-key (kbd "M-5")) +(defconst ergoemacs-query-replace-regexp-key (kbd "M-%")) + +(defconst ergoemacs-delete-other-windows-key (kbd "M-1")) +(defconst ergoemacs-delete-window-key (kbd "M-!")) + +(defconst ergoemacs-split-window-vertically-key (kbd "M-2")) +(defconst ergoemacs-split-window-horizontally-key (kbd "M-\"")) + +(defconst ergoemacs-extend-selection-key (kbd "M-8")) +(defconst ergoemacs-select-text-in-quote-key (kbd "M-(")) diff --git a/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-sp.el b/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-sp.el new file mode 100644 index 0000000..a8ad964 --- /dev/null +++ b/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-sp.el @@ -0,0 +1,106 @@ +;-*- coding: utf-8 -*- +;; Shortcuts for ERGOEMACS_KEYBOARD_LAYOUT=sp + +;;; -------------------------------------------------- +;;; CURSOR MOVEMENTS + +;; Single char cursor movement +(defconst ergoemacs-backward-char-key (kbd "M-j")) +(defconst ergoemacs-forward-char-key (kbd "M-l")) +(defconst ergoemacs-previous-line-key (kbd "M-i")) +(defconst ergoemacs-next-line-key (kbd "M-k")) + +;; Move by word +(defconst ergoemacs-backward-word-key (kbd "M-u")) +(defconst ergoemacs-forward-word-key (kbd "M-o")) + +;; Move by paragraph +(defconst ergoemacs-backward-paragraph-key (kbd "M-U")) +(defconst ergoemacs-forward-paragraph-key (kbd "M-O")) + +;; Move to beginning/ending of line +(defconst ergoemacs-move-beginning-of-line-key (kbd "M-h")) +(defconst ergoemacs-move-end-of-line-key (kbd "M-H")) + +;; Move by screen (page up/down) +(defconst ergoemacs-scroll-down-key (kbd "M-I")) +(defconst ergoemacs-scroll-up-key (kbd "M-K")) + +;; Move to beginning/ending of file +(defconst ergoemacs-beginning-of-buffer-key (kbd "M-J")) +(defconst ergoemacs-end-of-buffer-key (kbd "M-L")) + +;; isearch +(defconst ergoemacs-isearch-forward-key (kbd "M-ñ")) +(defconst ergoemacs-isearch-backward-key (kbd "M-Ñ")) + +(defconst ergoemacs-recenter-key (kbd "M-p")) + +;;; MAJOR EDITING COMMANDS + +;; Delete previous/next char. +(defconst ergoemacs-delete-backward-char-key (kbd "M-d")) +(defconst ergoemacs-delete-char-key (kbd "M-f")) + +; Delete previous/next word. +(defconst ergoemacs-backward-kill-word-key (kbd "M-e")) +(defconst ergoemacs-kill-word-key (kbd "M-r")) + +; Copy Cut Paste, Paste previous +(defconst ergoemacs-kill-region-key (kbd "M-x")) +(defconst ergoemacs-kill-ring-save-key (kbd "M-c")) +(defconst ergoemacs-yank-key (kbd "M-v")) +(defconst ergoemacs-yank-pop-key (kbd "M-V")) +(defconst ergoemacs-copy-all-key (kbd "M-C")) +(defconst ergoemacs-cut-all-key (kbd "M-X")) + +;; undo and redo +(defconst ergoemacs-redo-key (kbd "M-Z")) +(defconst ergoemacs-undo-key (kbd "M-z")) + +; Kill line +(defconst ergoemacs-kill-line-key (kbd "M-g")) +(defconst ergoemacs-kill-line-backward-key (kbd "M-G")) + +;;; Textual Transformation + +(defconst ergoemacs-mark-paragraph-key (kbd "M-S-SPC")) +(defconst ergoemacs-shrink-whitespaces-key (kbd "M-w")) +(defconst ergoemacs-comment-dwim-key (kbd "M-´")) +(defconst ergoemacs-toggle-letter-case-key (kbd "M--")) + +; keyword completion, because Alt+Tab is used by OS +(defconst ergoemacs-call-keyword-completion-key (kbd "M-t")) + +; Hard-wrap/un-hard-wrap paragraph +(defconst ergoemacs-compact-uncompact-block-key (kbd "M-q")) + +;;; EMACS'S SPECIAL COMMANDS + +; Mark point. +(defconst ergoemacs-set-mark-command-key (kbd "M-SPC")) + +(defconst ergoemacs-execute-extended-command-key (kbd "M-a")) +(defconst ergoemacs-shell-command-key (kbd "M-A")) + +;;; WINDOW SPLITING +(defconst ergoemacs-move-cursor-next-pane-key (kbd "M-s")) +(defconst ergoemacs-move-cursor-previous-pane-key (kbd "M-S")) + +;;; -------------------------------------------------- +;;; OTHER SHORTCUTS + +(defconst ergoemacs-switch-to-previous-frame-key (kbd "M-ª")) +(defconst ergoemacs-switch-to-next-frame-key (kbd "M-º")) + +(defconst ergoemacs-query-replace-key (kbd "M-5")) +(defconst ergoemacs-query-replace-regexp-key (kbd "M-%")) + +(defconst ergoemacs-delete-other-windows-key (kbd "M-1")) +(defconst ergoemacs-delete-window-key (kbd "M-!")) + +(defconst ergoemacs-split-window-vertically-key (kbd "M-2")) +(defconst ergoemacs-split-window-horizontally-key (kbd "M-\"")) + +(defconst ergoemacs-extend-selection-key (kbd "M-8")) +(defconst ergoemacs-select-text-in-quote-key (kbd "M-(")) diff --git a/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-us.el b/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-us.el new file mode 100755 index 0000000..5d70ccb --- /dev/null +++ b/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-layout-us.el @@ -0,0 +1,106 @@ +;-*- coding: utf-8 -*- +;; Shortcuts for ERGOEMACS_KEYBOARD_LAYOUT=us + +;;; -------------------------------------------------- +;;; CURSOR MOVEMENTS + +;; Single char cursor movement +(defconst ergoemacs-backward-char-key (kbd "M-j")) +(defconst ergoemacs-forward-char-key (kbd "M-l")) +(defconst ergoemacs-previous-line-key (kbd "M-i")) +(defconst ergoemacs-next-line-key (kbd "M-k")) + +;; Move by word +(defconst ergoemacs-backward-word-key (kbd "M-u")) +(defconst ergoemacs-forward-word-key (kbd "M-o")) + +;; Move by paragraph +(defconst ergoemacs-backward-paragraph-key (kbd "M-U")) +(defconst ergoemacs-forward-paragraph-key (kbd "M-O")) + +;; Move to beginning/ending of line +(defconst ergoemacs-move-beginning-of-line-key (kbd "M-h")) +(defconst ergoemacs-move-end-of-line-key (kbd "M-H")) + +;; Move by screen (page up/down) +(defconst ergoemacs-scroll-down-key (kbd "M-I")) +(defconst ergoemacs-scroll-up-key (kbd "M-K")) + +;; Move to beginning/ending of file +(defconst ergoemacs-beginning-of-buffer-key (kbd "M-J")) +(defconst ergoemacs-end-of-buffer-key (kbd "M-L")) + +;; isearch +(defconst ergoemacs-isearch-forward-key (kbd "M-;")) +(defconst ergoemacs-isearch-backward-key (kbd "M-:")) + +(defconst ergoemacs-recenter-key (kbd "M-p")) + +;;; MAJOR EDITING COMMANDS + +;; Delete previous/next char. +(defconst ergoemacs-delete-backward-char-key (kbd "M-d")) +(defconst ergoemacs-delete-char-key (kbd "M-f")) + +; Delete previous/next word. +(defconst ergoemacs-backward-kill-word-key (kbd "M-e")) +(defconst ergoemacs-kill-word-key (kbd "M-r")) + +; Copy Cut Paste, Paste previous +(defconst ergoemacs-kill-region-key (kbd "M-x")) +(defconst ergoemacs-kill-ring-save-key (kbd "M-c")) +(defconst ergoemacs-yank-key (kbd "M-v")) +(defconst ergoemacs-yank-pop-key (kbd "M-V")) +(defconst ergoemacs-copy-all-key (kbd "M-C")) +(defconst ergoemacs-cut-all-key (kbd "M-X")) + +;; undo and redo +(defconst ergoemacs-redo-key (kbd "M-Z")) +(defconst ergoemacs-undo-key (kbd "M-z")) + +; Kill line +(defconst ergoemacs-kill-line-key (kbd "M-g")) +(defconst ergoemacs-kill-line-backward-key (kbd "M-G")) + +;;; Textual Transformation + +(defconst ergoemacs-mark-paragraph-key (kbd "M-S-SPC")) +(defconst ergoemacs-shrink-whitespaces-key (kbd "M-w")) +(defconst ergoemacs-comment-dwim-key (kbd "M-'")) +(defconst ergoemacs-toggle-letter-case-key (kbd "M-/")) + +; keyword completion, because Alt+Tab is used by OS +(defconst ergoemacs-call-keyword-completion-key (kbd "M-t")) + +; Hard-wrap/un-hard-wrap paragraph +(defconst ergoemacs-compact-uncompact-block-key (kbd "M-q")) + +;;; EMACS'S SPECIAL COMMANDS + +; Mark point. +(defconst ergoemacs-set-mark-command-key (kbd "M-SPC")) + +(defconst ergoemacs-execute-extended-command-key (kbd "M-a")) +(defconst ergoemacs-shell-command-key (kbd "M-A")) + +;;; WINDOW SPLITING +(defconst ergoemacs-move-cursor-next-pane-key (kbd "M-s")) +(defconst ergoemacs-move-cursor-previous-pane-key (kbd "M-S")) + +;;; -------------------------------------------------- +;;; OTHER SHORTCUTS + +(defconst ergoemacs-switch-to-previous-frame-key (kbd "M-~")) +(defconst ergoemacs-switch-to-next-frame-key (kbd "M-`")) + +(defconst ergoemacs-query-replace-key (kbd "M-5")) +(defconst ergoemacs-query-replace-regexp-key (kbd "M-%")) + +(defconst ergoemacs-delete-other-windows-key (kbd "M-1")) +(defconst ergoemacs-delete-window-key (kbd "M-!")) + +(defconst ergoemacs-split-window-vertically-key (kbd "M-2")) +(defconst ergoemacs-split-window-horizontally-key (kbd "M-@")) + +(defconst ergoemacs-extend-selection-key (kbd "M-8")) +(defconst ergoemacs-select-text-in-quote-key (kbd "M-*")) diff --git a/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-mode.el b/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-mode.el new file mode 100755 index 0000000..59f735f --- /dev/null +++ b/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-mode.el @@ -0,0 +1,379 @@ +;-*- coding: utf-8 -*- +;; ergoemacs-mode.el -- A emacs keybinding set based on ergonomics. + +;; Copyright © 2007, 2008, 2009 by Xah Lee +;; Copyright © 2009 by David Capello + +;; Author: Xah Lee ( http://xahlee.org/ ), David Capello ( http://www.davidcapello.com.ar/ ) +;; Version: 5.1 +;; Keywords: qwerty, dvorak, keybinding, ergonomic, colemak + +;; You can redistribute this program and/or modify it under the terms +;; of the GNU General Public License as published by the Free Software +;; Foundation; either version 2, or (at your option) any later +;; version. + +;;; DESCRIPTION + +;; This keybinding set puts the most frequently used emacs keyboard +;; shortcuts into the most easy-to-type spots. +;; +;; For complete detail, see: +;; http://xahlee.org/emacs/ergonomic_emacs_keybinding.html + +;;; INSTALL + +;; See the file “_INSTALL.txt”. + +;;; HISTORY + +;; See the file “_HISTORY.txt”. + +;;; ACKNOWLEDGMENT +;; Thanks to Nikolaj Schumacher for his implementation of extend-selection. +;; Thanks to Andreas Politz and Nikolaj Schumacher for correcting/improving implementation of toggle-letter-case. +;; Thanks to Lennart Borgman for several suggestions on code to prevent shortcuts involving shift key to start select text when CUA-mode is on. +;; Thanks to David Capello for contribution to shrink-whitespaces. +;; Thanks to marciomazza for spotting several default bindings that should have been unbound. +;; Thanks to those who have created and improved the version for Colemak layout. They are (by date): “vockets”, “postivan”, Graham Poulter. +;; Thanks to lwarxx for bug report on diff-mode +;; Thanks to many users who send in comments and appreciations on this. + +;;; -------------------------------------------------- + +;; Add this same directory to load elisp files +(add-to-list 'load-path (file-name-directory (or load-file-name buffer-file-name))) + +;; Ergoemacs-keybindings version +(defconst ergoemacs-mode-version "5.1" + "Ergoemacs-keybindings minor mode version number.") + +;; Include extra files +(load "functions") +(load "ergoemacs-unbind") + +;; Load the keyboard layout looking the ERGOEMACS_KEYBOARD_LAYOUT +;; enviroment variable (this variable is set by ErgoEmacs runner) +(defvar ergoemacs-keyboard-layout (getenv "ERGOEMACS_KEYBOARD_LAYOUT") + "It is set with the value of ERGOEMACS_KEYBOARD_LAYOUT +enviroment variable. The possible values are: + + us = US English QWERTY keyboard layout + dv = US-Dvorak keyboard layout + sp = Spanish keyboard layout + it = Italian keyboard layout + colemak = Ergonomic Colemak keyboard layout") + +(cond + ((string= ergoemacs-keyboard-layout "us") + (load "ergoemacs-layout-us")) + ((or (string= ergoemacs-keyboard-layout "us_dvorak") + (string= ergoemacs-keyboard-layout "dv")) + (load "ergoemacs-layout-dv")) + ((string= ergoemacs-keyboard-layout "sp") + (load "ergoemacs-layout-sp")) + ((or (string= ergoemacs-keyboard-layout "it") + (string= ergoemacs-keyboard-layout "it142")) + (load "ergoemacs-layout-it")) + ((string= ergoemacs-keyboard-layout "colemak") + (load "ergoemacs-layout-colemak")) + (t ; US qwerty by default + (load "ergoemacs-layout-us")) + ) + +;;; -------------------------------------------------- +;;; ergoemacs-keymap + +(defvar ergoemacs-keymap (make-sparse-keymap) + "ErgoEmacs minor mode keymap.") + +;; Single char cursor movement +(define-key ergoemacs-keymap ergoemacs-backward-char-key 'backward-char) +(define-key ergoemacs-keymap ergoemacs-forward-char-key 'forward-char) +(define-key ergoemacs-keymap ergoemacs-previous-line-key 'previous-line) +(define-key ergoemacs-keymap ergoemacs-next-line-key 'next-line) + +;; Move by word +(define-key ergoemacs-keymap ergoemacs-backward-word-key 'backward-word) +(define-key ergoemacs-keymap ergoemacs-forward-word-key 'forward-word) + +;; Move by paragraph +(define-key ergoemacs-keymap ergoemacs-backward-paragraph-key 'backward-paragraph) +(define-key ergoemacs-keymap ergoemacs-forward-paragraph-key 'forward-paragraph) + +;; Move to beginning/ending of line +(define-key ergoemacs-keymap ergoemacs-move-beginning-of-line-key 'move-beginning-of-line) +(define-key ergoemacs-keymap ergoemacs-move-end-of-line-key 'move-end-of-line) + +;; Move by screen (page up/down) +(define-key ergoemacs-keymap ergoemacs-scroll-down-key 'scroll-down) +(define-key ergoemacs-keymap ergoemacs-scroll-up-key 'scroll-up) + +;; Move to beginning/ending of file +(define-key ergoemacs-keymap ergoemacs-beginning-of-buffer-key 'beginning-of-buffer) +(define-key ergoemacs-keymap ergoemacs-end-of-buffer-key 'end-of-buffer) + +;; isearch +(define-key ergoemacs-keymap ergoemacs-isearch-forward-key 'isearch-forward) +(define-key ergoemacs-keymap ergoemacs-isearch-backward-key 'isearch-backward) + +(define-key ergoemacs-keymap ergoemacs-recenter-key 'recenter) + +;;; MAJOR EDITING COMMANDS + +;; Delete previous/next char. +(define-key ergoemacs-keymap ergoemacs-delete-backward-char-key 'delete-backward-char) +(define-key ergoemacs-keymap ergoemacs-delete-char-key 'delete-char) + +; Delete previous/next word. +(define-key ergoemacs-keymap ergoemacs-backward-kill-word-key 'backward-kill-word) +(define-key ergoemacs-keymap ergoemacs-kill-word-key 'kill-word) + +; Copy Cut Paste, Paste previous +(define-key ergoemacs-keymap ergoemacs-kill-region-key 'kill-region) +(define-key ergoemacs-keymap ergoemacs-kill-ring-save-key 'kill-ring-save) +(define-key ergoemacs-keymap ergoemacs-yank-key 'yank) +(define-key ergoemacs-keymap ergoemacs-yank-pop-key 'yank-pop) +(define-key ergoemacs-keymap ergoemacs-copy-all-key 'copy-all) +(define-key ergoemacs-keymap ergoemacs-cut-all-key 'cut-all) + +;; undo and redo +(define-key ergoemacs-keymap ergoemacs-redo-key 'redo) +(define-key ergoemacs-keymap ergoemacs-undo-key 'undo) + +; Kill line +(define-key ergoemacs-keymap ergoemacs-kill-line-key 'kill-line) +(define-key ergoemacs-keymap ergoemacs-kill-line-backward-key 'kill-line-backward) + +;;; Textual Transformation + +(define-key ergoemacs-keymap ergoemacs-mark-paragraph-key 'mark-paragraph) +(define-key ergoemacs-keymap ergoemacs-shrink-whitespaces-key 'shrink-whitespaces) +(define-key ergoemacs-keymap ergoemacs-comment-dwim-key 'comment-dwim) +(define-key ergoemacs-keymap ergoemacs-toggle-letter-case-key 'toggle-letter-case) + +; keyword completion, because Alt+Tab is used by OS +(define-key ergoemacs-keymap ergoemacs-call-keyword-completion-key 'call-keyword-completion) + +; Hard-wrap/un-hard-wrap paragraph +(define-key ergoemacs-keymap ergoemacs-compact-uncompact-block-key 'compact-uncompact-block) + +;;; EMACS'S SPECIAL COMMANDS + +; Mark point. +(define-key ergoemacs-keymap ergoemacs-set-mark-command-key 'set-mark-command) + +(define-key ergoemacs-keymap ergoemacs-execute-extended-command-key 'execute-extended-command) +(define-key ergoemacs-keymap ergoemacs-shell-command-key 'shell-command) + +;;; WINDOW SPLITING +(define-key ergoemacs-keymap ergoemacs-move-cursor-next-pane-key 'move-cursor-next-pane) +(define-key ergoemacs-keymap ergoemacs-move-cursor-previous-pane-key 'move-cursor-previous-pane) + +;;; -------------------------------------------------- +;;; STANDARD SHORTCUTS + +(define-key ergoemacs-keymap (kbd "C-n") 'new-empty-buffer) +(define-key ergoemacs-keymap (kbd "C-S-n") 'make-frame-command) +(define-key ergoemacs-keymap (kbd "C-o") 'find-file) +(define-key ergoemacs-keymap (kbd "C-w") 'close-current-buffer) +(define-key ergoemacs-keymap (kbd "C-s") 'save-buffer) +(define-key ergoemacs-keymap (kbd "C-S-s") 'write-file) +(define-key ergoemacs-keymap (kbd "C-p") 'print-buffer) +(define-key ergoemacs-keymap (kbd "C-a") 'mark-whole-buffer) +(define-key ergoemacs-keymap (kbd "C-S-w") 'delete-frame) + +(define-key ergoemacs-keymap (kbd "C-f") 'search-forward) + +(define-key ergoemacs-keymap (kbd "") 'delete-char) ; the Del key for forward delete. Needed if C-d is set to nil. + +(define-key ergoemacs-keymap (kbd "C-") 'previous-user-buffer) +(define-key ergoemacs-keymap (kbd "C-") 'next-user-buffer) + +(define-key ergoemacs-keymap (kbd "C-S-") 'previous-emacs-buffer) +(define-key ergoemacs-keymap (kbd "C-S-") 'next-emacs-buffer) + +(define-key ergoemacs-keymap (kbd "M-S-") 'backward-page) +(define-key ergoemacs-keymap (kbd "M-S-") 'forward-page) + +(define-key ergoemacs-keymap (kbd "C-x C-b") 'ibuffer) +(define-key ergoemacs-keymap (kbd "C-h m") 'describe-major-mode) +(define-key ergoemacs-keymap (kbd "C-h o") 'where-is-old-binding) + +;; Ctrl+Break is a common IDE shortcut to stop compilation/find/grep +(define-key ergoemacs-keymap (kbd "C-") 'kill-compilation) + +;;; -------------------------------------------------- +;;; OTHER SHORTCUTS + +(define-key ergoemacs-keymap ergoemacs-switch-to-previous-frame-key 'switch-to-previous-frame) +(define-key ergoemacs-keymap ergoemacs-switch-to-next-frame-key 'switch-to-next-frame) + +(define-key ergoemacs-keymap ergoemacs-query-replace-key 'query-replace) +(define-key ergoemacs-keymap ergoemacs-query-replace-regexp-key 'query-replace-regexp) + +(define-key ergoemacs-keymap ergoemacs-delete-other-windows-key 'delete-other-windows) +(define-key ergoemacs-keymap ergoemacs-delete-window-key 'delete-window) + +(define-key ergoemacs-keymap ergoemacs-split-window-vertically-key 'split-window-vertically) +(define-key ergoemacs-keymap ergoemacs-split-window-horizontally-key 'split-window-horizontally) + +(define-key ergoemacs-keymap ergoemacs-extend-selection-key 'extend-selection) +(define-key ergoemacs-keymap ergoemacs-select-text-in-quote-key 'select-text-in-quote) + +;;---------------------------------------------------------------------- +;; ErgoEmacs hooks + +(defun ergoemacs-cua-hook () + "Prevent `cua-mode' from going into selection mode when commands with Shift key is used." + + (put 'cua-scroll-down 'CUA nil) + (put 'cua-scroll-up 'CUA nil) + (put 'backward-paragraph 'CUA nil) + (put 'forward-paragraph 'CUA nil) + (put 'beginning-of-buffer 'CUA nil) + (put 'end-of-buffer 'CUA nil) + (put 'move-end-of-line 'CUA nil) + ) + +(defun ergoemacs-minibuffer-setup-hook () + "Hook for minibuffer to move through history with previous-line and next-line keys." + + (defvar ergoemacs-minibuffer-keymap (copy-keymap ergoemacs-keymap)) + + (define-key ergoemacs-minibuffer-keymap ergoemacs-previous-line-key 'previous-history-element) + (define-key ergoemacs-minibuffer-keymap ergoemacs-next-line-key 'next-history-element) + (define-key ergoemacs-minibuffer-keymap (kbd "") 'previous-history-element) + (define-key ergoemacs-minibuffer-keymap (kbd "") 'next-history-element) + (define-key ergoemacs-minibuffer-keymap (kbd "S-") 'previous-matching-history-element) + (define-key ergoemacs-minibuffer-keymap (kbd "S-") 'next-matching-history-element) + + (add-to-list 'minor-mode-overriding-map-alist (cons 'ergoemacs-mode ergoemacs-minibuffer-keymap)) + ) + +(defun ergoemacs-isearch-hook () + "Hook for `isearch-mode-hook' so ergoemacs keybindings are not lost." + + ;; TODO restore these keys! (it is not necessary, when the + ;; ergoemacs-isearch-hook is removed from isearch-mode-hook) + + (define-key isearch-mode-map (kbd "M-p") 'nil) ; was isearch-ring-retreat + (define-key isearch-mode-map (kbd "M-n") 'nil) ; was isearch-ring-advance + (define-key isearch-mode-map (kbd "M-y") 'nil) ; was isearch-yank-kill + (define-key isearch-mode-map (kbd "M-c") 'nil) ; was isearch-toggle-case-fold + (define-key isearch-mode-map (kbd "M-r") 'nil) ; was isearch-toggle-regexp + (define-key isearch-mode-map (kbd "M-e") 'nil) ; was isearch-edit-string + + (define-key isearch-mode-map ergoemacs-isearch-forward-key 'isearch-repeat-forward) + (define-key isearch-mode-map ergoemacs-isearch-backward-key 'isearch-repeat-backward) + (define-key isearch-mode-map ergoemacs-recenter-key 'recenter) + (define-key isearch-mode-map ergoemacs-yank-key 'isearch-yank-kill) + + ;; isearch-other-control-char sends the key to the original buffer and cancels isearch + (define-key isearch-mode-map ergoemacs-kill-ring-save-key 'isearch-other-control-char) + (define-key isearch-mode-map ergoemacs-kill-word-key 'isearch-other-control-char) + (define-key isearch-mode-map ergoemacs-backward-kill-word-key 'isearch-other-control-char) + + (define-key isearch-mode-map (kbd "") 'isearch-ring-retreat) + (define-key isearch-mode-map (kbd "") 'isearch-ring-advance) + ) + +;; Hook for interpreters +(defun ergoemacs-comint-hook () + "Hook for `comint-mode-hook'." + + (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 "S-") 'comint-next-matching-input) + ) + +;; Log edit mode +(defun ergoemacs-log-edit-hook () + "Hook for `log-edit-mode-hook'." + + (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 "S-") 'log-edit-next-comment) + ) + +(defun ergoemacs-eshell-hook () + "Hook for `eshell-mode-hook', to redefine some ErgoEmacs keys so they are more useful." + + ;; Redefining ergoemacs-move-beginning-of-line-key to eshell-bol in eshell-mode-map + ;; does not work, we have to use minor-mode-overriding-map-alist in this case + (defvar ergoemacs-eshell-keymap (copy-keymap ergoemacs-keymap)) + + (define-key ergoemacs-eshell-keymap ergoemacs-move-beginning-of-line-key 'eshell-bol) + (define-key ergoemacs-eshell-keymap (kbd "") 'eshell-bol) + (define-key ergoemacs-eshell-keymap (kbd "") 'eshell-previous-matching-input-from-input) + (define-key ergoemacs-eshell-keymap (kbd "") 'eshell-next-matching-input-from-input) + (define-key ergoemacs-eshell-keymap (kbd "S-") 'eshell-previous-matching-input-from-input) + (define-key ergoemacs-eshell-keymap (kbd "S-") 'eshell-next-matching-input-from-input) + + (add-to-list 'minor-mode-overriding-map-alist (cons 'ergoemacs-mode ergoemacs-eshell-keymap)) + ) + +(defun ergoemacs-iswitchb-hook () + "Hooks for `iswitchb-minibuffer-setup-hook'." + + (defvar ergoemacs-iswitchb-keymap (copy-keymap ergoemacs-keymap)) + + (define-key ergoemacs-iswitchb-keymap ergoemacs-isearch-backward-key 'iswitchb-prev-match) + (define-key ergoemacs-iswitchb-keymap ergoemacs-isearch-forward-key 'iswitchb-next-match) + + (define-key ergoemacs-iswitchb-keymap (kbd "") 'iswitchb-prev-match) + (define-key ergoemacs-iswitchb-keymap (kbd "") 'iswitchb-next-match) + (define-key ergoemacs-iswitchb-keymap (kbd "S-") 'iswitchb-prev-match) + (define-key ergoemacs-iswitchb-keymap (kbd "S-") 'iswitchb-next-match) + + (add-to-list 'minor-mode-overriding-map-alist (cons 'ergoemacs-mode ergoemacs-iswitchb-keymap)) + ) + +(defun ergoemacs-hook-modes () + "Installs/Removes ErgoEmacs minor mode hooks from major modes +depending the state of `ergoemacs-mode' variable. If the mode +is being initialized, some global keybindings in current-global-map +will change." + + (let ((modify-hook (if ergoemacs-mode 'add-hook 'remove-hook))) + + ;; when ergoemacs-mode is on, activate hooks and unset global keys, else do inverse + (if (and ergoemacs-mode (not (equal ergoemacs-mode 0))) + (ergoemacs-unset-redundant-global-keys) + (ergoemacs-restore-global-keys)) + + (funcall modify-hook 'cua-mode-hook 'ergoemacs-cua-hook) + (funcall modify-hook 'isearch-mode-hook 'ergoemacs-isearch-hook) + (funcall modify-hook 'comint-mode-hook 'ergoemacs-comint-hook) + (funcall modify-hook 'log-edit-mode-hook 'ergoemacs-log-edit-hook) + (funcall modify-hook 'eshell-mode-hook 'ergoemacs-eshell-hook) + (funcall modify-hook 'minibuffer-setup-hook 'ergoemacs-minibuffer-setup-hook) + (funcall modify-hook 'iswitchb-minibuffer-setup-hook 'ergoemacs-iswitchb-hook) + ) + ) + +;;---------------------------------------------------------------------- +;; ErgoEmacs minor mode + +(define-minor-mode ergoemacs-mode + "Toggle ergoemacs keybinding mode. +This minor mode changes your emacs keybindings. +Without argument, toggles the minor mode. +If optional argument is 1, turn it on. +If optional argument is 0, turn it off. +Argument of t or nil should not be used. +For full documentation, see: +URL `http://xahlee.org/emacs/ergonomic_emacs_keybinding.html' + +If you turned on by mistake, the shortcut to call execute-extended-command is M-a." + nil + :lighter " ErgoEmacs" ;; TODO this should be nil (it is for testing purposes) + :global t + :keymap ergoemacs-keymap + + (ergoemacs-hook-modes) + ) + +(provide 'ergoemacs-mode) diff --git a/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-unbind.el b/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-unbind.el new file mode 100644 index 0000000..e902231 --- /dev/null +++ b/.emacs.d/ergoemacs-keybindings-5.1/ergoemacs-unbind.el @@ -0,0 +1,205 @@ +;-*- coding: utf-8 -*- + +;; this file define keys that we want to set/unset because they are already defined by ergoemacs minor mode + +(eval-when-compile (require 'edmacro)) + +(defconst ergoemacs-redundant-keys + '( "C-/" + "C-0" + "C-1" + "C-2" + "C-3" + "C-4" + "C-5" + "C-6" + "C-7" + "C-8" + "C-9" + "C-" + "C-" + "C-" + "C-@" + "C-M-%" + "C-_" + "C-a" + "C-b" + "C-d" + "C-e" + "C-f" + "C-j" + "C-k" + "C-l" + "C-n" + "C-o" + "C-p" + "C-r" + "C-s" + "C-t" + "C-v" + "C-w" + "C-x 0" + "C-x 1" + "C-x 2" + "C-x 3" + "C-x 5 0" + "C-x 5 2" + "C-x C-d" + "C-x C-f" + "C-x C-s" + "C-x C-w" + "C-x d" + "C-x h" + "C-x o" + "C-y" + "C-z" + "M--" + "M-0" + "M-1" + "M-2" + "M-3" + "M-4" + "M-5" + "M-6" + "M-7" + "M-8" + "M-9" + "M-<" + "M->" + "M-@" + "M-\\" + "M-a" + "M-b" + "M-c" + "M-d" + "M-e" + "M-f" + "M-h" + "M-i" + "M-j" + "M-k" + "M-l" + "M-m" + "M-n" + "M-o" + "M-p" + "M-q" + "M-r" + "M-s" + "M-t" + "M-u" + "M-v" + "M-w" + "M-x" + "M-y" + "M-z" + "M-{" + "M-}" + ) + ) + +;; Some exceptions we don't want to unset. +;; "C-g" 'keyboard-quit +;; "C-i" 'indent-for-tab-command +;; "C-m" 'newline-and-indent +;; "C-q" 'quote-insert +;; "C-u" 'universal-argument +;; "C-h" ; (help-map) +;; "C-x" ; (ctl-x-map) +;; "C-c" ; (prefix) +;; "M-g" ; (prefix) + +(defvar ergoemacs-overridden-global-keys '() + "Alist to store overridden keyboard shortcuts in + `current-global-map' and other maps. Each item looks like '(MAP KEY OLD-COMMAND).") + +(defun ergoemacs-unset-global-key (map key-s) + "Sets to nil the associated command for the specified key in specified map. +It is like: + + \(define-key map (kbd key-s) nil)) + +But it saves the old command associated with the +specified key, so we can restore it when ergoemacs minor mode is +disabled at `ergoemacs-restore-global-keys'." + (let (key oldcmd) + (setq key (edmacro-parse-keys key-s)) + ;; get the old command associated with this key + (setq oldcmd (lookup-key map key)) + ;; save that shortcut in ergoemacs-overridden-global-keys + (if oldcmd + (add-to-list 'ergoemacs-overridden-global-keys (cons map (cons key-s (cons oldcmd nil))))) + ;; redefine the key in the ergoemacs-keymap + (define-key map key nil) + ) + ) + +(defun ergoemacs-unset-redundant-global-keys () + "Unsets redundant keyboard shortcuts that should not be used in ErgoEmacs." + (mapc (lambda (x) + (ergoemacs-unset-global-key (current-global-map) x)) + ergoemacs-redundant-keys) + ) + +(defun ergoemacs-restore-global-keys () + "Restores all keyboard shortcuts that were overwritten by `ergoemacs-unbind-global-key'." + (mapc (lambda (x) + (define-key + (car x) + (edmacro-parse-keys (car (cdr x))) + (car (cdr (cdr x)))) + ) + ergoemacs-overridden-global-keys) + (setq ergoemacs-overridden-global-keys '()) ; clear the list + ) + +;; Based on describe-key-briefly +(defun where-is-old-binding (&optional key) + "Print the name of the function KEY invoked before to start ErgoEmacs minor mode." + (interactive + (let ((enable-disabled-menus-and-buttons t) + (cursor-in-echo-area t) + saved-yank-menu) + (unwind-protect + (let (key) + ;; If yank-menu is empty, populate it temporarily, so that + ;; "Select and Paste" menu can generate a complete event. + (when (null (cdr yank-menu)) + (setq saved-yank-menu (copy-sequence yank-menu)) + (menu-bar-update-yank-menu "(any string)" nil)) + (setq key (read-key-sequence "Describe old key (or click or menu item): ")) + ;; If KEY is a down-event, read and discard the + ;; corresponding up-event. Note that there are also + ;; down-events on scroll bars and mode lines: the actual + ;; event then is in the second element of the vector. + (and (vectorp key) + (let ((last-idx (1- (length key)))) + (and (eventp (aref key last-idx)) + (memq 'down (event-modifiers (aref key last-idx))))) + (read-event)) + (list key)) + ;; Put yank-menu back as it was, if we changed it. + (when saved-yank-menu + (setq yank-menu (copy-sequence saved-yank-menu)) + (fset 'yank-menu (cons 'keymap yank-menu)))))) + + (let (key-desc item-key item-cmd old-cmd) + (setq key-desc (key-description key)) + (setq item ergoemacs-overridden-global-keys) + (while (and item (not old-cmd)) + (setq item-key (car (cdr (car item)))) + (setq item-cmd (car (cdr (cdr (car item))))) + (if (string= item-key key-desc) + (setq old-cmd item-cmd)) + (setq item (cdr item)) + ) + (if old-cmd + (with-temp-buffer + (where-is old-cmd t) + (message "Key %s was bound to %s which is now invoked by %s" + key-desc old-cmd (buffer-string)) + ) + (message "Key %s was not bound to any command" key-desc) + ) + ) + ) diff --git a/.emacs.d/ergoemacs-keybindings-5.1/functions.el b/.emacs.d/ergoemacs-keybindings-5.1/functions.el new file mode 100755 index 0000000..1a86f9f --- /dev/null +++ b/.emacs.d/ergoemacs-keybindings-5.1/functions.el @@ -0,0 +1,385 @@ +;-*- coding: utf-8 -*- + +(require 'redo "redo.elc" t) ; for redo shortcut + +(delete-selection-mode 1) ; turn on text selection highlighting and make typing override selected text (Note: when delete-selection-mode is on, then transient-mark-mode is automatically on too.) + +(defun call-keyword-completion () + "Call the command that has keyboard shortcut M-TAB." + (interactive) + (call-interactively (key-binding (kbd "M-TAB"))) +) + +(defun describe-major-mode () + "Show inline doc for current major-mode." + ;; code by Kevin Rodgers. 2009-02-25 + (interactive) + (describe-function major-mode)) + +(defun copy-all () + "Put the whole buffer content into the kill-ring. +If narrow-to-region is in effect, then copy that region only." + (interactive) + (kill-ring-save (point-min) (point-max)) + (message "Buffer content copied") + ) + +(defun cut-all () + "Cut the whole buffer content into the kill-ring. +If narrow-to-region is in effect, then cut that region only." + (interactive) + (kill-region (point-min) (point-max)) + (message "Buffer content cut") + ) + +;;; TEXT SELECTION RELATED + +(defun select-text-in-quote () + "Select text between the nearest left and right delimiters. +Delimiters are paired characters: ()[]<>«»“”‘’「」【】, including \"\"." + (interactive) + (let (b1 b2) + (skip-chars-backward "^<>(“{[「«【\"‘") + (setq b1 (point)) + (skip-chars-forward "^<>)”}]」】»\"’") + (setq b2 (point)) + (set-mark b1) + ) + ) + +;; by Nikolaj Schumacher, 2008-10-20. Released under GPL. +(defun semnav-up (arg) + (interactive "p") + (when (nth 3 (syntax-ppss)) + (if (> arg 0) + (progn + (skip-syntax-forward "^\"") + (goto-char (1+ (point))) + (decf arg)) + (skip-syntax-backward "^\"") + (goto-char (1- (point))) + (incf arg))) + (up-list arg)) + +;; by Nikolaj Schumacher, 2008-10-20. Released under GPL. +(defun extend-selection (arg &optional incremental) + "Select the current word. +Subsequent calls expands the selection to larger semantic unit." + (interactive (list (prefix-numeric-value current-prefix-arg) + (or (and transient-mark-mode mark-active) + (eq last-command this-command)))) + (if incremental + (progn + (semnav-up (- arg)) + (forward-sexp) + (mark-sexp -1)) + (if (> arg 1) + (extend-selection (1- arg) t) + (if (looking-at "\\=\\(\\s_\\|\\sw\\)*\\_>") + (goto-char (match-end 0)) + (unless (memq (char-before) '(?\) ?\")) + (forward-sexp))) + (mark-sexp -1)))) + +;;; TEXT TRANSFORMATION RELATED + +(defun kill-line-backward () + "Kill text between the beginning of the line to the cursor position. +If there's no text, delete the previous line ending." + (interactive) + (if (looking-back "\n") + (delete-char -1) + (kill-line 0) + ) + ) + +(defun move-cursor-next-pane () + "Move cursor to the next pane." + (interactive) + (other-window 1) + ) + +(defun move-cursor-previous-pane () + "Move cursor to the previous pane." + (interactive) + (other-window -1) + ) + +(defun compact-uncompact-block () + "Remove or add line endings on the current block of text. +This is similar to a toggle for fill-paragraph and unfill-paragraph +When there is a text selection, act on the region. + +When in text mode, a paragraph is considerd a block. When in programing +language mode, the block is defined by between empty lines. + +Todo: The programing language behavior is currently not done. +Right now, the code uses fill* functions, so does not work or work well +in programing lang modes. A proper implementation to compact is replacing +EOL chars by space when the EOL char is not inside string." + (interactive) + + ;; This command symbol has a property “'stateIsCompact-p”, the + ;; possible values are t and nil. This property is used to easily + ;; determine whether to compact or uncompact, when this command is + ;; called again + + (let (bds currentLineCharCount currentStateIsCompact + (bigFillColumnVal 4333999) (deactivate-mark nil)) + + (save-excursion + ;; currentLineCharCount is used to determine whether current state + ;; is compact or not, when the command is run for the first time + (setq currentLineCharCount + (progn + (setq bds (bounds-of-thing-at-point 'line)) + (length (buffer-substring-no-properties (car bds) (cdr bds))) + ;; Note: 'line includes eol if it is not buffer's last line + ) + ) + + ;; Determine whether the text is currently compact. when the last + ;; command is this, then symbol property easily tells, but when + ;; this command is used fresh, right now we use num of chars of + ;; the cursor line as a way to define current compatness state + (setq currentStateIsCompact + (if (eq last-command this-command) + (get this-command 'stateIsCompact-p) + (if (> currentLineCharCount fill-column) t nil) + ) + ) + + (if (and transient-mark-mode mark-active) + (if currentStateIsCompact + (fill-region (region-beginning) (region-end)) + (let ((fill-column bigFillColumnVal)) + (fill-region (region-beginning) (region-end))) + ) + (if currentStateIsCompact + (fill-paragraph nil) + (let ((fill-column bigFillColumnVal)) + (fill-paragraph nil)) + ) + ) + + (put this-command 'stateIsCompact-p (if currentStateIsCompact + nil t)) ) ) ) + +(defun shrink-whitespaces () + "Remove white spaces around cursor to just one or none. +If current line does not contain non-white space chars, then remove blank lines to just one. +If current line contains non-white space chars, then shrink any whitespace char surrounding cursor to just one space. +If current line is a single space, remove that space. + +Calling this command 3 times will always result in no whitespaces around cursor." + (interactive) + (let ( + cursor-point + line-has-meat-p ; current line contains non-white space chars + spaceTabNeighbor-p + whitespace-begin whitespace-end + space-or-tab-begin space-or-tab-end + line-begin-pos line-end-pos + ) + (save-excursion + ;; todo: might consider whitespace as defined by syntax table, and also consider whitespace chars in unicode if syntax table doesn't already considered it. + (setq cursor-point (point)) + + (setq spaceTabNeighbor-p (if (or (looking-at " \\|\t") (looking-back " \\|\t")) t nil) ) + (move-beginning-of-line 1) (setq line-begin-pos (point) ) + (move-end-of-line 1) (setq line-end-pos (point) ) + ;; (re-search-backward "\n$") (setq line-begin-pos (point) ) + ;; (re-search-forward "\n$") (setq line-end-pos (point) ) + (setq line-has-meat-p (if (< 0 (count-matches "[[:graph:]]" line-begin-pos line-end-pos)) t nil) ) + (goto-char cursor-point) + + (skip-chars-backward "\t ") + (setq space-or-tab-begin (point)) + + (skip-chars-backward "\t \n") + (setq whitespace-begin (point)) + + (goto-char cursor-point) (skip-chars-forward "\t ") + (setq space-or-tab-end (point)) + (skip-chars-forward "\t \n") + (setq whitespace-end (point)) + ) + + (if line-has-meat-p + (let (deleted-text) + (when spaceTabNeighbor-p + ;; remove all whitespaces in the range + (setq deleted-text (delete-and-extract-region space-or-tab-begin space-or-tab-end)) + ;; insert a whitespace only if we have removed something + ;; different that a simple whitespace + (if (not (string= deleted-text " ")) + (insert " ") ) ) ) + + (progn + ;; (delete-region whitespace-begin whitespace-end) + ;; (insert "\n") + (delete-blank-lines) + ) + ;; todo: possibly code my own delete-blank-lines here for better efficiency, because delete-blank-lines seems complex. + ) + ) + ) + +(defun toggle-letter-case () + "Toggle the letter case of current word or text selection. +Toggles from 3 cases: UPPER CASE, lower case, Title Case, +in that cyclic order." +(interactive) +(let (pos1 pos2 (deactivate-mark nil) (case-fold-search nil)) + (if (and transient-mark-mode mark-active) + (setq pos1 (region-beginning) + pos2 (region-end)) + (setq pos1 (car (bounds-of-thing-at-point 'word)) + pos2 (cdr (bounds-of-thing-at-point 'word)))) + + (when (not (eq last-command this-command)) + (save-excursion + (goto-char pos1) + (cond + ((looking-at "[[:lower:]][[:lower:]]") (put this-command 'state "all lower")) + ((looking-at "[[:upper:]][[:upper:]]") (put this-command 'state "all caps") ) + ((looking-at "[[:upper:]][[:lower:]]") (put this-command 'state "init caps") ) + (t (put this-command 'state "all lower") ) + ) + ) + ) + + (cond + ((string= "all lower" (get this-command 'state)) + (upcase-initials-region pos1 pos2) (put this-command 'state "init caps")) + ((string= "init caps" (get this-command 'state)) + (upcase-region pos1 pos2) (put this-command 'state "all caps")) + ((string= "all caps" (get this-command 'state)) + (downcase-region pos1 pos2) (put this-command 'state "all lower")) + ) +) +) + +;;; FRAME + +(defun switch-to-next-frame () + "Select the next frame on current display, and raise it." + (interactive) + (other-frame 1) + ) + +(defun switch-to-previous-frame () + "Select the previous frame on current display, and raise it." + (interactive) + (other-frame -1) + ) + +;;; BUFFER RELATED + +(defun next-user-buffer () + "Switch to the next user buffer. +User buffers are those whose name does not start with *." + (interactive) + (next-buffer) + (let ((i 0)) + (while (and (string-match "^*" (buffer-name)) (< i 50)) + (setq i (1+ i)) (next-buffer) ))) + +(defun previous-user-buffer () + "Switch to the previous user buffer. +User buffers are those whose name does not start with *." + (interactive) + (previous-buffer) + (let ((i 0)) + (while (and (string-match "^*" (buffer-name)) (< i 50)) + (setq i (1+ i)) (previous-buffer) ))) + +(defun next-emacs-buffer () + "Switch to the next emacs buffer. +Emacs buffers are those whose name starts with *." + (interactive) + (next-buffer) + (let ((i 0)) + (while (and (not (string-match "^*" (buffer-name))) (< i 50)) + (setq i (1+ i)) (next-buffer) ))) + +(defun previous-emacs-buffer () + "Switch to the previous emacs buffer. +Emacs buffers are those whose name starts with *." + (interactive) + (previous-buffer) + (let ((i 0)) + (while (and (not (string-match "^*" (buffer-name))) (< i 50)) + (setq i (1+ i)) (previous-buffer) ))) + +(defun new-empty-buffer () + "Opens a new empty buffer." + (interactive) + (let ((buf (generate-new-buffer "untitled"))) + (switch-to-buffer buf) + (funcall (and initial-major-mode)) + (setq buffer-offer-save t))) +;; note: emacs won't offer to save a buffer that's +;; not associated with a file, +;; even if buffer-modified-p is true. +;; One work around is to define your own my-kill-buffer function +;; that wraps around kill-buffer, and check on the buffer modification +;; status to offer save +;; This custome kill buffer is close-current-buffer. + + +(defvar recently-closed-buffers (cons nil nil) "A list of recently closed buffers. The max number to track is controlled by the variable recently-closed-buffers-max.") +(defvar recently-closed-buffers-max 10 "The maximum length for recently-closed-buffers.") + +(defun close-current-buffer () +"Close the current buffer. + +Similar to (kill-buffer (current-buffer)) with the following addition: + +• prompt user to save if the buffer has been modified even if the buffer is not associated with a file. +• make sure the buffer shown after closing is a user buffer. +• if the buffer is a file, add the path to the list recently-closed-buffers. + +A emacs buffer is one who's name starts with *. +Else it is a user buffer." + (interactive) + (let (emacsBuff-p isEmacsBufferAfter) + (if (string-match "^*" (buffer-name)) + (setq emacsBuff-p t) + (setq emacsBuff-p nil)) + + ;; offer to save buffers that are non-empty and modified, even for non-file visiting buffer. (because kill-buffer does not offer to save buffers that are not associated with files) + (when (and (buffer-modified-p) + (not emacsBuff-p) + (not (string-equal major-mode "dired-mode")) + (if (equal (buffer-file-name) nil) + (if (string-equal "" (save-restriction (widen) (buffer-string))) nil t) + t + ) + ) + (if (y-or-n-p + (concat "Buffer " (buffer-name) " modified; Do you want to save?")) + (save-buffer) + (set-buffer-modified-p nil))) + + ;; save to a list of closed buffer + (when (not (equal buffer-file-name nil)) + (setq recently-closed-buffers + (cons (cons (buffer-name) (buffer-file-name)) recently-closed-buffers)) + (when (> (length recently-closed-buffers) recently-closed-buffers-max) + (setq recently-closed-buffers (butlast recently-closed-buffers 1)) + ) + ) + + ;; close + (kill-buffer (current-buffer)) + + ;; if emacs buffer, switch to a user buffer + (if (string-match "^*" (buffer-name)) + (setq isEmacsBufferAfter t) + (setq isEmacsBufferAfter nil)) + (when isEmacsBufferAfter + (previous-user-buffer) + ) + ) + ) diff --git a/.emacs.d/line-num.el b/.emacs.d/line-num.el deleted file mode 100644 index e18a917..0000000 --- a/.emacs.d/line-num.el +++ /dev/null @@ -1,265 +0,0 @@ -;;; line-num.el --- Display line numbers in left-margin of buffer. -;; -;; Filename: line-num.el -;; Description: Display line numbers in left-margin of buffer. -;; Author: (Darryl Okahata) darrylo@hpsrdmo, Drew Adams -;; Maintainer: Drew Adams -;; Copyright (C) 1999-2009, Drew Adams, all rights reserved. -;; Copyright (C) 1989, Hewlett-Packard, all rights reserved. -;; Created: Wed Mar 31 16:18:24 1999 -;; Version: 21.0 -;; Last-Updated: Sat Dec 27 10:09:30 2008 (-0800) -;; By: dradams -;; Update #: 206 -;; URL: http://www.emacswiki.org/cgi-bin/wiki/line-num.el -;; Keywords: local -;; Compatibility: GNU Emacs 20.x, GNU Emacs 21.x, GNU Emacs 22.x -;; -;; Features that might be required by this library: -;; -;; None -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Commentary: -;; -;; Display line numbers in left-margin of buffer. -;; -;; New functions defined here: -;; -;; `display-line-numbers', `toggle-line-numbers-display', -;; `turn-on-line-numbers-display', `turn-off-line-numbers-display'. -;; -;; NOTE: `setnu.el' now provides similar, but generally better, -;; functionality. -;; -;; Original author was Darryl Okahata darrylo@hpsrdmo: The copy on -;; which the current (Adams) modifications were made was obtained from -;; Rick Kunin (rickk@sperdk). -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Change log: -;; -;; 2004/11/26 dadams -;; Replaced decf with setq...1+. -;; turn-off-line-numbers-display: Error if not displaying line #s. -;; Removed calls to `fit-frame' (and require of fit-frame.el). -;; 2000/11/01 dadams -;; 1. Added: toggle-line-numbers-display, turn-on-line-numbers-display, -;; turn-off-line-numbers-display. -;; 2. Added global vars: displaying-line-numbers-p, -;; display-line-numbers-format-string, display-line-numbers-first-line, -;; display-line-numbers-count, display-line-numbers-buffer-name, -;; display-line-numbers-modified-p. -;; 1999/04/14 dadams -;; Commented out assignment to unused free var: insert-end. -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; This program 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 2, or (at your option) -;; any later version. - -;; This program 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 this program; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth -;; Floor, Boston, MA 02110-1301, USA. -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Code: - -;;>> Problem: Tabs at beginning of lines - - -(and (< emacs-major-version 20) (eval-when-compile (require 'cl))) ;; when, unless - -;;;;;;;;;;;;; - - -;;;###autoload -(defun display-line-numbers () - "Temporarily display line numbers in left margin of current buffer." - (interactive) - (or (eq (current-buffer) (window-buffer (selected-window))) - (error "Current buffer, %s, is not the selected window's buffer" - (buffer-name))) - (let ((buffer-read-only nil) - (modified (buffer-modified-p)) - (name buffer-file-name) - (point (point-marker)) - format-string - line-number - (count 0) - nlines - first-line) - (save-restriction - (widen) - (save-excursion - (setq first-line (window-start (selected-window))) - (goto-char first-line) - (setq line-number (1+ (count-lines (point-min) (point)))) - (move-to-window-line -1) - (beginning-of-line) - (setq nlines (count-lines first-line (point))) - (let ((max (+ line-number nlines))) - (setq format-string (cond ((< max 100) "%2d ") - ((< max 1000) "%3d ") - ((< max 10000) "%4d ") - (t "%7d ")))))) - (save-excursion - (unwind-protect - (progn - (goto-char first-line) - ;; defeat file locking... don't try this at home, kids! - (setq buffer-file-name nil) - (while (<= count nlines) - (insert-before-markers (format format-string line-number)) - ;;;(setq insert-end (point)) THIS VAR IS FREE - AND UNUSED! - (setq line-number (1+ line-number)) - (setq count (1+ count)) - (forward-line 1)) - (set-window-start (selected-window) first-line) - (goto-char point) - (set-buffer-modified-p modified) - (message "<<< Press SPACE to continue >>>") - (let ((char (read-char))) - (or (eql char ?\ ) - (setq unread-command-events (list char)))) - ) - (goto-char first-line) - (let ((n (1+ (- (aref format-string 1) ?0)))) - (while (> count 0) - (setq count (1- count)) - (delete-char n) - (forward-line 1))) - (setq buffer-file-name name) - (set-buffer-modified-p modified))))) - -;;;----------------------------------------------------------------- - -(defvar displaying-line-numbers-p nil) -(make-variable-buffer-local 'displaying-line-numbers-p) -(defvar display-line-numbers-format-string nil) -(make-variable-buffer-local 'display-line-numbers-format-string) -(defvar display-line-numbers-first-line nil) -(make-variable-buffer-local 'display-line-numbers-first-line) -(defvar display-line-numbers-count 0) -(make-variable-buffer-local 'display-line-numbers-count) -(defvar display-line-numbers-buffer-name nil) -(make-variable-buffer-local 'display-line-numbers-buffer-name) -(defvar display-line-numbers-modified-p nil) -(make-variable-buffer-local 'display-line-numbers-modified-p) - -;;;###autoload -(defun toggle-line-numbers-display (arg) - "Display/clear line numbers in left margin of current buffer. -With prefix ARG, just number lines in current window, not all lines in -buffer." - (interactive "P") - (if displaying-line-numbers-p - (turn-off-line-numbers-display) - (turn-on-line-numbers-display arg))) - -;;;###autoload -(defun turn-on-line-numbers-display (arg) - "Display line numbers in left margin of current buffer. -With prefix ARG, just number lines in current window, not all lines in -buffer." - (interactive "P") - (or (eq (current-buffer) (window-buffer (selected-window))) - (error "Current buffer, %s, is not the selected window's buffer" - (buffer-name))) - (let ((buffer-read-only nil) - (point (point-marker)) - line-number - nlines) - (setq display-line-numbers-buffer-name buffer-file-name) - (setq display-line-numbers-modified-p (buffer-modified-p)) - (save-restriction - (widen) - (save-excursion - (setq display-line-numbers-first-line - (if arg - (window-start (selected-window)) - (point-min))) - (goto-char display-line-numbers-first-line) - (setq line-number (1+ (count-lines (point-min) (point)))) - (if arg - (move-to-window-line -1) - (goto-char (point-max))) - (beginning-of-line) - (setq nlines (count-lines display-line-numbers-first-line (point))) - (let ((max (+ line-number nlines))) - (setq display-line-numbers-format-string (cond ((< max 100) "%2d ") - ((< max 1000) "%3d ") - ((< max 10000) "%4d ") - (t "%7d ")))))) - (save-excursion - (condition-case nil - (progn - (goto-char display-line-numbers-first-line) - (setq buffer-file-name nil) ; To prevent saving with line numbers etc. - (setq displaying-line-numbers-p t) - (while (<= display-line-numbers-count nlines) - (insert-before-markers - (format display-line-numbers-format-string line-number)) - (setq line-number (1+ line-number)) - (setq display-line-numbers-count (1+ display-line-numbers-count)) - (forward-line 1)) - (when arg - (set-window-start (selected-window) display-line-numbers-first-line)) - (goto-char point) - (set-buffer-modified-p display-line-numbers-modified-p)) - (error - (progn - (goto-char display-line-numbers-first-line) - (let ((n (1+ (- (aref display-line-numbers-format-string 1) ?0)))) - (while (> display-line-numbers-count 0) - (setq display-line-numbers-count (1- display-line-numbers-count)) - (delete-char n) - (forward-line 1))) - (setq buffer-file-name display-line-numbers-buffer-name) - (set-buffer-modified-p display-line-numbers-modified-p) - (setq displaying-line-numbers-p nil)))))) - (let ((curr-line (count-lines (window-start) (point)))) - (when (> curr-line 0) (setq curr-line (1+ curr-line))) - (recenter curr-line))) - -;;;###autoload -(defun turn-off-line-numbers-display () - "Clear displayed line numbers from left margin of current buffer." - (interactive) - (unless (eq (current-buffer) (window-buffer (selected-window))) - (error "Current buffer, `%s', is not the selected window's buffer" - (buffer-name))) - (unless displaying-line-numbers-p - (error "Not displaying line numbers in buffer `%s'" (buffer-name))) - (let ((buffer-read-only nil)) - (save-excursion - (when (boundp 'display-line-numbers-buffer-name) - (setq buffer-file-name display-line-numbers-buffer-name)) - (goto-char display-line-numbers-first-line) - (let ((n (1+ (- (aref display-line-numbers-format-string 1) ?0)))) - (while (> display-line-numbers-count 0) - (setq display-line-numbers-count (1- display-line-numbers-count)) - (delete-char n) - (forward-line 1))) - (when (boundp 'display-line-numbers-modified-p) - (set-buffer-modified-p display-line-numbers-modified-p)) - (setq displaying-line-numbers-p nil)))) - - -;;;;;;;;;;;;;;;;;;;;;;; - -(provide 'line-num) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; line-num.el ends here diff --git a/.emacs.d/linum.el b/.emacs.d/linum.el deleted file mode 100644 index 00da901..0000000 --- a/.emacs.d/linum.el +++ /dev/null @@ -1,196 +0,0 @@ -;;; linum.el --- Display line numbers to the left of buffers - -;; Copyright (C) 2007 Markus Triska - -;; Author: Markus Triska -;; Keywords: convenience - -;; This file 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, or (at your option) -;; any later version. - -;; This file 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 GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;; Display line numbers for the current buffer. Copy linum.el to your -;; load-path and add to your .emacs: - -;; (require 'linum) - -;; Then toggle display of line numbers with M-x linum-mode. To enable -;; line numbering in all buffers, use M-x global-linum-mode. - -;;; Code: - -(defconst linum-version "0.9wx") - -(defvar linum-overlays nil "Overlays used in this buffer.") -(defvar linum-available nil "Overlays available for reuse.") -(defvar linum-before-numbering-hook nil - "Functions run in each buffer before line numbering starts.") - -(mapc #'make-variable-buffer-local '(linum-overlays linum-available)) - -(defgroup linum nil - "Show line numbers to the left of buffers" - :group 'convenience) - -;;;###autoload -(defcustom linum-format 'dynamic - "Format used to display line numbers. Either a format string -like \"%7d\", 'dynamic to adapt the width as needed, or a -function that is called with a line number as its argument and -should evaluate to a string to be shown on that line. See also -`linum-before-numbering-hook'." - :group 'linum - :type 'sexp) - -(defface linum - '((t :inherit shadow)) - "Face for displaying line numbers in the display margin." - :group 'linum) - -(defcustom linum-eager t - "Whether line numbers should be updated after each command. -The conservative setting `nil' might miss some buffer changes, -and you have to scroll or press C-l to update the numbers." - :group 'linum - :type 'boolean) - -(defcustom linum-delay t - "Whether updates should be delayed to give Emacs a chance for -other changes." - :group 'linum - :type 'boolean) - -;;;###autoload -(define-minor-mode linum-mode - "Toggle display of line numbers in the left marginal area." - :lighter "" ; for desktop.el - (if linum-mode - (progn - (if linum-eager - (add-hook 'post-command-hook (if linum-delay - 'linum-schedule - 'linum-update-current) nil t) - (add-hook 'after-change-functions 'linum-after-change nil t)) - (add-hook 'window-scroll-functions 'linum-after-scroll nil t) - ;; mistake in Emacs: window-size-change-functions cannot be local - (add-hook 'window-size-change-functions 'linum-after-size) - (add-hook 'change-major-mode-hook 'linum-delete-overlays nil t) - (add-hook 'window-configuration-change-hook - 'linum-after-config nil t) - (linum-update-current)) - (remove-hook 'post-command-hook 'linum-update-current t) - (remove-hook 'post-command-hook 'linum-schedule t) - (remove-hook 'window-size-change-functions 'linum-after-size) - (remove-hook 'window-scroll-functions 'linum-after-scroll t) - (remove-hook 'after-change-functions 'linum-after-change t) - (remove-hook 'window-configuration-change-hook 'linum-after-config t) - (remove-hook 'change-major-mode-hook 'linum-delete-overlays t) - (linum-delete-overlays))) - -;;;###autoload -(define-globalized-minor-mode global-linum-mode linum-mode linum-on) - -(defun linum-on () - (unless (minibufferp) - (linum-mode 1))) - -(defun linum-delete-overlays () - "Delete all overlays displaying line numbers for this buffer." - (mapc #'delete-overlay linum-overlays) - (setq linum-overlays nil) - (dolist (w (get-buffer-window-list (current-buffer) nil t)) - (set-window-margins w 0))) - -(defun linum-update-current () - "Update line numbers for the current buffer." - (linum-update (current-buffer))) - -(defun linum-update (buffer) - "Update line numbers for all windows displaying BUFFER." - (with-current-buffer buffer - (when linum-mode - (setq linum-available linum-overlays) - (setq linum-overlays nil) - (save-excursion - (mapc #'linum-update-window - (get-buffer-window-list buffer nil 'visible))) - (mapc #'delete-overlay linum-available) - (setq linum-available nil)))) - -(defun linum-update-window (win) - "Update line numbers for the portion visible in window WIN." - (goto-char (window-start win)) - (let ((line (line-number-at-pos)) - (limit (1+ (window-end win t))) - (fmt (cond ((stringp linum-format) linum-format) - ((eq linum-format 'dynamic) - (let ((w (length (number-to-string - (count-lines (point-min) (point-max)))))) - (concat "%" (number-to-string w) "d "))))) - (width 0) - visited - ov) - (run-hooks 'linum-before-numbering-hook) - ;; Create an overlay (or reuse an existing one) for each - ;; line visible in this window, if necessary. - (while (and (not (eobp)) (< (point) limit)) - (setq visited nil) - (dolist (o (overlays-in (point) (point))) - (when (eq (overlay-get o 'linum-line) line) - (unless (memq o linum-overlays) - (push o linum-overlays)) - (setq linum-available (delete o linum-available)) - (setq visited t))) - (let ((str (if fmt - (propertize (format fmt line) 'face 'linum) - (funcall linum-format line)))) - (setq width (max width (length str))) - (unless visited - (if (null linum-available) - (setq ov (make-overlay (point) (point))) - (setq ov (pop linum-available)) - (move-overlay ov (point) (point))) - (push ov linum-overlays) - (setq str (propertize " " 'display `((margin left-margin) ,str))) - (overlay-put ov 'before-string str) - (overlay-put ov 'linum-line line))) - (forward-line) - (setq line (1+ line))) - (set-window-margins win width))) - -(defun linum-after-change (beg end len) - ;; update overlays on deletions, and after newlines are inserted - (when (or (= beg end) - (= end (point-max)) - ;; TODO: use string-match-p with CVS or new release - (string-match "\n" (buffer-substring-no-properties beg end))) - (linum-update-current))) - -(defun linum-after-scroll (win start) - (linum-update (window-buffer win))) - -(defun linum-after-size (frame) - (linum-after-config)) - -(defun linum-schedule () - ;; schedule an update; the delay gives Emacs a chance for display changes - (run-with-idle-timer 0 nil #'linum-update-current)) - -(defun linum-after-config () - (walk-windows (lambda (w) (linum-update (window-buffer))) nil 'visible)) - -(provide 'linum) -;;; linum.el ends here