emacs 使い方メモ




[code lang=text] (require 'package)

;; MELPAを追加 (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))

;; Marmaladeを追加 (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))

;; 初期化 (package-initialize)

(setq inhibit-startup-message t)

;;; .~ とかのバックアップファイルを作らない (setq make-backup-files nil) ;;; .# とかのバックアップファイルを作らない (setq auto-save-default nil) (electric-indent-mode -1) (add-hook 'before-save-hook 'delete-trailing-whitespace)

(setq-default indent-tabs-mode nil) ; インデントはタブではなくスペースを使用 (setq-default show-trailing-whitespace t) ; 行末の空白をハイライト (add-hook 'font-lock-mode-hook ; タブをハイライト (lambda () (font-lock-add-keywords nil '*1

;; Emulate kill-line' in helm minibuffer (setq helm-delete-minibuffer-contents-from-point t) (defadvice helm-delete-minibuffer-contents (before helm-emulate-kill-line activate) "Emulatekill-line' in helm minibuffer" (kill-new (buffer-substring (point) (field-end))))

(defadvice helm-ff-kill-or-find-buffer-fname (around execute-only-if-exist activate) "Execute command only if CANDIDATE exists" (when (file-exists-p candidate) ad-do-it))

(defadvice helm-ff-transform-fname-for-completion (around my-transform activate) "Transform the pattern to reflect my intention" (let *2 (input-pattern (file-name-nondirectory pattern)) (dirname (file-name-directory pattern))) (setq input-pattern (replace-regexp-in-string "\." "\\." input-pattern)) (setq ad-return-value (concat dirname (if (string-match "^\^" input-pattern) ;; '^' is a pattern for basename ;; and not required because the directory name is prepended (substring input-pattern 1) (concat "." input-pattern)))))))



M-x package-list-packages installするものはiで選んでxでinstallする。

[code lang=text] async 20150412.... installed Asynchronous processing in Emacs bind-key 20150321.213 installed A simple way to manage personal keybindings helm 20150428.... installed Helm is an Emacs incremental and narrowing framework helm-firefox 20150307.121 installed Firefox bookmarks helm-git 20120630.... installed Helm extension for Git. helm-git-files 20141212.517 installed helm for git files helm-git-grep 20140222.... installed helm for git grep, an incremental git-grep(1) [/code]


C-x C-fでファイルを選べるようになった。

*1:"\t" 0 'trailing-whitespace prepend)))))

(when (require 'helm-config nil t) (helm-mode 1)

(define-key global-map (kbd "M-x") 'helm-M-x) (define-key global-map (kbd "C-x C-f") 'helm-find-files) (define-key global-map (kbd "C-x C-r") 'helm-recentf) (define-key global-map (kbd "M-y") 'helm-show-kill-ring) (define-key global-map (kbd "C-c i") 'helm-imenu) (define-key global-map (kbd "C-x b") 'helm-buffers-list)

(define-key helm-map (kbd "C-h") 'delete-backward-char) (define-key helm-find-files-map (kbd "C-h") 'delete-backward-char) (define-key helm-find-files-map (kbd "TAB") 'helm-execute-persistent-action) (define-key helm-read-file-map (kbd "TAB") 'helm-execute-persistent-action)

;; Disable helm in some functions (add-to-list 'helm-completing-read-handlers-alist '(find-alternate-file . nil

*2:pattern (ad-get-arg 0