Emacs: Zsh-style completion.

Emacs: a lot of fixes.
master
Pierre Neidhardt 2013-01-10 17:33:33 +01:00
parent 6609385cce
commit d401566687
4 changed files with 59 additions and 101 deletions

View File

@ -95,7 +95,7 @@ frames with exactly two windows."
(next-line arg))
;; Binding.
(define-key my-keys-minor-mode-map (kbd "C-c C-d") 'duplicate-line)
(global-set-key (kbd "C-c C-d") 'duplicate-line)
;;==============================================================================
;; Comment DWIM -- toggle comment line

View File

@ -2,43 +2,14 @@
;; MAIN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;==============================================================================
;; Bindings
;;==============================================================================
;; Make questions less annoying
(defalias 'yes-or-no-p 'y-or-n-p)
;; We use this minor mode to store custom bindings and use them where we want.
(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)
(my-keys-minor-mode 1)
(defun my-minibuffer-setup-hook ()
(my-keys-minor-mode 0))
(add-hook 'minibuffer-setup-hook 'my-minibuffer-setup-hook)
;;==============================================================================
;; Toggle line numbers.
(global-set-key (kbd "C-<f5>") 'linum-mode)
;; Copy/Paste to/from clipboard.
;; (define-key my-keys-minor-mode-map (kbd "M-p") (kbd "C-u M-! xclip <SPC> -o"))
;; (define-key my-keys-minor-mode-map (kbd "C-<f6>") (kbd "M-| xsel <SPC> -p <SPC> -i"))
(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"))
;; Window resize
;; TODO: Use more { and } to continue.
(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)
;; Print column number
(column-number-mode 1)
;; Kill whole line
(setq kill-whole-line t)
;; Modern scrolling
(global-set-key [next]
@ -51,33 +22,17 @@
(condition-case nil (scroll-down)
(beginning-of-buffer (goto-char (point-min))))))
;(global-set-key (kbd "C-<tab>") 'dabbrev-expand)
;(define-key minibuffer-local-map (kbd "C-<tab>") 'dabbrev-expand)
;;==============================================================================
;; General
;;==============================================================================
;; Make questions less annoying
(defalias 'yes-or-no-p 'y-or-n-p)
;; Print column number
(column-number-mode 1)
;; Kill whole line
(setq kill-whole-line t)
;; 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. Bug?
(global-linum-mode 1) ;; FIXME: This may generate warnings with emacsclient. Bug?
(global-set-key (kbd "C-<f5>") 'linum-mode) ;; Toggle line numbers.
;; Indentation
;(setq standard-indent 4) ;; Set standard indent to 2 rather that 4
(setq-default tab-width 4) ; Tab width set to 2 spaces
(setq-default indent-tabs-mode nil) ; Indentation cannot insert tabs
(setq c-default-style "linux" c-basic-offset 4) ;; Identation style
;(setq standard-indent 4)
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil) ;; Indentation cannot insert tabs
;; Line by line scrolling
(setq scroll-step 1)
@ -85,9 +40,6 @@
;; Highlight selections -- not activated by default on old emacs.
(transient-mark-mode 1)
;; Mousewheel scrolling -- Does not work?
;(mouse-wheel-mode t)
;; No trailing whitespace
;; WARNING: this can break some configuration files needing whitespaces at the
;; end.
@ -97,36 +49,26 @@
(setq default-abbrev-mode t)
;; Remember last cursor position
(setq save-place-file "~/.emacs.d/.saveplace")
(setq-default save-place t)
(require 'saveplace)
(setq save-place-file "~/.emacs.d/saveplace")
(setq-default save-place t)
;; Disable autosave features
(setq auto-save-default nil)
;; Place Backup Files in Specific Directory
(setq backup-inhibited t) ;; Disable backup files.
;(setq make-backup-files t) ;; Enable backup files.
;(setq version-control t) ;; Enable versioning with default values (keep five last versions, I think!)
;(setq backup-directory-alist (quote ((".*" . "~/.emacs.d/.backups/")))) ;; Save all backup file in this directory.
;; (setq backup-inhibited t) ;; Disable backup files.
;; (setq make-backup-files t) ;; Enable backup files.
;; (setq version-control t) ;; Enable numbered versioning.
(setq backup-directory-alist (quote ((".*" . "~/.emacs.d/backups/")))) ;; Save all backup file in this directory.
;; Remove menu-bar
(menu-bar-mode -1)
;; Set Fill Column
(setq-default fill-column 80)
;; (setq auto-fill-mode 1) ;; Does not work ?
;; (auto-fill-mode 1) ;; Will not work because it gets overridden by major modes.
(add-hook 'text-mode-hook 'turn-on-auto-fill)
;; (add-hook 'c-mode-common-hook
;; (lambda ()
;; (auto-fill-mode 1)
;; (set (make-local-variable 'fill-nobreak-predicate)
;; (lambda ()
;; (not (eq (get-text-property (point) 'face)
;; 'font-lock-comment-face ))
;; ))
;; ))
;; Man-mode
(setenv "MANWIDTH" "80")
@ -156,3 +98,15 @@ browse-url-browser-function 'browse-url-generic)
;; it to 0 to deactivate.
(setq show-paren-delay 0)
;; 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 "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"))

View File

@ -293,6 +293,10 @@ your document embeds raster graphics."
;; C-mode
;;==============================================================================
(require 'compile)
;; Identation style
(setq c-default-style "linux" c-basic-offset 4)
(add-hook 'c-mode-hook
(lambda ()
(unless (file-exists-p "Makefile")
@ -310,7 +314,7 @@ your document embeds raster graphics."
file))))
(local-set-key (kbd "C-c C-f") 'compile)
;; (define-key my-keys-minor-mode-map (kbd "<f12>") 'next-error)
;; (global-set-key (kbd "<f12>") 'next-error)
(local-set-key (kbd "M-a") 'beginning-of-defun)
(local-set-key (kbd "M-e") 'end-of-defun)
@ -346,22 +350,22 @@ your document embeds raster graphics."
;; Flymake has a bug that prevents menu from spawning in a console. We redefine
;; the function to spawn the error message in the mini-buffer.
(defun flymake-display-err-message-for-current-line ()
"Display a message with errors/warnings for current line if it
has errors and/or warnings."
(interactive)
(let* ((line-no (flymake-current-line-no))
(line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
(menu-data (flymake-make-err-menu-data line-no line-err-info-list)))
(if menu-data
(let ((messages))
(push (concat (car menu-data) ":") messages)
(dolist (error-or-warning (cadr menu-data))
(push (car error-or-warning) messages))
(message "%s" (mapconcat #'identity (reverse messages) "\n"))))))
;; (defun flymake-display-err-message-for-current-line ()
;; "Display a message with errors/warnings for current line if it
;; has errors and/or warnings."
;; (interactive)
;; (let* ((line-no (flymake-current-line-no))
;; (line-err-info-list (nth 0 (flymake-find-err-info flymake-err-info line-no)))
;; (menu-data (flymake-make-err-menu-data line-no line-err-info-list)))
;; (if menu-data
;; (let ((messages))
;; (push (concat (car menu-data) ":") messages)
;; (dolist (error-or-warning (cadr menu-data))
;; (push (car error-or-warning) messages))
;; (message "%s" (mapconcat #'identity (reverse messages) "\n"))))))
(define-key my-keys-minor-mode-map (kbd "<f10>")
'flymake-display-err-message-for-current-line)
;; (global-set-key (kbd "<f10>")
;; 'flymake-display-err-message-for-current-line)
;;==============================================================================
;; GUD
@ -370,7 +374,6 @@ has errors and/or warnings."
;; Set GDB to display many windows by default.
(setq gdb-many-windows t)
;;==============================================================================
;; Ediff
;;==============================================================================

View File

@ -103,16 +103,17 @@
(require 'zlc)
(let ((map minibuffer-local-map))
;;; like menu select
(define-key map (kbd "<down>") 'zlc-select-next-vertical)
(define-key map (kbd "<up>") 'zlc-select-previous-vertical)
(define-key map (kbd "<right>") 'zlc-select-next)
(define-key map (kbd "<left>") 'zlc-select-previous)
;; Like Zsh menu select. Should not use arrows directly because it overrides
;; default controls like previous entry, or previous/next char.
(define-key map (kbd "C-<down>") 'zlc-select-next-vertical)
(define-key map (kbd "C-<up>") 'zlc-select-previous-vertical)
(define-key map (kbd "C-<right>") 'zlc-select-next)
(define-key map (kbd "C-<left>") 'zlc-select-previous)
;;; reset selection
;;; Reset selection.
(define-key map (kbd "C-c") 'zlc-reset)
)
(setq zlc-select-completion-immediately t)
;; (setq zlc-select-completion-immediately t)
;; To change style, M-x customize-face and input zlc-selected-completion-face.