Top/Editor/emacs

目次

編集関連

矩形選択

設定関連

(setq frame-title-format (format "emacs@%s : %%f" (system-name)))	; タイトルバーの表示書式にファイル名を入れる

文字色の変更

terinal 上で動作させる場合

どの変数で色定義されているかを調べる

  1. 対象となる文字列にカーソルを合わせた上で、以下を実行する:
    M-x: describe-face
    すると、ミニバッファに以下のように表示される:
    Describe face (default `cscope-file-face'): 
  2. ここで決定(return キーを押す)と、以下のように表示される:
    Face: cscope-file-face (sample) (customize this face)
    
    Documentation:
    Face used to highlight file name in the *cscope* buffer.
    
    Defined in `xcscope.el'.
    
               Family: unspecified
              Foundry: unspecified
                Width: unspecified
               Height: unspecified
               Weight: unspecified
                Slant: unspecified
           Foreground: yellow
    DistantForeground: unspecified
           Background: unspecified
            Underline: unspecified
             Overline: unspecified
       Strike-through: unspecified
                  Box: unspecified
              Inverse: unspecified
              Stipple: unspecified
                 Font: unspecified
              Fontset: unspecified
              Inherit: unspecified

色変更の定義

  1. 上記を元に、以下のように設定してやれば、色を変えることが出来る
    (set-face-foreground 'cscope-file-face "#d54e53")  ; yellow → (RGB)=(0xd5,0x4e,0x53)

色設定

{menu|tool}-barを消す

(tool-bar-mode 0)		; tool bar を表示しない
(menu-bar-mode 0)		; menu bar を表示しない
(which-function-mode 1)	; 現在の関数名をモードラインに表示

行頭に行番号を表示する(モード行ではなく)

モードラインに現在カーソルが位置している関数の関数名を表示する

Time-stamp

; Time-stamp
; http://homepage.mac.com/zenitani/elisp-j.html#time-stamp
(require 'time-stamp)
(setq time-stamp-start "Last updated: <")	; 開始文字列の設定。通常は "Time-stamp: <>"
;; 日本語で日付を入れたくないのでlocaleをCにする
(defun time-stamp-with-locale-c ()
  (let ((system-time-locale "C"))
    (time-stamp)
    nil))
(if (not (memq 'time-stamp-with-locale-c write-file-hooks))
    (add-hook 'write-file-hooks 'time-stamp-with-locale-c))
; (setq time-stamp-format "%3a %3b %02d %02H:%02M:%02S %Z %:y")
(setq time-stamp-format "%04y/%02m/%02d %02H:%02M:%02S %Z")	; YYYY/MM/DD HH:MM:SS JST

文字数を数える

isearch で、カーソルの位置にある単語を検索対象にする

shell-mode で制御文字を処理する

; shell-mode で制御文字を処理する。
(autoload 'ansi-color-for-comint-mode-on "ansi-color"
          "Set `ansi-color-for-comint-mode' to t." t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

ファイルを read-only で開く

C-x C-r

バックアップファイルを作らないようにする

(setq make-backup-files nil)  ; *.~ とかのバックアップファイルを作らない
(setq auto-save-default nil)  ; .#* とかのバックアップファイルを作らない

選択領域を [DEL] で一気に消せるようにする

; (setq delete-selection-mode t)
(delete-selection-mode)

HTML文書編集での自動補完

scroll を1行単位にする

(setq scroll-step 1)

分割した window のサイズを変える

commanddescriptionremark
M-x: enlarge-window縦方向にサイズを大きくする
M-x: shrink-window縦方向にサイズを小さくする
M-x: enlarge-window-horizontally横方向にサイズを大きくする
M-x: shrink-window-horizontally横方向にサイズを小さくする

ウインドウ自動分割時の制御

beep 音を消す

前のウインドウに戻る

; XEmacsにはあるが、emacsにはない(!)
; http://matome.replore.com/index.php?title=Emacs_Lisp%E3%81%BE%E3%81%A8%E3%82%81
; xemacsに合わせて、関数名を backward-other-window に変更。
; (defun other-window-backward (&optional n)
(defun backward-other-window (&optional n)
  "Select nth previous window."
  (interactive "P")
  (other-window (- (prefix-numeric-value n))))

起動済みのemacs にファイルを渡す (emacsclient)

検索時に大文字・小文字を区別するかしないかの設定

(setq default-case-fold-search nil)  ; 大文字・小文字を区別させる(〜emacs23.1)
(setq case-fold-search nil)          ; 大文字・小文字を区別させる (emacs23.2〜)

ediff

control window を別ウインドウにしないようにする

参考リンク

カレンダーで日本の祝日を表示する

gdb-mode

helm

入手先

参考リンク

clang-format

環境構築

  1. パッケージをインストールする
    apt-get install clang-tools-7 clang-format
  2. clang-tools のパスを通す
    export PATH=/usr/lib/llvm-7/bin:${PATH}
  3. emacs 向けパッケージの設定
  1. 上記各リポジトリを tag で checkout する
    package nametagremark
    lsp-moderefs/tags/7.0
    lsp-uirefs/tags/7.0
    company-lsprefs/tags/2.1.0
    elpa(HEAD)tagは試行中。動かなかったら検討する。
  2. 上記各リポジトリのファイルが emacs から見える場所に配置する。
    ::: ~/.emacs/init.el
    ;;; ~/.emacs.d/site-lisp 配下に各リポジトリを配置した場合の設定例
    ; (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/dash") load-path)) ; dash (use system-included)
    (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/elpa/packages/cl-generic") load-path)) ; cl-generic
    (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/ht") load-path)) ; ht.el
    (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/elpa/packages/hydra") load-path)) ; lv.el
    (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/elpa/packages/spinner") load-path)) ; spinner.el
    (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/elpa/packages/company") load-path)) ; company.el
    
    
    (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/lsp-mode") load-path))
    (require 'lsp-mode)
    
    (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/lsp-ui") load-path))
    (require 'lsp-ui)
    
    (setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/company-lsp") load-path))
    (require 'company-lsp)
    
    
    
    (add-hook 'c++-mode-hook 'company-mode) ; 補完用
    (add-hook 'c++-mode-hook 'flycheck-mode) ; チェック用
    (add-hook 'c++-mode-hook #'lsp)
    
    (provide 'clang-format.conf)

参考 URI

多言語入力

ドイツ語

  1. M-x set-input-method german
  2. ウムラウトは以下のキー入力にて。ちなみに z と y が入れ替わるので、慣れてない人は注意!
    CharacterKey binding
    äC-x 8 " a
    üC-x 8 " u
    öC-x 8 " o

チェコ語

html-mode

キーバインド

keycommanddescriptionremark
C-c C-jhtml-line改行+ <br>挿入
C-c C-hhtml-paragraph<p> 挿入
C-c C-asgml-attributes
C-c C-bsgml-skip-tag-backward一つ前の開始タグまで戻る(?)
C-c C-ddelete-tagタグ単位で消す
C-c C-fsgml-skip-tag-foward1つ先の終了タグまで飛ぶ(?)
C-c /sgml-close-tag終了タグを挿入する
C-c <1-6>html-headline-<1-6>h1-h6 の開始・終了タグを挿入する
C-c C-c -html-horizontal-rule<hr> タグを挿入する
C-c C-c chtml-checkboxes'<input type="checkbox" name="' を挿入する
C-c C-c hhtml-href-ancor'<a href="' を挿入する
C-c C-c ihtml-image対話的に img タグを挿入する
C-c C-c nhtml-name-anchor'<a name="' を挿入する
C-c C-c ohtml-ordered-list番号リストの開始タグを挿入する
C-c C-c rhtml-radio-buttonラジオボタンを挿入する
C-c C-c uhtml-unordered-list番号なしリストの開始タグを挿入する
C-c DELsgml-delete-tagカーソルの後ろのタグを消す

参考リンク


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS