<commit_before>;; make evil jump words like Vim
(defun underscores-in-words ()
  (modify-syntax-entry ?_ "w" (syntax-table)))
(add-hook 'python-mode-hook 'underscores-in-words)
(add-hook 'sh-mode-hook 'underscores-in-words)
(add-hook 'ruby-mode-hook 'underscores-in-words)
(add-hook 'c-mode-common-hook 'underscores-in-words)
(add-hook 'html-mode-hook 'underscores-in-words)
(add-hook 'json-mode-hook 'underscores-in-words)
(add-hook 'sql-mode-hook 'underscores-in-words)
(add-hook 'web-mode-hook 'underscores-in-words)
(add-hook 'perl-mode-hook 'underscores-in-words)
(add-hook 'text-mode-hook 'underscores-in-words)
(add-hook 'robot-mode-hook 'underscores-in-words)
(add-hook 'dockerfile-mode-hook 'underscores-in-words)
(add-hook 'typescript-mode-hook 'underscores-in-words)

;; save the desktop periodically
(add-hook 'projectile-idle-timer-hook 'desktop-save-in-desktop-dir)

(add-to-list 'load-path (expand-file-name "~/.emacs.d/private"))
(require 'google-c-style)
(add-hook 'c-mode-common-hook 'google-set-c-style)

;; Use "; " to comment out .ini files
(add-hook 'conf-space-mode-hook
          (lambda () (setq comment-start "; " comment-end "")))
(add-to-list 'auto-mode-alist '("\\.ini$" . conf-windows-mode))

;; Try to do case-sensitive matching with just hippie expand
;; From http://stackoverflow.com/a/8723712/131159
(defadvice hippie-expand (around hippie-expand-case-fold)
  "Try to do case-sensitive matching (not effective with all functions)."
  (let ((case-fold-search nil))
    ad-do-it))
(ad-activate 'hippie-expand)

(defun after-load-python ()
  (defun python-fill-string (&optional justify)
    (let* ((str-start-pos
            (set-marker
             (make-marker)
             (or (python-syntax-context 'string)
                 (and (equal (string-to-syntax "|")
                             (syntax-after (point)))
                      (point)))))
           (num-quotes (python-syntax-count-quotes
                        (char-after str-start-pos) str-start-pos))
           (str-end-pos
            (save-excursion
              (goto-char (+ str-start-pos num-quotes))
              (or (re-search-forward (rx (syntax string-delimiter)) nil t)
                  (goto-char (point-max)))
              (point-marker)))
           (multi-line-p
            ;; Docstring styles may vary for oneliners and multi-liners.
            (> (count-matches "\n" str-start-pos str-end-pos) 0))
           (delimiters-style
            (pcase python-fill-docstring-style
              ;; delimiters-style is a cons cell with the form
              ;; (START-NEWLINES .  END-NEWLINES). When any of the sexps
              ;; is NIL means to not add any newlines for start or end
              ;; of docstring.  See `python-fill-docstring-style' for a
              ;; graphic idea of each style.
              (`django (cons 1 1))
              (`onetwo (and multi-line-p (cons 1 2)))
              (`pep-257 (and multi-line-p (cons nil 2)))
              (`pep-257-nn (and multi-line-p (cons nil 1)))
              (`symmetric (and multi-line-p (cons 1 1)))))
           (docstring-p (save-excursion
                          ;; Consider docstrings those strings which
                          ;; start on a line by themselves.
                          (python-nav-beginning-of-statement)
                          (and (= (point) str-start-pos))))
           (paragraph-start "[ \t\f]*\"*$\\|[ \t\f]*@[a-z]+:")
           (paragraph-separate "[ \t\f]*\"*$"))
      (save-excursion
        (goto-char (+ str-start-pos num-quotes))
        (delete-region (point) (progn
                                 (skip-syntax-forward "> ")
                                 (point)))
        (newline-and-indent)
        (insert "    "))
      (fill-paragraph justify))))
(with-eval-after-load 'python (after-load-python))

(defun balance-windows-2 (window horizontal)
  "Subroutine of `balance-windows-1'.
WINDOW must be a vertical combination (horizontal if HORIZONTAL
is non-nil)."
  (let* ((char-size (if window-resize-pixelwise
			1
		      (frame-char-size window horizontal)))
	 (first (window-child window))
	 (sub first)
	 (number-of-children 0)<commit_msg>add my eyebrowse hooks and error handling<commit_after>;; make evil jump words like Vim
(defun underscores-in-words ()
  (modify-syntax-entry ?_ "w" (syntax-table)))
(add-hook 'python-mode-hook 'underscores-in-words)
(add-hook 'sh-mode-hook 'underscores-in-words)
(add-hook 'ruby-mode-hook 'underscores-in-words)
(add-hook 'c-mode-common-hook 'underscores-in-words)
(add-hook 'html-mode-hook 'underscores-in-words)
(add-hook 'json-mode-hook 'underscores-in-words)
(add-hook 'sql-mode-hook 'underscores-in-words)
(add-hook 'web-mode-hook 'underscores-in-words)
(add-hook 'perl-mode-hook 'underscores-in-words)
(add-hook 'text-mode-hook 'underscores-in-words)
(add-hook 'robot-mode-hook 'underscores-in-words)
(add-hook 'dockerfile-mode-hook 'underscores-in-words)
(add-hook 'typescript-mode-hook 'underscores-in-words)

;; save the desktop periodically
(add-hook 'projectile-idle-timer-hook 'desktop-save-in-desktop-dir)

(add-to-list 'load-path (expand-file-name "~/.emacs.d/private"))
(require 'google-c-style)
(add-hook 'c-mode-common-hook 'google-set-c-style)

;; Use "; " to comment out .ini files
(add-hook 'conf-space-mode-hook
          (lambda () (setq comment-start "; " comment-end "")))
(add-to-list 'auto-mode-alist '("\\.ini$" . conf-windows-mode))

;; Try to do case-sensitive matching with just hippie expand
;; From http://stackoverflow.com/a/8723712/131159
(defadvice hippie-expand (around hippie-expand-case-fold)
  "Try to do case-sensitive matching (not effective with all functions)."
  (let ((case-fold-search nil))
    ad-do-it))
(ad-activate 'hippie-expand)

(defun after-load-python ()
  (defun python-fill-string (&optional justify)
    (let* ((str-start-pos
            (set-marker
             (make-marker)
             (or (python-syntax-context 'string)
                 (and (equal (string-to-syntax "|")
                             (syntax-after (point)))
                      (point)))))
           (num-quotes (python-syntax-count-quotes
                        (char-after str-start-pos) str-start-pos))
           (str-end-pos
            (save-excursion
              (goto-char (+ str-start-pos num-quotes))
              (or (re-search-forward (rx (syntax string-delimiter)) nil t)
                  (goto-char (point-max)))
              (point-marker)))
           (multi-line-p
            ;; Docstring styles may vary for oneliners and multi-liners.
            (> (count-matches "\n" str-start-pos str-end-pos) 0))
           (delimiters-style
            (pcase python-fill-docstring-style
              ;; delimiters-style is a cons cell with the form
              ;; (START-NEWLINES .  END-NEWLINES). When any of the sexps
              ;; is NIL means to not add any newlines for start or end
              ;; of docstring.  See `python-fill-docstring-style' for a
              ;; graphic idea of each style.
              (`django (cons 1 1))
              (`onetwo (and multi-line-p (cons 1 2)))
              (`pep-257 (and multi-line-p (cons nil 2)))
              (`pep-257-nn (and multi-line-p (cons nil 1)))
              (`symmetric (and multi-line-p (cons 1 1)))))
           (docstring-p (save-excursion
                          ;; Consider docstrings those strings which
                          ;; start on a line by themselves.
                          (python-nav-beginning-of-statement)
                          (and (= (point) str-start-pos))))
           (paragraph-start "[ \t\f]*\"*$\\|[ \t\f]*@[a-z]+:")
           (paragraph-separate "[ \t\f]*\"*$"))
      (save-excursion
        (goto-char (+ str-start-pos num-quotes))
        (delete-region (point) (progn
                                 (skip-syntax-forward "> ")
                                 (point)))
        (newline-and-indent)
        (insert "    "))
      (fill-paragraph justify))))
(with-eval-after-load 'python (after-load-python))

(defun after-load-eyebrowse ()
  (defun eyebrowse--load-window-config (slot)
    "Restore the window config from SLOT."
    (-when-let (match (assq slot (eyebrowse--get 'window-configs)))
      ;; KLUDGE: workaround for #36
      ;; see also http://debbugs.gnu.org/cgi/bugreport.cgi?bug=20848
      (when (version< emacs-version "25")
        (delete-other-windows)
        (set-window-dedicated-p nil nil))
      ;; KLUDGE: workaround for visual-fill-column foolishly
      ;; setting the split-window parameter
      (let ((ignore-window-parameters t)
            (window-config (eyebrowse--fixup-window-config (cadr match))))
        ;; (with-demoted-errors
            ;; (window-state-put window-config (frame-root-window) 'safe)
            (window-state-put window-config (frame-root-window))
          ;; )
            )))

  (defun golden-ratio (&optional arg)
    "Resizes current window to the golden-ratio's size specs."
    (interactive "p")
    (unless (or (and (not golden-ratio-mode) (null arg))
                (window-minibuffer-p)
                (one-window-p)
                (golden-ratio-exclude-major-mode-p)
                (member (buffer-name)
                        golden-ratio-exclude-buffer-names)
                (and golden-ratio-exclude-buffer-regexp
                  (loop for r in golden-ratio-exclude-buffer-regexp
                          thereis (string-match r (buffer-name))))
                (and golden-ratio-inhibit-functions
                    (loop for fun in golden-ratio-inhibit-functions
                          thereis (funcall fun))))
      (let ((dims (golden-ratio--dimensions))
            (golden-ratio-mode nil))
        ;; Always disable `golden-ratio-mode' to avoid
        ;; infinite loop in `balance-windows'.
        (balance-windows)
        (golden-ratio--resize-window dims)
        (when golden-ratio-recenter
          (scroll-right)
          (condition-case err
              recenter
            (message "config.el is catching recenter error: '%s'"
                     (error-message-string err)))
          )))))
(with-eval-after-load 'eyebrowse (after-load-eyebrowse))

(add-hook 'eyebrowse-pre-window-switch-hook
          (lambda ()
            (setq using-golden-ratio golden-ratio-mode)
            (spacemacs/toggle-golden-ratio-off)
            ))
(add-hook 'eyebrowse-post-window-switch-hook
          (lambda ()
            (if using-golden-ratio
                (spacemacs/toggle-golden-ratio-on))
            ))

(defun balance-windows-2 (window horizontal)
  "Subroutine of `balance-windows-1'.
WINDOW must be a vertical combination (horizontal if HORIZONTAL
is non-nil)."
  (let* ((char-size (if window-resize-pixelwise
			1
		      (frame-char-size window horizontal)))
	 (first (window-child window))
	 (sub first)
	 (number-of-children 0)
{'fraction_non_alphanumeric': 0.14481049830228504, 'fraction_numerical': 0.006699091493071487, 'mean_word_length': 2.0785310734463276, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1020301', 'n_tokens_mistral': 3595, 'n_tokens_neox': 3364, 'n_words': 771}