Last active
June 12, 2024 23:01
-
-
Save podhmo/def90c8e45e7e4625d45bc3793052138 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 my:count-chars-of-first-line () | |
(interactive) | |
(save-excursion | |
(save-restriction | |
(goto-char (point-min)) | |
(let (beg end) | |
(beginning-of-line) | |
(setq beg (point)) | |
(end-of-line) | |
(setq end (point)) | |
(when (interactive-p) | |
(message "chars=%s in first line beg=%s end=%s" (- end beg) beg end)) | |
(- end beg))))) | |
(defun my:open-with-low-cost-mode--if-huge-first-line () | |
(interactive) | |
"先頭行が長過ぎる場合に、論理行での移動を止める" | |
(let ((threashold 2000)) | |
(when (>= (my:count-chars-of-first-line) threashold) | |
(fundamental-mode) | |
(message "huge first line, so setq-local line-mode-visual nil") | |
(setq-local line-move-visual nil) ;; C-nでの移動は論理行ではなく物理行にする | |
))) | |
(with-eval-after-load 'js | |
(add-hook 'js-json-mode-hook 'my:open-with-low-cost-mode--if-huge-first-line)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment