Created
January 31, 2010 20:07
-
-
Save gifnksm/291215 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun beginning-of-indented-line (current-point) | |
"インデント文字を飛ばした行頭に戻る。ただし、ポイントから行頭までの間にインデント文字しかない場合は、行頭に戻る。" | |
(interactive "d") | |
(if (minibuffer-window-active-p (get-buffer-window (current-buffer))) | |
(beginning-of-line) | |
(if (string-match | |
"^[ \t]+$" | |
(save-excursion | |
(buffer-substring-no-properties | |
(progn (beginning-of-line) (point)) | |
current-point))) | |
(beginning-of-line) | |
(back-to-indentation)))) | |
(defun beginning-of-visual-indented-line (current-point) | |
"インデント文字を飛ばした行頭に戻る。ただし、ポイントから行頭までの間にインデント文 字しかない場合は、行頭に戻る。" | |
(interactive "d") | |
(if (minibuffer-window-active-p (get-buffer-window (current-buffer))) | |
(beginning-of-line) | |
(let ((vhead-pos (save-excursion (progn (beginning-of-visual-line) (point)))) | |
(head-pos (save-excursion (progn (beginning-of-line) (point))))) | |
(message (format "%d, %d" vhead-pos head-pos)) | |
(cond | |
;; 物理行の1行目にいる場合 | |
((eq vhead-pos head-pos) | |
(if (string-match | |
"^[ \t]+$" | |
(buffer-substring-no-properties vhead-pos current-point)) | |
(beginning-of-visual-line) | |
(back-to-indentation))) | |
;; 物理行の2行目以降の先頭にいる場合 | |
((eq vhead-pos current-point) | |
(backward-char) | |
(beginning-of-visual-indented-line (point))) | |
;; 物理行の2行目以降の途中にいる場合 | |
(t (beginning-of-visual-line)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment