relative line number
This commit is contained in:
parent
ee21236448
commit
1851b3418d
|
@ -0,0 +1,22 @@
|
|||
(defvar my-linum-format-string "%3d")
|
||||
(add-hook 'linum-before-numbering-hook 'my-linum-get-format-string)
|
||||
(defun my-linum-get-format-string ()
|
||||
(let* ((width (1+ (length (number-to-string
|
||||
(count-lines (point-min) (point-max))))))
|
||||
(format (concat "%" (number-to-string width) "d")))
|
||||
(setq my-linum-format-string format)))
|
||||
|
||||
(defvar my-linum-current-line-number 0)
|
||||
|
||||
(setq linum-format 'my-linum-relative-line-numbers)
|
||||
|
||||
(defun my-linum-relative-line-numbers (line-number)
|
||||
(let ((offset (- line-number my-linum-current-line-number)))
|
||||
(propertize (format my-linum-format-string offset) 'face 'linum)))
|
||||
|
||||
(defadvice linum-update (around my-linum-update)
|
||||
(let ((my-linum-current-line-number (line-number-at-pos)))
|
||||
ad-do-it))
|
||||
(ad-activate 'linum-update)
|
||||
(custom-set-faces
|
||||
'(linum ((t (:inherit (shadow) :height 0.8)))))
|
|
@ -10,4 +10,5 @@
|
|||
;; highlight current line
|
||||
(global-hl-line-mode t)
|
||||
(set-face-background 'hl-line "#073642")
|
||||
|
||||
;; relative line number
|
||||
(load-file (concat user-extensions-directory "linum-relativenumber.el"))
|
||||
|
|
Loading…
Reference in New Issue