<commit_before>;;; evil-helm.el --- Evil bindings for Helm  -*- lexical-binding: t -*-

;; Copyright (C) 2017 <NAME>

;; Author: <NAME> <<EMAIL>>
;; Maintainer: <NAME> <<EMAIL>>
;; <NAME> <<EMAIL>>
;; URL: https://github.com/jojojames/evil-collection
;; Version: 0.0.1
;; Package-Requires: ((emacs "25.1"))
;; Keywords: evil, helm, tools

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published
;; by the Free Software Foundation; either version 3, or (at your
;; option) any later version.
;;
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; For a full copy of the GNU General Public License
;; see <http://www.gnu.org/licenses/>.

;;; Commentary:
;; Evil bindings for Helm.

;;; Code:
(require 'evil)
(require 'helm-files nil t) ; TODO: Check if this is the ideal requirement and if we are not loading too much.

;; To navigate Helm entries with <hjkl> in insert state, we need a modifier.
;; Using the C- modifier would conflict with the help prefix "C-h".  So we use
;; M- prefixed bindings instead.

;; Helm-find-files: We cannot use "h" and "l" in normal state to navigate up and
;; down the file system hierarchy since we need them to use it to edit the
;; minibuffer content.

(defvar helm-map)
(defvar helm-find-files-map)
(defvar helm-read-file-map)

(defun evil-helm-setup ()
  "Set up `evil' bindings for `helm'."
  ;; TODO: We should not modify helm-map in Emacs state but somehow it does not
  ;; work otherwise.
  (define-key helm-map (kbd "M-[") 'helm-previous-source)
  (define-key helm-map (kbd "M-]") 'helm-next-source)
  (define-key helm-map (kbd "M-l") 'helm-execute-persistent-action)
  (dolist (map (list helm-find-files-map helm-read-file-map))
    (define-key map (kbd "M-h") 'helm-find-files-up-one-level)
    (define-key map (kbd "M-l") 'helm-execute-persistent-action) ; TODO: Inheritance does not seem to work for that binding.
    (define-key map (kbd "C-l") nil)) ; So the header displays the above binding.

  (evil-define-key 'normal helm-map
    (kbd "[") 'helm-previous-source
    (kbd "]") 'helm-next-source
    "j" 'helm-next-line
    "k" 'helm-previous-line
    "g" 'helm-beginning-of-buffer
    "G" 'helm-end-of-buffer
    (kbd "SPC") 'helm-toggle-visible-mark)

  (evil-define-key '(normal insert) helm-map
    (kbd "M-j") 'helm-next-line
    (kbd "M-k") 'helm-previous-line
    (kbd "C-f") 'helm-next-page
    (kbd "C-b") 'helm-previous-page))

(provide 'evil-helm)
;;; evil-helm.el ends here
<commit_msg>evil-helm: Add support for numeric prefix in mark commands<commit_after>;;; evil-helm.el --- Evil bindings for Helm  -*- lexical-binding: t -*-

;; Copyright (C) 2017 <NAME>

;; Author: <NAME> <<EMAIL>>
;; Maintainer: <NAME> <<EMAIL>>
;; <NAME> <<EMAIL>>
;; URL: https://github.com/jojojames/evil-collection
;; Version: 0.0.1
;; Package-Requires: ((emacs "25.1"))
;; Keywords: evil, helm, tools

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published
;; by the Free Software Foundation; either version 3, or (at your
;; option) any later version.
;;
;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; For a full copy of the GNU General Public License
;; see <http://www.gnu.org/licenses/>.

;;; Commentary:
;; Evil bindings for Helm.

;;; Code:
(require 'evil)
(require 'helm-files nil t) ; TODO: Check if this is the ideal requirement and if we are not loading too much.

;; To navigate Helm entries with <hjkl> in insert state, we need a modifier.
;; Using the C- modifier would conflict with the help prefix "C-h".  So we use
;; M- prefixed bindings instead.

;; Helm-find-files: We cannot use "h" and "l" in normal state to navigate up and
;; down the file system hierarchy since we need them to use it to edit the
;; minibuffer content.

(defvar helm-map)
(defvar helm-find-files-map)
(defvar helm-read-file-map)

(defun evil-helm-toggle-visible-mark-backwards (&optional args)
  (interactive "p")
  (evil-helm-toggle-visible-mark args t))

(defun evil-helm-toggle-visible-mark (&optional args backwards)
  (interactive "p")
  (unless (numberp args) (setq args 1))
  (dotimes (_ (abs args))
    (if (or (and (< args 0) (not backwards)) (and (> args 0) backwards))
        (helm-toggle-visible-mark-backwards)
      (helm-toggle-visible-mark))))

(defun evil-helm-setup ()
  "Set up `evil' bindings for `helm'."
  ;; TODO: We should not modify helm-map in Emacs state but somehow it does not
  ;; work otherwise.
  (define-key helm-map (kbd "M-[") 'helm-previous-source)
  (define-key helm-map (kbd "M-]") 'helm-next-source)
  (define-key helm-map (kbd "M-l") 'helm-execute-persistent-action)
  (dolist (map (list helm-find-files-map helm-read-file-map))
    (define-key map (kbd "M-h") 'helm-find-files-up-one-level)
    (define-key map (kbd "M-l") 'helm-execute-persistent-action) ; TODO: Inheritance does not seem to work for that binding.
    (define-key map (kbd "C-l") nil)) ; So the header displays the above binding.

  (evil-define-key 'normal helm-map
    (kbd "[") 'helm-previous-source
    (kbd "]") 'helm-next-source
    "j" 'helm-next-line
    "k" 'helm-previous-line
    "g" 'helm-beginning-of-buffer
    "G" 'helm-end-of-buffer
    (kbd "SPC") 'evil-helm-toggle-visible-mark
    (kbd "S-SPC") 'evil-helm-toggle-visible-mark-backwards)

  (evil-define-key '(normal insert) helm-map
    (kbd "M-j") 'helm-next-line
    (kbd "M-k") 'helm-previous-line
    (kbd "C-f") 'helm-next-page
    (kbd "C-b") 'helm-previous-page))

(provide 'evil-helm)
;;; evil-helm.el ends here

{'fraction_non_alphanumeric': 0.1487410371852593, 'fraction_numerical': 0.00416875104218776, 'mean_word_length': 3.6245181187355437, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1941536', 'n_tokens_mistral': 2096, 'n_tokens_neox': 2002, 'n_words': 711}