從0開始的Emacs列數模式數列通常不會導致我的悲傷,但我正在處理一些基於行/列的數據文件,其規範以'1'開頭,並且如果我可以讓emacs做到這一點,或者找到一些elisp,那將會容易得多。我可以更改emacs第一列的概念嗎? (從零到一)
思想歡迎。
從0開始的Emacs列數模式數列通常不會導致我的悲傷,但我正在處理一些基於行/列的數據文件,其規範以'1'開頭,並且如果我可以讓emacs做到這一點,或者找到一些elisp,那將會容易得多。我可以更改emacs第一列的概念嗎? (從零到一)
思想歡迎。
你不能輕易地改變Emacs的基於1的列計數,改變必須在C代碼中。
但是,您可以計算自己的列並將其放入模式行中。注意:這需要使用force-mode-line-update
- 這可能會減慢您的Emacs速度(請記住,以防Emacs在兩年後在某些大型緩衝區中感覺不穩定)。
;; update the mode line to have line number and column number
(setq mode-line-position
'("%p (%l," (:eval (format "%d)" (1+ (current-column))))))
;; force the update of the mode line so the column gets updated
(add-hook 'post-command-hook 'force-mode-line-update)
使用的文件鏈接'Variables Used In Mode Line'和'Cursor Position Information'。
那麼,這可能不是最好的答案,因爲我不知道emacs那麼好。我編輯了mode-line-position
,這是mode-line-format
的一部分。在使用它之前,請看原始值,以確保沒有遺漏任何東西。
(setq mode-line-position
'((-3 #("%p" 0 2 (help-echo "Size indication mode
mouse-1: Display Line and Column Mode Menu" mouse-face mode-line-highlight local-map (keymap (mode-line keymap (down-mouse-1 keymap (column-number-mode menu-item "Display Column Numbers" column-number-mode :help "Toggle displaying column numbers in the mode-line" :button (:toggle . column-number-mode)) (line-number-mode menu-item "Display Line Numbers" line-number-mode :help "Toggle displaying line numbers in the mode-line" :button (:toggle . line-number-mode)) "Toggle Line and Column Number Display"))))))
(size-indication-mode (8 #(" of %I" 0 6 (help-echo "Size indication mode
mouse-1: Display Line and Column Mode Menu" mouse-face mode-line-highlight local-map (keymap (mode-line keymap (down-mouse-1 keymap (column-number-mode menu-item "Display Column Numbers" column-number-mode :help "Toggle displaying column numbers in the mode-line" :button (:toggle . column-number-mode)) (line-number-mode menu-item "Display Line Numbers" line-number-mode :help "Toggle displaying line numbers in the mode-line" :button (:toggle . line-number-mode)) "Toggle Line and Column Number Display")))))))
"(%l,[%c"
(:eval (format ",%d])" (1+ (current-column))))))
的主要問題是,當你從模式行的格式刪除%c
(列號),您(:eval (current-column))
作品很慢。我不知道如何讓它變得更好。
從Emacs 26(尚未發佈)開始,將會有內置旋鈕來解決這個問題。
要使用它,設置 (setq column-number-indicator-zero-based nil)
在你的.emacs
你可以建立從git倉庫的主分支在Emacs現在將得到這個功能。
謝謝;這工作很好。 –