update
[poppyer.git] / init / 02-keybind-init.el
blobd1fe7752d28605f4c8b1451f6b380fdfedf75514
2 (global-set-key "\C-x\C-r" 'revert-buffer)
3 ;;(global-auto-revert-mode t)
6 (global-set-key (kbd "C-x SPC") (lambda() ;; toggle-mark
7 (interactive)
8 (if mark-active
9 (deactivate-mark)
10 (cons
11 (exchange-point-and-mark)
12 (exchange-point-and-mark)
20 (global-set-key "\C-x\C-j" 'delete-indentation)
22 ;;CRM bufer list;; ibuffer is another choice
23 (if (string-match "XEmacs" (emacs-version))
24 (global-set-key "\C-x\C-b" 'electric-buffer-list)
25 (global-set-key "\C-x\C-b" 'bs-show)
28 (defun kill-other-buffer ()
29 (interactive)
30 (if (one-window-p t)
31 (message "No other window")
32 (other-window 1)
33 (kill-this-buffer)
34 (other-window 1)
37 (global-set-key "\C-x\M-k" 'kill-other-buffer)
40 (defun switch-to-previous-buffer ()
41 (interactive)
42 (switch-to-buffer (other-buffer)))
43 (global-set-key "\M-o" 'switch-to-previous-buffer)
47 ;;(global-set-key "\M-g" 'goto-line) ;; use \M-g \M-g by default
48 (global-set-key "\M-gf" 'facemenu-set-foreground)
49 (global-set-key "\M-gB" 'facemenu-set-background)
50 (global-set-key "\M-gb" 'facemenu-set-bold)
51 (global-set-key "\M-g\M-c" 'calculator)
52 (global-set-key "\M-#" 'calc-dispatch)
57 (defun wy-go-to-char (n char)
58 "Move forward to Nth occurence of CHAR.
59 Typing `wy-go-to-char-key' again will move forward to the next Nth occurence of CHAR."
60 (interactive "p\ncGo to char: ")
61 (search-forward (string char) nil nil n)
62 (while (char-equal (read-char)
63 char)
64 (search-forward (string char) nil nil n))
65 (setq unread-command-events (list last-input-event)))
67 (defun wy-backward-to-char (n char)
68 "Move backward to Nth occurence of CHAR.
69 Typing `wy-backward-to-char-key' again will move backward to the next Nth occurence of CHAR."
70 (interactive "p\ncBackward to char: ")
71 (backward-char)
72 (search-backward (string char) nil nil n)
73 (forward-char)
74 (while (char-equal (read-char)
75 char)
76 (search-backward (string char) nil nil (+ n 1))
77 (forward-char))
78 (setq unread-command-events (list last-input-event)))
80 (define-key global-map (kbd "C-c f") 'wy-go-to-char)
81 (define-key global-map (kbd "C-c b") 'wy-backward-to-char)
85 ;; ;;;;;;;;;;;;;;;;;;;;;; simple Bookmarking - history stack ;;;;;;;;;;;;;;;
86 ;; (global-set-key [f11] 'point-stack-push)
87 ;; (global-set-key [f10] 'point-stack-pop)
88 ;;(defvar point-stack nil)
89 ;; (defun point-stack-push ()
90 ;; "Push current location and buffer info onto stack."
91 ;; (interactive)
92 ;; (message "Location marked.")
93 ;; (setq point-stack (cons (list (current-buffer) (point)) point-stack)))
94 ;; (defun point-stack-pop ()
95 ;; "Pop a location off the stack and move to buffer"
96 ;; (interactive)
97 ;; (if (null point-stack)
98 ;; (message "Stack is empty.")
99 ;; (switch-to-buffer (caar point-stack))
100 ;; (goto-char (cadar point-stack))
101 ;; (setq point-stack (cdr point-stack))))
102 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
103 (defun mark-and-jump (&optional arg)
104 "remember current point and jump to previous"
105 (interactive "P")
106 (let ((tmp (point-marker)))
107 (when (null arg)
108 (jump-to-register ?j))
109 (set-register ?j tmp))
111 (global-set-key [f11] 'mark-and-jump)
112 (global-set-key [M-f11] '(lambda()
113 (interactive)
114 (mark-and-jump -1)
120 ;;;;;;;;;;;;;;;;;;;;;;;;;;history;;;;;;;;;;;;;;;;;;;;;;;;;;;;
121 (defun previous-history-matching-element (n)
122 (interactive "p")
123 (unless (memq last-command '(previous-history-matching-element
124 next-history-matching-element))
125 (setq minibuffer-text-before-history (minibuffer-contents)))
126 (previous-matching-history-element
127 (concat "^" (regexp-quote minibuffer-text-before-history)) n))
128 (defun next-history-matching-element (n)
129 (interactive "p")
130 (previous-history-matching-element (- n)))
131 (mapc (lambda (map)
132 (define-key map (kbd "C-p") 'previous-history-matching-element)
133 (define-key map (kbd "C-n") 'next-history-matching-element))
134 (list minibuffer-local-completion-map
135 minibuffer-local-map
136 minibuffer-local-must-match-map
137 minibuffer-local-ns-map))
142 ;;(set-default-font "-misc-fixed-medium-*-normal--15-*")
143 ;;(add-to-list 'default-frame-alist '(font . "9x15"))
144 (global-set-key (kbd "s-f") 'new-frame)