<commit_before>;; relative line number for operator state
;; inspired by https://github.com/cofi/dotfiles/blob/master/emacs.d/config/cofi-evil.el
(defvar cofi/current-line 0
  "Stores the current line before linum numbers the lines.")
(defadvice linum-update (before set-current-line activate)
  (setq cofi/current-line (line-number-at-pos)))
(defun cofi/relative-line (line-number)
  (let ((relative (abs (- line-number cofi/current-line))))
    (propertize (format "%2d" relative) 'face (if (= relative 0)
                                                  'linum-current-line
                                                'linum))))
(defun cofi/evil-toggle-relative-lines ()
  (interactive)
  (if (eq linum-format #'cofi/relative-line)
      (progn
        (linum-mode -1)
        (setq linum-format #'cofi/linum-dynamic-lines))
    (progn
      (linum-mode t)
      (setq linum-format #'cofi/relative-line)))
  (linum-update-current))
(defun cofi/linum-dynamic-lines (line-number)
  (let ((width (ceiling (log (count-lines (point-min) (point-max)) 10))))
    (propertize (format (format "%%%dd" width) line-number)
                'face (if (= cofi/current-line line-number)
                          'linum-current-line
                        'linum))))
(setq linum-format #'cofi/linum-dynamic-lines)

;; evil mode init ------------------------------------------------------------

(use-package evil
  :init
  (progn
    (setq evil-mode-line-format 'before)
    (setq evil-emacs-state-cursor  '("red" box))
    (setq evil-normal-state-cursor '("orange" box))
    (setq evil-visual-state-cursor '("black" box))
    (setq evil-insert-state-cursor '("green3" box))
    (setq evil-motion-state-cursor '("purple" box))
    (add-to-hooks #'cofi/evil-toggle-relative-lines
                  '(evil-operator-state-entry-hook
                    evil-operator-state-exit-hook))
    ;; I prefer to stay on the original character when leaving insert mode
    ;; (initiated with 'i').
    (setq evil-move-cursor-back nil)
    (evil-mode 1))
  :config<commit_msg>Switch all evil motion states to evil normal states<commit_after>;; relative line number for operator state
;; inspired by https://github.com/cofi/dotfiles/blob/master/emacs.d/config/cofi-evil.el
(defvar cofi/current-line 0
  "Stores the current line before linum numbers the lines.")
(defadvice linum-update (before set-current-line activate)
  (setq cofi/current-line (line-number-at-pos)))
(defun cofi/relative-line (line-number)
  (let ((relative (abs (- line-number cofi/current-line))))
    (propertize (format "%2d" relative) 'face (if (= relative 0)
                                                  'linum-current-line
                                                'linum))))
(defun cofi/evil-toggle-relative-lines ()
  (interactive)
  (if (eq linum-format #'cofi/relative-line)
      (progn
        (linum-mode -1)
        (setq linum-format #'cofi/linum-dynamic-lines))
    (progn
      (linum-mode t)
      (setq linum-format #'cofi/relative-line)))
  (linum-update-current))
(defun cofi/linum-dynamic-lines (line-number)
  (let ((width (ceiling (log (count-lines (point-min) (point-max)) 10))))
    (propertize (format (format "%%%dd" width) line-number)
                'face (if (= cofi/current-line line-number)
                          'linum-current-line
                        'linum))))
(setq linum-format #'cofi/linum-dynamic-lines)

;; evil mode init ------------------------------------------------------------

(use-package evil
  :init
  (progn
    (setq evil-mode-line-format 'before)
    (setq evil-emacs-state-cursor  '("red" box))
    (setq evil-normal-state-cursor '("orange" box))
    (setq evil-visual-state-cursor '("black" box))
    (setq evil-insert-state-cursor '("green3" box))
    (setq evil-motion-state-cursor '("purple" box))
    (add-to-hooks #'cofi/evil-toggle-relative-lines
                  '(evil-operator-state-entry-hook
                    evil-operator-state-exit-hook))
    ;; I prefer to stay on the original character when leaving insert mode
    ;; (initiated with 'i').
    (setq evil-move-cursor-back nil)
    (evil-mode 1)
    ;; replace motion state by normal state and add some other modes
    (setq evil-normal-state-modes (append '(rcirc-mode) evil-motion-state-modes)))
  :config
{'fraction_non_alphanumeric': 0.16778991401347898, 'fraction_numerical': 0.0037183360446200325, 'mean_word_length': 2.2630780894617133, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4978855', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1357, 'n_words': 321}