LoginSignup
0
0

More than 5 years have passed since last update.

emacs

Last updated at Posted at 2014-09-17

使用中バージョン

packagesが使いたかった

  • Emacs 24.4についても追記

.emacs は catatsuyさんのGitからいただいたものをベースにゴッと使っています。
catatsuy/dot.emacs.d · GitHub https://github.com/catatsuy/dot.emacs.d

バージョン24.4にした。

※ Alfredに認識させる
linkapps でショートカットを更新した後、alfredのアプリ候補にヒットさせるためにサーチスコープにパスを追加する。

Alfred右肩のギアから設定ダイアログ表示 → BASIC - Default Results
Serch Scope: [+]
ファイル選択ダイアログで [Shift]+[Command]+[G]でパス入力
/usr/local/Cellar/
[Open]でCellar配下の xxxx.app が認識される

$ brew install --cocoa --d-bus --gnutls --librsvg --imagemagick --mailutils --glib --srgb --with-gnutls --japanese -v emacs
$ brew linkapps

$ # brew install --gnutls --librsvg --imagemagick --mailutils --glib -v emacs
$ # これじゃだめだった
  • ng

私家版Homebrew:Ng-utf8 - 冒険するコンピューティング
http://linux.matchy.net/archives/344
ngは毎回ビルドしている

.ng作成
; ~/.ng
;
; for more detail, please read Ng.doc
;

; 'next-line' doesn't insert newline at the end of buffer.
(next-line-add-newlines nil)

; exchange C-h with DEL.
(bsmap-mode)

; don't make backup files.
(make-backup-files nil)

; blink matching parens
(global-set-key ")" 'blink-matching-paren-hack)
(global-set-key "}" 'blink-matching-paren-hack)
(global-set-key "]" 'blink-matching-paren-hack)

; regexp search by typing ESC C-s/C-r
(global-set-key "\^[\^s" 're-search-forward)
(global-set-key "\^[\^r" 're-search-backward)

dot.emacsについて

.emacs は catatsuyさんのGitからいただいたものをベースにゴッと使っています。
catatsuy/dot.emacs.d · GitHub https://github.com/catatsuy/dot.emacs.d

packages

M-x list-packages で好きなパッケージを入れる

  1. org-mode
  2. howm-mode

トリム、タブ<->スペース置換

ys_trim-whitespaces.el
;;; -*- Mode: Emacs-Lisp ; Coding: utf-8 -*-

;; 行末にある余分な whitespace を削除したい
;;
;; 以下を ~/.emacs に書いておき、M-x ys:trim-whitespaces すると良いです。
;; これにより、buffer 末尾の余分な whitespace や改行も削除されます。ま
;; た、必要に応じて whitespace を tab に変換することも出来ます。
;; http://www.fan.gr.jp/~ring/Meadow/meadow.html
(defun ys:trim-whitespaces ()
  "Trim excess whitespaces."
  (interactive "*")
  (let ((key (read-char "Convert spaces?: (t)abify (u)ntabify (n)o"))
        (reg (and transient-mark-mode mark-active)))
    (save-excursion
      (save-restriction
        (if reg
            (narrow-to-region (region-beginning) (region-end)))
        (goto-char (point-min))
        (while (re-search-forward "[ \t]+$" nil t)
          (replace-match "" nil nil))
        (if reg nil
          (goto-char (point-max))
          (delete-blank-lines))
        (cond
         ((= key ?t)
          (tabify (point-min) (point-max)))
         ((= key ?u)
          (untabify (point-min) (point-max)))))))
  (deactivate-mark))

~/.emacs.d/conf/init-scratch.el

~/.emacs.d/cont/init-scratch.el
;; -*- Mode: Emacs-Lisp ; Coding: utf-8 -*-
;; ============================================================
;; *scratch*バッファ
;; ============================================================
;;  29.4.2 *scratch*バッファを kill できないように (2003/04/09)
;; "http://www.bookshelf.jp/cgi-bin/goto.cgi?file=meadow&node=delete%20scratch"
;; ネタ元: Petit emacs lisp tips http://www-tsujii.is.s.u-tokyo.ac.jp/~yoshinag/tips/elisp_tips.html
;; C-x C-s  保存時には*scratch*バッファを作成
;; C-x k    kill すると,*scratch*バッファの内容をすべて消してくれます.
(defun my-make-scratch (&optional arg)
  (interactive)
  (progn
    ;; "*scratch*" を作成して buffer-list に放り込む
    (set-buffer (get-buffer-create "*scratch*"))
    (funcall initial-major-mode)
    (erase-buffer)
    (when (and initial-scratch-message (not inhibit-startup-message))
      (insert initial-scratch-message))
    (or arg (progn (setq arg 0)
                   (switch-to-buffer "*scratch*")))
    (cond ((= arg 0) (message "*scratch* is cleared up."))
          ((= arg 1) (message "another *scratch* is created")))))

(defun my-buffer-name-list ()
  (mapcar (function buffer-name) (buffer-list)))

(add-hook 'kill-buffer-query-functions
    ;; *scratch* バッファで kill-buffer したら内容を消去するだけにする
          (function (lambda ()
                      (if (string= "*scratch*" (buffer-name))
                          (progn (my-make-scratch 0) nil)
                        t))))

(add-hook 'after-save-hook
;; *scratch* バッファの内容を保存したら *scratch* バッファを新しく作る
          (function (lambda ()
                      (unless (member "*scratch*" (my-buffer-name-list))
                        (my-make-scratch 1)))))

;; ------------------------------------------------------------
;; 29.6 scratch バッファの内容を保存 (2003/10/27)
(defun save-scratch-data ()
  (let ((str (progn
               (set-buffer (get-buffer "*scratch*"))
               (buffer-substring-no-properties
                (point-min) (point-max))))
        (file "~/.scratch"))
    (if (get-file-buffer (expand-file-name file))
        (setq buf (get-file-buffer (expand-file-name file)))
      (setq buf (find-file-noselect file)))
    (set-buffer buf)
    (erase-buffer)
    (insert str)
    (save-buffer)))

(defadvice save-buffers-kill-emacs
  (before save-scratch-buffer activate)
  (save-scratch-data))

(defun read-scratch-data ()
  (let ((file "~/.scratch"))
    (when (file-exists-p file)
      (set-buffer (get-buffer "*scratch*"))
      (erase-buffer)
      (insert-file-contents file))
    ))

(read-scratch-data)

;;;;
;;;; end of file
;;;;

~/.emacs.d/conf/init-global.el

yes no をエンターでyesにしてる

~/.emacs.d/conf/init-global.el
;; -*- Mode: Emacs-Lisp ; Coding: utf-8 -*-
;; 問い合わせを簡略化
;; 問い合わせをさらに簡略化
;; http://d.hatena.ne.jp/goinger/20070723/1185214263
;; Treat 'y' or <CR> as yes, 'n' as no.
(fset 'yes-or-no-p 'y-or-n-p)
(define-key query-replace-map [return] 'act)
(define-key query-replace-map [?\C-m] 'act)

;; リージョンをC-hで削除
(delete-selection-mode t)

;;; 最終行に必ず一行挿入する
(setq require-final-newline t)

;;; 一行が 120 字以上になった時には自動改行する
;;(setq fill-column 120)
;;(setq-default fill-column 90)
;;(setq-default auto-fill-mode t)

;;; ---------------------------------------------------
;; 大文字小文字チェックを無効にする
;;; ---------------------------------------------------
(setq completion-ignore-case t)
;; ファイル名検索の大文字小文字チェックを無効にする
(setq read-file-name-completion-ignore-case t)
;; 検索時に大文字と小文字の区別をしない nil:する t:しない
(setq case-fold-search t)
;; 置換時に大文字と小文字の区別をしない nil:する t:しない
(setq case-replace nil)

;; 33.10 連続する同じ行を 1 行に― uniq (2003/10/08)
;; URL="http://www.bookshelf.jp/cgi-bin/goto.cgi?file=meadow&node=uniq"
;; http://www.astrogoth.com/~reeses/software/uniq.el
;; 重複行の作成
;; リージョンで選択して,M-x uniq-region
;; M-x uniq-remove-dup-lines
(load "uniq")


(require 'highlight-current-line)
(highlight-current-line-on t)
;; To customize the background color
(set-face-background 'highlight-current-line-face "#281a14")        ;; 鉄黒
;; (set-face-background 'highlight-current-line-face "#333631")        ;; 黒緑
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0