C-aで「行頭」と「インデントを飛ばした行頭」を行き来する(物理行対応版)
先日書いた関数(d:id:gifnksm:20090331:1238488792)の物理行対応版。physical-line.elが別途必要です。
(defun beggining-of-physical-indented-line (current-point) "インデント文字を飛ばした行頭に戻る。 ただし、ポイントから行頭までの間にインデント文字しかない場合は、行頭に戻る。" (interactive "d") (let ((line (save-excursion (buffer-substring-no-properties (progn (physical-line-beginning-of-line) (point)) current-point))) (phys-line-head-pos (save-excursion (progn (physical-line-beginning-of-line) (point)))) (line-head-pos (save-excursion (progn (beginning-of-line) (point))))) (if (or (not (eq phys-line-head-pos line-head-pos)) (string-match "^[ \t]+$" line)) (physical-line-beginning-of-line) (back-to-indentation))))
もっとうまい書き方がある気がする。行頭から数えたカーソル位置を返す関数とかそういうのがあればきっときれいに書ける。