突っ走り書き

見せるほどのものでは..

TeX で章を移動するための emacs lisp

\chapter,\section,\subsection,\subsubsection を検索して移動するためのコマンドを作った.

(defun next-setion ()
  "Move to next section."
  (interactive)
  (end-of-line)
  (re-search-forward "^[ \t]*\\\\\\(sub\\)?\\(sub\\)?section\\*?{.*}"))

(defun previous-section ()
  "Move to previous section."
  (interactive)
  (beginning-of-line)
  (re-search-backward "^[ \t]*\\\\\\(sub\\)?\\(sub\\)?section\\*?{.*}"))

(defun grep-section ()
  "Search all line with section command."
  (interactive)
  (grep (format "%s %s"
                "grep -nH -E '\\\\(sub|subsub)?section\\*?{.*}|\\\\chapter{.*}'"
                (file-name-nondirectory (buffer-file-name))))
  (pop-to-buffer "*grep*"))

(add-hook 'yatex-mode-hook
          '(lambda ()
             (local-set-key (kbd "C-c s") 'grep-section)
             (local-set-key (kbd "M-N") 'next-setion)
             (local-set-key (kbd "M-P") 'previous-section)))