Emacs: AWK snippets.

Emacs: my-keys minor more is back and fixed.
master
Pierre Neidhardt 2013-02-04 21:32:40 +01:00
parent 1240c58803
commit 3655967420
14 changed files with 93 additions and 20 deletions

4
.emacs
View File

@ -14,5 +14,9 @@
(load "~/.emacs.d/plugins" nil t)
(load "~/.emacs.d/theme" nil t)
;; We need to put it at the end to make sure it doesn't get itself overriden by
;; other minor modes.
(my-keys-minor-mode 1)
;; End of file

View File

@ -54,7 +54,7 @@ frames with exactly two windows."
(select-window first-win)
(if this-win-2nd (other-window 1))))))
(global-set-key [(control c) (|)] 'my-toggle-window-split)
(define-key my-keys-minor-mode-map [(control c) (|)] 'my-toggle-window-split)
;;==============================================================================
;; Duplicate line
@ -95,7 +95,7 @@ frames with exactly two windows."
(next-line arg))
;; Binding.
(global-set-key (kbd "C-c C-d") 'duplicate-line)
(define-key my-keys-minor-mode-map (kbd "C-c C-d") 'duplicate-line)
;;==============================================================================
;; Comment DWIM -- toggle comment line
@ -117,5 +117,4 @@ the line."
(comment-dwim arg)))
;; Binding.
;; TODO: global key ?
(global-set-key "\M-;" 'comment-dwim-line)
(define-key my-keys-minor-mode-map "\M-;" 'comment-dwim-line)

View File

@ -2,6 +2,18 @@
;; MAIN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; We use a minor mode to override global keys.To assign
;; global keys, you need to write
;; (define-key my-keys-minor-mode-map (kbd "C-i") 'some-function)
(defvar my-keys-minor-mode-map (make-keymap) "my-keys-minor-mode keymap.")
(define-minor-mode my-keys-minor-mode
"A minor mode so that my key settings override annoying major modes."
t " my-keys" 'my-keys-minor-mode-map)
(add-hook 'minibuffer-setup-hook (lambda () (my-keys-minor-mode 0) ) )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Make questions less annoying
(defalias 'yes-or-no-p 'y-or-n-p)
@ -12,22 +24,22 @@
(setq kill-whole-line t)
;; Modern scrolling
(global-set-key [next]
(lambda () (interactive)
(condition-case nil (scroll-up)
(end-of-buffer (goto-char (point-max))))))
(define-key my-keys-minor-mode-map [next]
(lambda () (interactive)
(condition-case nil (scroll-up)
(end-of-buffer (goto-char (point-max))))))
(global-set-key [prior]
(lambda () (interactive)
(condition-case nil (scroll-down)
(beginning-of-buffer (goto-char (point-min))))))
(define-key my-keys-minor-mode-map [prior]
(lambda () (interactive)
(condition-case nil (scroll-down)
(beginning-of-buffer (goto-char (point-min))))))
;; Line numbers
(autoload 'linum-mode "linum" "toggle line numbers on/off" t)
;; (setq linum-format "%-4d ")
(setq linum-format "%d ")
(global-linum-mode 1) ;; FIXME: This may generate warnings with emacsclient. Bug?
(global-set-key (kbd "C-<f5>") 'linum-mode) ;; Toggle line numbers.
(define-key my-keys-minor-mode-map (kbd "C-<f5>") 'linum-mode) ;; Toggle line numbers.
;; Indentation
;(setq standard-indent 4)
@ -100,16 +112,16 @@ browse-url-browser-function 'browse-url-generic)
;; Window resize
;; TODO: Use more { and } to continue.
(global-set-key (kbd "C-x {") (lambda () (interactive) (shrink-window-horizontally 5)))
(global-set-key (kbd "C-x }") (lambda () (interactive) (enlarge-window-horizontally 5)))
(define-key my-keys-minor-mode-map (kbd "C-x {") (lambda () (interactive) (shrink-window-horizontally 5)))
(define-key my-keys-minor-mode-map (kbd "C-x }") (lambda () (interactive) (enlarge-window-horizontally 5)))
;; (define-key my-keys-minor-mode-map (kbd "S-C-<down>") 'shrink-window)
;; (define-key my-keys-minor-mode-map (kbd "S-C-<up>") 'enlarge-window)
;; Copy/Paste to/from clipboard.
;; FIXME: copying does not work.
(global-set-key (kbd "C-<f6>") (kbd "M-| xclip"))
(global-set-key (kbd "C-<f7>") (kbd "C-u M-! xclip <SPC> -o"))
(global-set-key (kbd "C-<f8>") (kbd "C-u M-! xclip <SPC> -o <SPC> -selection <SPC> clipboard"))
(define-key my-keys-minor-mode-map (kbd "C-<f6>") (kbd "M-| xclip"))
(define-key my-keys-minor-mode-map (kbd "C-<f7>") (kbd "C-u M-! xclip <SPC> -o"))
(define-key my-keys-minor-mode-map (kbd "C-<f8>") (kbd "C-u M-! xclip <SPC> -o <SPC> -selection <SPC> clipboard"))
;; query-replace-regex fix on terminals.
(global-set-key (kbd "C-M-y") 'query-replace-regexp)
(define-key my-keys-minor-mode-map (kbd "C-M-y") 'query-replace-regexp)

View File

@ -365,7 +365,6 @@ properly escaped with double-quotes in case it has spaces."
)
(setq compilation-scroll-output t)
(local-set-key "\C-c\C-c" 'python-my-compile)
(local-set-key "\C-c\C-d" 'duplicate-line)
)
)

View File

@ -0,0 +1 @@
text-mode

View File

@ -0,0 +1,7 @@
# name: do { ... } while (...)
# key: do
# --
do
{
$0
} while (${1:condition})

View File

@ -0,0 +1,7 @@
# name: else { ... }
# key: else
# --
else
{
$0
}

View File

@ -0,0 +1,7 @@
# name: for (...; ...; ...) { ... }
# key: for
# --
for (${1:i = 0}; ${2:i < NF}; ${3:i++})
{
$0
}

View File

@ -0,0 +1,7 @@
# name: for ( var in array ) statement
# key: forin
# --
for ( ${1:var} in ${2:array})
{
$0
}

View File

@ -0,0 +1,6 @@
#name : type fun (args) { ... }
# --
${1:name} (${2:args})
{
$0
}

View File

@ -0,0 +1,4 @@
# -*- mode: snippet -*-
# key: gsub
# --
gsub ("${1:regex}" , "${2:subs}"${3:, s})

View File

@ -0,0 +1,7 @@
# name: if (...) { ... }
# key: if
# --
if (${1:condition})
{
$0
}

View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: printf
# contributor: joaotavora
# key: printf
# --
printf ("${1:%s}\\n"${1:$(if (string-match "%" text) "," "\)")}$2${1:$(if (string-match "%" text) "\)" "")}

View File

@ -0,0 +1,7 @@
# name : while (...) { ... }
# key: while
# --
while (${1:condition})
{
$0
}