<commit_before>;;; -*- lexical-binding: t -*-
;;; Commentary:

;; Utility functions and commands

;;; Code:

;; save any dirty buffers
;;;###autoload
(defun me:save-dirty-buffers ()
  "Save any dirty buffers"
  (interactive)
  (save-some-buffers t))

;; Return non-nil if buffer can be selected.  This allows
;; certain non-file buffers to be selected with
;; me:select-nth-other-buffer.

(defconst me:special-names #'("*scratch*" "*Messages*" "*ielm*" "*Help*" "*info*"))
(defconst me:special-modes #'( dired-mode woman-mode ))

(defun me:useful-buffer (buffer)
  (let ((bufname (buffer-name buffer)))
    (cond ((member bufname me:special-names))             ;; one of these names
          ((buffer-file-name buffer))                     ;; has a file
          ((string-match ".~[-_.A-Za-z]+~$" bufname))     ;; magit branch buffer
          ((member (with-current-buffer buffer major-mode) me:special-modes)))))  ;; one of these modes

;;;###autoload
(defun me:select-nth-other-buffer (arg &optional prefix)
  "Select the nth other buffer. Use prefix to put in other window"
  (interactive "P")
  (let ((buffer (nth arg (-filter 'me:useful-buffer (buffer-list)))))
    (if buffer
        (if prefix
            (switch-to-buffer-other-window buffer)
          (switch-to-buffer buffer)))))

;;;###autoload
(defun me:select-2nd-other-buffer (&optional prefix)
  "Select 2nd other buffer"
  (interactive "P")
  (me:select-nth-other-buffer 1 prefix))

;;;###autoload
(defun me:select-3rd-other-buffer (&optional prefix)
  "Select 2nd other buffer"
  (interactive "P")
  (me:select-nth-other-buffer 2 prefix))

;;;###autoload<commit_msg>[emacs] consider magit status to be a useful buffer<commit_after>;;; -*- lexical-binding: t -*-
;;; Commentary:

;; Utility functions and commands

;;; Code:

;; save any dirty buffers
;;;###autoload
(defun me:save-dirty-buffers ()
  "Save any dirty buffers"
  (interactive)
  (save-some-buffers t))

;; Return non-nil if buffer can be selected.  This allows
;; certain non-file buffers to be selected with
;; me:select-nth-other-buffer.

(defconst me:special-names #'("*scratch*" "*Messages*" "*ielm*" "*Help*" "*info*"))
(defconst me:special-modes #'( dired-mode woman-mode magit-status-mode))

(defun me:useful-buffer (buffer)
  (let ((bufname (buffer-name buffer)))
    (cond ((member bufname me:special-names))             ;; one of these names
          ((buffer-file-name buffer))                     ;; has a file
          ((string-match ".~[-_.A-Za-z]+~$" bufname))     ;; magit branch buffer
          ((member (with-current-buffer buffer major-mode) me:special-modes)))))  ;; one of these modes

;;;###autoload
(defun me:select-nth-other-buffer (arg &optional prefix)
  "Select the nth other buffer. Use prefix to put in other window"
  (interactive "P")
  (let ((buffer (nth arg (-filter 'me:useful-buffer (buffer-list)))))
    (if buffer
        (if prefix
            (switch-to-buffer-other-window buffer)
          (switch-to-buffer buffer)))))

;;;###autoload
(defun me:select-2nd-other-buffer (&optional prefix)
  "Select 2nd other buffer"
  (interactive "P")
  (me:select-nth-other-buffer 1 prefix))

;;;###autoload
(defun me:select-3rd-other-buffer (&optional prefix)
  "Select 2nd other buffer"
  (interactive "P")
  (me:select-nth-other-buffer 2 prefix))

;;;###autoload
{'fraction_non_alphanumeric': 0.16811768237766436, 'fraction_numerical': 0.003602521765235665, 'mean_word_length': 3.47248322147651, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '3593774', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1091, 'n_words': 308}