diff options
| author | Craig Jennings <c@cjennings.net> | 2026-07-11 13:14:56 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-07-11 13:14:56 -0500 |
| commit | d9897243c88b39109996e67f214ebff63d000742 (patch) | |
| tree | 3a84a6dd7b8f3e540ed5da2ad2c86872b5c734a3 /custom/profile-dotemacs.el | |
| parent | 559530a208f8287d450cd842bfbdda92da97971c (diff) | |
| download | dotemacs-d9897243c88b39109996e67f214ebff63d000742.tar.gz dotemacs-d9897243c88b39109996e67f214ebff63d000742.zip | |
refactor: retire unreferenced modules to an archive directory
A reachability sweep from init.el found eight .el files that nothing in the config loads or references. I moved them under archive/ (off the load-path, still tracked in git) so they stay readable and restorable rather than deleted. archive/README.org records the rule (every .el outside archive/ should be actively used) and why each file was retired.
I retired show-kill-ring, duet-config, and mu4e-org-contacts-setup from modules/, and eplot, profile-dotemacs, titlecase, titlecase-data, and edit-indirect from custom/. Retiring show-kill-ring also removed the orphaned M-K -> M-S-k translation in keyboard-compat, which had left M-K a dead key. Its tests now assert seventeen translations and guard M-K's absence.
Diffstat (limited to 'custom/profile-dotemacs.el')
| -rw-r--r-- | custom/profile-dotemacs.el | 161 |
1 files changed, 0 insertions, 161 deletions
diff --git a/custom/profile-dotemacs.el b/custom/profile-dotemacs.el deleted file mode 100644 index 8baee47b..00000000 --- a/custom/profile-dotemacs.el +++ /dev/null @@ -1,161 +0,0 @@ -;;; profile-dotemacs.el --- Profile your Emacs init file - -;; Copyright (C) 2010, 2012 David Engster - -;; Author: David Engster <dengste@eml.cc> - -;; This file is NOT part of GNU Emacs. - -;; This program 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 2 -;; of the License, or (at your option) any later version. -;; -;; This program 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. -;; -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see <http://www.gnu.org/licenses/>. - -;;; Commentary: -;; -;; Profiles profile-dotemacs-file by evaluating top-level sexps with -;; benchmark-run, then overlays the source buffer so expensive forms stand out -;; by percentage of total runtime. -;; -;; Run with: -;; emacs -Q -l /path/to/profile-dotemacs.el -f profile-dotemacs -;; -;; Full sexps are the unit of measurement; split large conditional blocks before -;; profiling if finer detail is needed. - -;;; Code: - -(require 'thingatpt) -(require 'benchmark) - -;; User variables - -(defvar profile-dotemacs-file "~/.emacs.d/init.el" - "File to be profiled.") - -(defvar profile-dotemacs-low-percentage 3 - "Percentage which should be considered low. -All sexp's with a running time below this percentage will be -grayed out.") - -(defface profile-dotemacs-time-face - '((((background dark)) (:background "OrangeRed1")) - (t (:background "red3"))) - "Background color to indicate percentage of total time.") - -(defface profile-dotemacs-low-percentage-face - '((((background dark)) (:foreground "gray25")) - (t (:foreground "gray75"))) - "Face for sexps below `profile-dotemacs-low-percentage'.") - -(defface profile-dotemacs-highlight-face - '((((background dark)) (:background "blue")) - (t (:background "yellow"))) - "Highlight face for benchmark results.") - -;; Main function - -(defun profile-dotemacs () - "Load `profile-dotemacs-file' and benchmark its sexps." - (interactive) - (with-current-buffer (find-file-noselect profile-dotemacs-file t) - (setq buffer-read-only t) ;; just to be sure - (goto-char (point-min)) - (let (start end results) - (while - (< (point) - (setq end (progn - (forward-sexp 1) - (point)))) - (forward-sexp -1) - (setq start (point)) - (add-to-list - 'results - `(,start ,end - ,(benchmark-run - (eval (sexp-at-point))))) - (goto-char end)) - (profile-dotemacs-show-results results) - (switch-to-buffer (current-buffer))))) - -;; Helper functions - -(defun profile-dotemacs-show-results (results) - "Show timings from RESULTS in current buffer." - (let ((totaltime (profile-dotemacs-totaltime results)) - current percentage ov) - (while results - (let* ((current (pop results)) - (ov (make-overlay (car current) (cadr current))) - (current (car (last current))) - (percentage (/ (+ (car current) (nth 2 current)) - totaltime)) - col benchstr lowface) - (setq col - (profile-dotemacs-percentage-color - percentage - (face-background 'default) - (face-background 'profile-dotemacs-time-face))) - (setq percentage (round (* 100 percentage))) - (setq benchstr (profile-dotemacs-make-benchstr current)) - (overlay-put ov 'help-echo benchstr) - (if (and (numberp profile-dotemacs-low-percentage) - (< percentage profile-dotemacs-low-percentage)) - (overlay-put ov 'face 'profile-dotemacs-low-percentage-face) - (overlay-put ov 'before-string - (propertize benchstr - 'face 'profile-dotemacs-highlight-face)) - (overlay-put ov 'face - `(:background ,col))))) - (setq ov (make-overlay (1- (point-max)) (point-max))) - (overlay-put ov 'after-string - (propertize - (format "\n-----------------\nTotal time: %.2fs\n" - totaltime) - 'face 'profile-dotemacs-highlight-face)))) - -(defun profile-dotemacs-totaltime (results) - "Calculate total time of RESULTS." - (let ((totaltime 0)) - (mapc (lambda (x) - (let ((cur (car (last x)))) - (setq totaltime (+ totaltime (car cur) (nth 2 cur))))) - results) - totaltime)) - -(defun profile-dotemacs-percentage-color (percent col-begin col-end) - "Calculate color according to PERCENT between COL-BEGIN and COL-END." - (let* ((col1 (color-values col-begin)) - (col2 (color-values col-end)) - (col - (mapcar (lambda (c) - (round - (+ (* (- 1 percent) (nth c col1)) - (* percent (nth c col2))))) - '(0 1 2)))) - (format "RGB:%04x/%04x/%04x" - (car col) - (nth 1 col) - (nth 2 col)))) - -(defun profile-dotemacs-make-benchstr (timings) - "Create descriptive benchmark string from TIMINGS." - (format - (concat - "<Percentage: %d ; " - "Time: %.2f ; " - "Number of GC: %d ; " - "Time for GC: %.2f>\n") - percentage - (car timings) (nth 1 timings) (nth 2 timings))) - - -;; profile-dotemacs.el ends here |
