<commit_before>;;; bde-style.el --- Provide BDE-style C++ indentation
;;;
;;; See https://github.com/bloomberg/bde
;;;
;;; -------------- -------------------------------------------------------
;;; Key            Definition
;;; -------------- -------------------------------------------------------
;;; C-c =          `bde-insert-define-class-header'
;;; C-c -          `bde-insert-declare-class-header'
;;; C->            `bde-align-right': align text after point
;;;                to the right. If line ends with a comment such as // RETURN
;;;                or // LOCK, align the comment.
;;; C-c i          `bde-insert-redundant-include-guard'
;;; C-c a          `bde-align-fundecl': align arguments in function declaration
;;; C-c f          `bde-align-funcall': align arguments in function call
;;; C-c m          `bde-align-class-members'
;;; (no key)       `bde-repunctuate'
;;; -------------- -------------------------------------------------------
;;;
;;; `bde-align-right':
;;; Before (cursor anywhere after semi-colon):
;;;     return x; // RETURN
;;; After:
;;;     return x;                                     // RETURN
;;;
;;; `bde-insert-redundant-include-guard':
;;; Before (cursor must be on the line, or region with one or more includes
;;; must be selected):
;;;     #include <bsl_iostream.h>
;;; After:
;;;     #ifndef INCLUDED_BSL_IOSTREAM
;;;     #include <bsl_iostream.h>
;;;     #endif
;;;
;;; `bde-align-fundecl': align function signature
;;; Before (cursor must be inside the argument list):
;;;    Customer(const BloombergLP::bslstl::StringRef& firstName,
;;;             const BloombergLP::bslstl::StringRef& lastName,
;;;             const bsl::vector<int>& accounts,
;;;             int id,
;;;             BloombergLP::bslma::Allocator *basicAllocator = 0);
;;; After:
;;;    Customer(const BloombergLP::bslstl::StringRef&  firstName,
;;;             const BloombergLP::bslstl::StringRef&  lastName,
;;;             const bsl::vector<int>&                accounts,
;;;             int                                    id,
;;;             BloombergLP::bslma::Allocator         *basicAllocator = 0);
;;; TODO: apparently default values should be aligned too.
;;;
;;; `bde-align-funcall': align function call arguments
;;; Before (cursor must be inside the argument list):
;;;    bslma::ManagedPtr<BufferedMessage> message(
;;;       groupInfo->bufferedMessages()[0], &d_bufferedMessagePool);
;;; After:
;;;    bslma::ManagedPtr<BufferedMessage> message(
;;;                                           groupInfo->bufferedMessages()[0],
;;;                                           &d_bufferedMessagePool);
;;; TODO: currently does not work well with comments.
;;;
;;; `bde-align-class-members'
;;; Before (region must be selected):
;;;    bslma::Allocator *d_allocator_p; // held not owned
;;;    bool d_started;
;;;    bdet_TimeInterval d_idleCheckInterval; // Delay between 2 checks for
;;;         // idle sessions. Default is 0, meaning this feature is not used.
;;; After:
;;;    bslma::Allocator *d_allocator_p;    // held not owned
;;;
;;;    bool              d_started;
;;;
;;;    bdet_TimeInterval d_idleCheckInterval;
;;;                                        // Delay between 2 checks for
;;;                                        // idle sessions. Default is 0,
;;;                                        // meaning this feature is not used.
;;;
;;; `bde-repunctuate': puts two spaces at the end of each sentence in selected
;;; region or comment block.
;;; TODO: the regex should be fixed for words like "e.g." or "i.e.".

(with-no-warnings (require 'cl))
(require 'cc-defs)
(require 'cc-vars)
(require 'cc-mode)
(require 'subr-x)
(require 'init-lib)



;;; Utility functions

(defun bde-component-name ()
  "Return the name of the component for the current buffer"
  (let ((name (file-name-sans-extension
               (file-name-nondirectory (buffer-file-name)))))
    (if (string-suffix-p ".t" name)
        (substring name 0 (- (length name) 2))
      name)))

(defun bde-package-name ()
  "Return the name of the package for the current buffer"
  (interactive)
  (let ((component-name (bde-component-name)))
    (substring component-name 0 (string-match "_" component-name))))



;;; Indentation
;;;<commit_msg>Recognise longer suffixes of test drivers<commit_after>;;; bde-style.el --- Provide BDE-style C++ indentation
;;;
;;; See https://github.com/bloomberg/bde
;;;
;;; -------------- -------------------------------------------------------
;;; Key            Definition
;;; -------------- -------------------------------------------------------
;;; C-c =          `bde-insert-define-class-header'
;;; C-c -          `bde-insert-declare-class-header'
;;; C->            `bde-align-right': align text after point
;;;                to the right. If line ends with a comment such as // RETURN
;;;                or // LOCK, align the comment.
;;; C-c i          `bde-insert-redundant-include-guard'
;;; C-c a          `bde-align-fundecl': align arguments in function declaration
;;; C-c f          `bde-align-funcall': align arguments in function call
;;; C-c m          `bde-align-class-members'
;;; (no key)       `bde-repunctuate'
;;; -------------- -------------------------------------------------------
;;;
;;; `bde-align-right':
;;; Before (cursor anywhere after semi-colon):
;;;     return x; // RETURN
;;; After:
;;;     return x;                                     // RETURN
;;;
;;; `bde-insert-redundant-include-guard':
;;; Before (cursor must be on the line, or region with one or more includes
;;; must be selected):
;;;     #include <bsl_iostream.h>
;;; After:
;;;     #ifndef INCLUDED_BSL_IOSTREAM
;;;     #include <bsl_iostream.h>
;;;     #endif
;;;
;;; `bde-align-fundecl': align function signature
;;; Before (cursor must be inside the argument list):
;;;    Customer(const BloombergLP::bslstl::StringRef& firstName,
;;;             const BloombergLP::bslstl::StringRef& lastName,
;;;             const bsl::vector<int>& accounts,
;;;             int id,
;;;             BloombergLP::bslma::Allocator *basicAllocator = 0);
;;; After:
;;;    Customer(const BloombergLP::bslstl::StringRef&  firstName,
;;;             const BloombergLP::bslstl::StringRef&  lastName,
;;;             const bsl::vector<int>&                accounts,
;;;             int                                    id,
;;;             BloombergLP::bslma::Allocator         *basicAllocator = 0);
;;; TODO: apparently default values should be aligned too.
;;;
;;; `bde-align-funcall': align function call arguments
;;; Before (cursor must be inside the argument list):
;;;    bslma::ManagedPtr<BufferedMessage> message(
;;;       groupInfo->bufferedMessages()[0], &d_bufferedMessagePool);
;;; After:
;;;    bslma::ManagedPtr<BufferedMessage> message(
;;;                                           groupInfo->bufferedMessages()[0],
;;;                                           &d_bufferedMessagePool);
;;; TODO: currently does not work well with comments.
;;;
;;; `bde-align-class-members'
;;; Before (region must be selected):
;;;    bslma::Allocator *d_allocator_p; // held not owned
;;;    bool d_started;
;;;    bdet_TimeInterval d_idleCheckInterval; // Delay between 2 checks for
;;;         // idle sessions. Default is 0, meaning this feature is not used.
;;; After:
;;;    bslma::Allocator *d_allocator_p;    // held not owned
;;;
;;;    bool              d_started;
;;;
;;;    bdet_TimeInterval d_idleCheckInterval;
;;;                                        // Delay between 2 checks for
;;;                                        // idle sessions. Default is 0,
;;;                                        // meaning this feature is not used.
;;;
;;; `bde-repunctuate': puts two spaces at the end of each sentence in selected
;;; region or comment block.
;;; TODO: the regex should be fixed for words like "e.g." or "i.e.".

(with-no-warnings (require 'cl))
(require 'cc-defs)
(require 'cc-vars)
(require 'cc-mode)
(require 'subr-x)
(require 'init-lib)



;;; Utility functions

(defun bde-component-name ()
  "Return the name of the component for the current buffer"
  (let ((name (file-name-sans-extension
               (file-name-nondirectory (buffer-file-name)))))
    (message name)
    (cond ((string-match-p "\\.[gipu]\\.t$" name)
           (substring name 0 (- (length name) 4)))
          ((string-suffix-p ".t" name)
           (substring name 0 (- (length name) 2)))
          (t name))))

(defun bde-package-name ()
  "Return the name of the package for the current buffer"
  (interactive)
  (let ((component-name (bde-component-name)))
    (substring component-name 0 (string-match "_" component-name))))



;;; Indentation
;;;
{'fraction_non_alphanumeric': 0.19408991606301024, 'fraction_numerical': 0.0027595722662987236, 'mean_word_length': 2.0180430256766133, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2611885', 'n_tokens_mistral': 2580, 'n_tokens_neox': 2517, 'n_words': 677}