<commit_before>#+SETUPFILE: ~/.emacs.d/org-init/level-0.orgsetup
* Toby Mode
  I made a minor-mode to capture some features and key-bindings that I
  think might bother another experienced Emacs user.  This way I can
  turn those bits off should the need arise.

** Setup
   Make some common-lisp-isms available:
   #+BEGIN_SRC emacs-lisp
   (eval-when-compile (require 'cl))
   #+END_SRC

   I still use a couple functions from the old TextMate package:
   #+BEGIN_SRC emacs-lisp
   (require-package 'textmate)
   (require 'textmate)
   #+END_SRC

** Commands
   Use =tramp= to re-open a file with more privileges:
   #+BEGIN_SRC emacs-lisp
   (defun sudo-file ()
     "Re-open the current buffer's file with sudo"
     (interactive)
     (let ((p (point)))
       (find-alternate-file
        (concat "/sudo::" (buffer-file-name)))
           (goto-char p)))
   #+END_SRC

   #+BEGIN_SRC emacs-lisp
   (defun duplicate-line ()
     "Duplicate the current line"
     (interactive)
     (save-excursion
       (move-beginning-of-line 1)
       (kill-line)
       (yank)
       (open-line 1)
       (next-line 1)
       (yank)))
   #+END_SRC

   Sometimes, like inside some shells, you might find yourself wanting
   to swap the Meta and Super modifiers.  This command lets you do that:
   #+BEGIN_SRC emacs-lisp
   (defun swap-modifiers ()
     "Swap meta and super"
     (interactive)
     (cond
      ((equal ns-command-modifier 'super)
       (setq ns-command-modifier   'meta
             ns-alternate-modifier 'super)
       (message "Command is Meta"))
      (t
       (setq ns-command-modifier   'super
             ns-alternate-modifier 'meta)
       (message "Alt is Meta"))))
   #+END_SRC

   New-line and indent from anywhere in the current line:
   #+BEGIN_SRC emacs-lisp
   (defun toby/open-line ()
     "Insert a newline after the current line and move down"
     (interactive)
     (end-of-visual-line)
     (newline-and-indent))
   #+END_SRC

   Save all buffers while updating the modification time of the
   current buffer's file.  This is handy if you're using something
   like [[https://github.com/guard/guard][Guard]] to automatically run unit tests.
   #+BEGIN_SRC emacs-lisp
   (defun touch ()
     "update the mtime of the file for the current buffer"
     (interactive)
     (save-some-buffers 't)
     (shell-command (concat "touch "
                            (shell-quote-argument (buffer-file-name))))
     (clear-visited-file-modtime)
     (message "I'm touched"))
   #+END_SRC

   Increment a number at the point:
   #+BEGIN_SRC emacs-lisp
   (defun toby/increment-number-at-point (&optional arg)
     "Increment the decimal number at point by 'arg'."
     (interactive "p*")
     (save-excursion
       (save-match-data
         (let ((number (number-at-point))
               (inc-by (if arg arg 1)))
           (when number
             (progn
               (forward-word)
               (search-backward (number-to-string number))
               (replace-match (number-to-string (+ number inc-by)))))))))
   #+END_SRC

   #+BEGIN_SRC emacs-lisp
   (defun toby/align-columns (start end regexp)<commit_msg>No confirm on save all<commit_after>#+SETUPFILE: ~/.emacs.d/org-init/level-0.orgsetup
* Toby Mode
  I made a minor-mode to capture some features and key-bindings that I
  think might bother another experienced Emacs user.  This way I can
  turn those bits off should the need arise.

** Setup
   Make some common-lisp-isms available:
   #+BEGIN_SRC emacs-lisp
   (eval-when-compile (require 'cl))
   #+END_SRC

   I still use a couple functions from the old TextMate package:
   #+BEGIN_SRC emacs-lisp
   (require-package 'textmate)
   (require 'textmate)
   #+END_SRC

** Commands
   Use =tramp= to re-open a file with more privileges:
   #+BEGIN_SRC emacs-lisp
   (defun sudo-file ()
     "Re-open the current buffer's file with sudo"
     (interactive)
     (let ((p (point)))
       (find-alternate-file
        (concat "/sudo::" (buffer-file-name)))
           (goto-char p)))
   #+END_SRC

   #+BEGIN_SRC emacs-lisp
   (defun duplicate-line ()
     "Duplicate the current line"
     (interactive)
     (save-excursion
       (move-beginning-of-line 1)
       (kill-line)
       (yank)
       (open-line 1)
       (next-line 1)
       (yank)))
   #+END_SRC

   Sometimes, like inside some shells, you might find yourself wanting
   to swap the Meta and Super modifiers.  This command lets you do that:
   #+BEGIN_SRC emacs-lisp
   (defun swap-modifiers ()
     "Swap meta and super"
     (interactive)
     (cond
      ((equal ns-command-modifier 'super)
       (setq ns-command-modifier   'meta
             ns-alternate-modifier 'super)
       (message "Command is Meta"))
      (t
       (setq ns-command-modifier   'super
             ns-alternate-modifier 'meta)
       (message "Alt is Meta"))))
   #+END_SRC

   New-line and indent from anywhere in the current line:
   #+BEGIN_SRC emacs-lisp
   (defun toby/open-line ()
     "Insert a newline after the current line and move down"
     (interactive)
     (end-of-visual-line)
     (newline-and-indent))
   #+END_SRC

   Save all buffers while updating the modification time of the
   current buffer's file.  This is handy if you're using something
   like [[https://github.com/guard/guard][Guard]] to automatically run unit tests.
   #+BEGIN_SRC emacs-lisp
   (defun touch ()
     "update the mtime of the file for the current buffer"
     (interactive)
     (save-some-buffers 'no-confirm)
     (shell-command (concat "touch "
                            (shell-quote-argument (buffer-file-name))))
     (clear-visited-file-modtime)
     (message "I'm touched"))
   #+END_SRC

   Increment a number at the point:
   #+BEGIN_SRC emacs-lisp
   (defun toby/increment-number-at-point (&optional arg)
     "Increment the decimal number at point by 'arg'."
     (interactive "p*")
     (save-excursion
       (save-match-data
         (let ((number (number-at-point))
               (inc-by (if arg arg 1)))
           (when number
             (progn
               (forward-word)
               (search-backward (number-to-string number))
               (replace-match (number-to-string (+ number inc-by)))))))))
   #+END_SRC

   #+BEGIN_SRC emacs-lisp
   (defun toby/align-columns (start end regexp)
{'fraction_non_alphanumeric': 0.11155188828943192, 'fraction_numerical': 0.0015867978419549348, 'mean_word_length': 2.418112798264642, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2605603', 'n_tokens_mistral': 2071, 'n_tokens_neox': 2007, 'n_words': 611}