95 lines
3.0 KiB
EmacsLisp
95 lines
3.0 KiB
EmacsLisp
;;;; Editing improvements
|
|
|
|
;; fix Emacs' definition of a sentence
|
|
(setq sentence-end-double-space nil)
|
|
|
|
;; the utter basics
|
|
(global-set-key (kbd "C-h") 'backward-delete-char)
|
|
(define-key isearch-mode-map (kbd "C-h") 'isearch-delete-char)
|
|
(global-set-key (kbd "C-w") 'backward-kill-word)
|
|
(defun cp-kill-line-0 ()
|
|
(interactive)
|
|
(kill-line 0))
|
|
(global-set-key (kbd "C-u") 'cp-kill-line-0)
|
|
|
|
(global-unset-key (kbd "C-x C-r"))
|
|
(cp-set-keys
|
|
:bindings
|
|
;; whole-line-or-region
|
|
`((,(kbd "C-y") whole-line-or-region-yank)
|
|
(,(kbd "M-w") whole-line-or-region-kill-ring-save)
|
|
(,(kbd "C-x C-r C-i") string-insert-rectangle)
|
|
(,(kbd "C-x C-r C-r") replace-rectangle)
|
|
(,(kbd "C-x C-r C-k") kill-rectangle)
|
|
|
|
;; A better solution would be to hack kill-line/kill-visual-line to
|
|
;; kill the region if a region is active. The flexibility of those
|
|
;; functions is very desirable - you can delete from point to line
|
|
;; end, clear a line to enter some other text on it (C-a C-k/"a k"),
|
|
;; or delete one or more whole lines (C-1 C-k/"1 k" or C-<num>
|
|
;; C-k/"<num> k").
|
|
(,(kbd "C-S-k") whole-line-or-region-kill-region)
|
|
|
|
(,(kbd "C-,") backward-paragraph)
|
|
(,(kbd "C-.") forward-paragraph)
|
|
(,(kbd "C-<") beginning-of-buffer)
|
|
(,(kbd "C->") end-of-buffer)
|
|
(,(kbd "C-;") delete-horizontal-space)))
|
|
|
|
;; open-line should always move to the beginning of the current line
|
|
;; first, so one can run it anywhere. I also want it to indent it to
|
|
;; the next or the previous line...
|
|
(defadvice open-line
|
|
(before open-line-bol activate) (beginning-of-visual-line))
|
|
(defadvice open-line
|
|
(after open-line-indent activate) (indent-for-tab-command))
|
|
|
|
(global-set-key (kbd "C-o") 'open-line)
|
|
(defun cp-open-line ()
|
|
(interactive)
|
|
(progn
|
|
(end-of-visual-line)
|
|
(newline)))
|
|
|
|
;; I wish you could press e.g. S-o in god-mode to get C-S-o.
|
|
;; 10/10 would make life better.
|
|
(global-set-key (kbd "C-S-o") 'cp-open-line)
|
|
|
|
(setq dired-bind-jump nil)
|
|
(global-set-key (kbd "C-x C-j") 'join-line)
|
|
|
|
;; C-z (suspend-frame) is utterly useless and disruptive - good place to put universal-argument
|
|
(global-unset-key (kbd "C-z"))
|
|
(global-set-key (kbd "C-z") 'universal-argument)
|
|
|
|
;; (defun cp-kill-line (&optional arg)
|
|
;; (interactive)
|
|
;; (if arg
|
|
;; (if mark-active
|
|
;; (kill-region arg)
|
|
;; (kill-line arg))
|
|
;; (if mark-active
|
|
;; (kill-region)
|
|
;; (kill-line))))
|
|
;; (global-set-key (kbd "C-k") 'cp-kill-line)
|
|
;; Chris Done (god-mode) recommends this, but Emacs' repeat command is almost useless...
|
|
;; (global-set-key (kbd "C-.") 'repeat)
|
|
|
|
;;;; I like the transpose commands
|
|
(global-unset-key (kbd "C-t"))
|
|
(cp-set-keys
|
|
:bindings
|
|
`((,(kbd "C-t C-c") transpose-chars)
|
|
(,(kbd "C-t C-w") transpose-words)
|
|
(,(kbd "C-t C-l") transpose-lines)
|
|
(,(kbd "C-t C-s") transpose-sentences)
|
|
(,(kbd "C-t C-e") transpose-sexps)
|
|
(,(kbd "C-t C-p") transpose-paragraphs)))
|
|
|
|
(global-set-key (kbd "C-M-h") 'er/expand-region)
|
|
|
|
(require 'dot-mode)
|
|
(dot-mode 1)
|
|
(define-key dot-mode-map (kbd "C-.") nil)
|
|
(define-key dot-mode-map (kbd "M-.") 'dot-mode-execute)
|