emacsの継続行の扱い

vlineで継続行まわりを変えようとしてて微妙にはまってるんでメモ。
# 行末処理といってもlonglinesとかvisual-line-modeで日本語を扱おうとかそういう話じゃないです。そっちもやりたいけど禁則まわりとかfill.elみてもようわからんです。むずかしい。


で、以下めも。

overflow-newline-into-fringe が non-nil だと

  • 行の最後が改行で改行だけはみでる場合
  • ちょうどwindowの幅と行のカラム数が一緒の場合

のどっちかの場合にカーソルが fringe にめりこむ。

(with-current-buffer (get-buffer-create "*hoge*")
  (display-buffer (current-buffer))
  (let ((w (get-buffer-window (current-buffer)))I)
    (erase-buffer)
    (setq truncate-lines nil)
    (save-excursion
      (insert (make-string (window-width w) ?x)))
    (set-window-point w (line-end-position))))

はみでた直後の文字が全角文字で、はみでる前の行の半角での文字数がwindowsの幅-1の場合に、表示上のカラムと current-column がずれる(これって前からだったかな?前は違ったような)。

(with-current-buffer (get-buffer-create "*hoge*")
  (display-buffer (current-buffer))
  (let ((w (get-buffer-window (current-buffer)))I)
    (erase-buffer)
    (setq truncate-lines nil)
    (save-excursion
      (insert (make-string (1- (window-width w)) ?x) "あx\n")
      (insert (make-string (window-width w) ?x) "あx\n"))
    (save-excursion
      (loop 
       until (eobp) collect
       (prog1
           (progn (end-of-line) (current-column))
         (forward-line))))))