Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change emacs' notion of the first column? (From zero to one)

Tags:

emacs

Emacs column-number-mode numbers columns from 0 which normally doesn't cause me any grief, but I'm working with some line/column based data files whose spec starts with '1', and it would be a lot easier if I could either get emacs to do that, or find some elisp to.

Thoughts welcome.

like image 275
Michael Campbell Avatar asked Oct 19 '11 15:10

Michael Campbell


1 Answers

You cannot easily change Emacs to have 1-based column counting, the change would have to be in the C code.

However, you can calculate your own column and put that in the mode line. Note: this requires the use of the force-mode-line-update - which could potentially slow down your Emacs (just keep it in mind in case two years from now Emacs feels sluggish on some large buffer).

;; 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)

Doc links of use are 'Variables Used In Mode Line' and 'Cursor Position Information'.

like image 157
Trey Jackson Avatar answered Oct 03 '22 14:10

Trey Jackson