ユーザ用ツール

サイト用ツール


サイドバー

emacs

emacs

以下,微妙に使うショートカットを一部抜粋

M-= 文字数のカウント
C-M-\ カレントリージョンをまとめてインデント
C-c Enter (.f90モード) &(改行)&を出力

Frotran90でopenmpに色付け

;;; highlight fortran openmp code
;;; original version is ...
;;; https://www.pgroup.com/userforum/viewtopic.php?t=5214&sid=51dc5164d4b5962373b0adda3fa62705
(when (require 'font-lock nil 'noerror ) 
 
  (defface openmp-face 
    '((t 
       :foreground "#666666"
       ;; :background "yellow" 
       ;; :bold       t 
       )) 
    "Face for !$ [a-zA-Z] comments" 
    ) 
  (defvar openmp-face 'openmp-face) 
 
  (defface openmp2-face 
    '((t 
       :foreground "#999999"
       ;; :background "yellow" 
       ;; :bold       t 
       )) 
    "Face for !$OMP comments" 
    ) 
  (defvar openmp2-face 'openmp2-face) 
 
 
  (defvar omp-regex "$[\t ][a-zA-Z].*") 
  (defvar omp-regex2 "$omp[\t ].*") 
  (defvar omp-regex-f90 (concat "^[ \t]*\\(!" omp-regex "\\)" ) ) 
  (defvar omp-regex2-f90 (concat "^[ \t]*\\(!" omp-regex2 "\\)" ) ) 
 
  (font-lock-add-keywords 'f90-mode  
                          ( list 
                            ( list omp-regex-f90 1 'openmp-face  t) 
                            ( list omp-regex2-f90 1 'openmp2-face  t) 
                            )) 
 
)

Changelog memo

http://0xcc.net/unimag/1/

Ctrl-c M とするとChangelog mode でdiary.txtが立ち上がる. ~/memo/diary.txt をDropbox内のファイルに変更しておくと幸せになれる.

(defun memo ()
  (interactive)
    (add-change-log-entry 
     nil
     (expand-file-name "~/memo/diary.txt")))
(define-key ctl-x-map "M" 'memo)

名前やアドレスの設定

(setq user-full-name "hoge piyo")
(setq user-mail-address "...@???.com")

Headline

起動時にウィンドウが2つに割れないようにする.

(setq inhibit-startup-message t)

テキストの印刷

emacsで

C-u M-x ps-print-buffer-with-faces

でpsファイルにカラーのまま出力. 白黒でよければ,

C-u M-x ps-print-buffer

psファイルをpdfにしておけば,タブレットでも見れる. 以下は端末でのコマンド.

 ps2pdf file.ps

細かい字でも平気な人は以下の設定でOK. http://www.emacswiki.org/emacs/PsPrint

(setq ps-paper-type 'a4
	  ps-font-size 7.0
	  ps-print-header nil
	  ps-landscape-mode t
	  ps-number-of-columns 2)

エラーメッセージ

** (emacs:16172): CRITICAL **: murrine_style_draw_box: assertion `height >= -1' failed

なんてエラーがでる場合,/usr/share/themes/Ambiance/gtk-2.0/gtkrc を編集. GtkRange::trough-under-steppers = 0 ⇒ GtkRange::trough-under-steppers = 1.

フレームを縦分割したときも折り返し

C-x 3したときに、右から文字があふれる人のために。

(setq truncate-partial-width-windows nil)

折り返しをON/OFF

C-c C-lで折り返したり溢れさせたり、を切り替えれるようになる。

(defun toggle-truncate-lines ()
  "折り返し表示をトグル動作します."
  (interactive)
  (if truncate-lines
      (setq truncate-lines nil)
    (setq truncate-lines t))
  (recenter))
(global-set-key "\C-c\C-l" 'toggle-truncate-lines) ; 折り返し表示ON/OFF

etags

たくさんサブルーチンを作る人は、tagをつけると幸せ。

~/workdir$ etags *f90 *f

とやると、workdir 内にある *f90 *fの中で呼ばれているサブルーチンのリストを作ってくれる。 リストはTAGSというファイルに吐き出される。

さらに、 *.f90のなかに、hogeというサブルーチンがあるとき、emacsでhogeの文字の上にカーソルをもってきて

M-.

と叩くと、hogeが定義されている場所に連れていってくれる。 元の箇所へ帰るときは

M-*

http://www.bookshelf.jp/soft/meadow_42.html#SEC634 http://www.emacswiki.org/emacs/?action=browse;oldid=TagFile;id=TagsFile

コンパイラオプションを付けてもエラーの行数が出ない

sudo apt-get install gdb
gfortran  ◯◯◯◯.f90 -g -fbounds-check
gdb ./a.out

実行するには

run

抜け出すには

quit

起動時の下の画面を消す

端末で下のようにファイルを作る.

emacs .emacs.d/init.el&

できたファイルに下記のものを貼る.

(setq inhibit-startup-message t)
(put 'upcase-region 'disabled nil)

その他の便利な機能はgoogleで,「emacs init.el」で検索すると出るはず.

背景を黒く

背景が黒の方が目にやさしいらしい。 .zshrcか.bashrcか何かに、

alias emacs='emacs -r'

でおk。もっと凝ったことをしたければ、 http://www.emacswiki.org/emacs/ColorTheme なんてのもあるらしい。 load-pathの通った場所 1) にcolor-theme.elを置いて、 .emacsに

(require 'color-theme)

と書いて、M-x color-theme-[Tab]で気に入ったものを探せばよろしい。 気に入ったテーマが見つかったら、.emacsに

(color-theme-hogehogehoge)

と書いておくと、emacsを起動するたびにhogehogehogeを開いてくれる。 ただし、拾ってきたcolor-theme.elにはbugがいる模様。common-color-configurationの部分をコメントアウトすれば、一応動くようにはなる。FIXME

ispell-buffer

M-x(Alt押しながらx)ispell-bufferで、スペルチェックしてくれる。 Error: No word lists can be found for the language “ja_JP”.と怒られるかも。 ~/.aspell.confというファイルを新規作成して、

lang en_US

と書いておく。

ispell-buffer起動後は、変更したい単語を選ぶことでスペルミスをした単語を修正できる。 また、間違っていない場合(elastodynamics, FEMなど)はSpaceを押すとスキップでき、さらにその単語を自分の辞書に追加したい場合はiを押せば良い。 追加の単語は ~/.aspell.en.pws に記述される.直接編集することも可能.

emacsから日本語文書を直接印刷

  • gs-cjk-resource, cmap-adobe-japan1が必要
sudo apt-get install gs-cjk-resource cmap-adobe-japan1
  • ~/.emacs.el に以下の設定を追記.
(setq ps-multibyte-buffer 'non-latin-printer)
(require 'ps-mule)
(defalias 'ps-mule-header-string-charsets 'ignore)
  • M-x ps-print-buffer かメニューバーからFile ⇒ print Postscript Bufferで印刷.

anthyの設定

; Anthy, swith mode by CTRL-
(load-library "anthy")
(setq default-input-method "japanese-anthy")
 
;(setq its-hira-period ".")
;(setq its-hira-comma ",")
(anthy-change-hiragana-map "," ",")
(anthy-change-hiragana-map "." ".")

yatexの設定

;旧来のショートカットを利用(ubuntu only?)
(setq YaTeX-inhibit-prefix-letter nil)
;;*.texで自動的にYaTeXモード
(setq auto-mode-alist
      (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist))
(autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)
(setq tex-command "platex")
(setq dvi2-command "xdvi")
;; 1 = Shift_JIS, 2 = ISO-2022-JP, 3 = EUC-JP, 4 = UTF-8
(setq YaTeX-kanji-code 4)
;;use LaTeX2e and AMS-LaTeX
(setq YaTeX-use-LaTeX2e t)
(setq YaTeX-use-AMS-LaTeX t)
;;font latex hook
(add-hook 'yatex-mode-hook
         '(lambda () (require 'font-latex)
            (font-latex-setup))) 
;;dvipdfmxの追加
;; dviからpdfを作成する%sはファイル名,C-c t l(古いprefixの場合)
(setq dviprint-command-format "dvipdfmx %s")

a2psjを使った印刷

a2psjが必要.

sudo apt-get install a2ps-perl-ja
;;;====================================
;;;; print - 印刷設定
;;;====================================
;;; Postscript で印刷
(setq print-command-format "a2psj| lpr")
  (defun print-region (begin end)
    (interactive "r")
      (shell-command-on-region begin end print-command-format))
  (defun print-buffer ()
    (interactive)
      (print-region (point-min) (point-max)))
(setq print-function (function print-buffer))
1) .emacsに
(setq load-path (cons (expand-file-name "~/適当な/ディレクトリの/名前") load-path))
を書けばよい
emacs.txt · 最終更新: 2017/10/03 12:55 (外部編集)