diff options
| author | Craig Jennings <c@cjennings.net> | 2025-10-17 11:34:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-10-17 11:34:34 -0500 |
| commit | dc7a04516b9e9581fa96911d471c9ff71a1b77e9 (patch) | |
| tree | 5431c896e52d1578f8c0c7815eedca77eb230ea1 /modules | |
| parent | 8997ae94748d2fe7b30d933f8ef3b7c6234c4788 (diff) | |
custom-comments: optimize startup; remove wip function
- add eval-when-compile and autoload functions to speed startup time
- comment user edit needs to be rethought, so removing current wip function
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/custom-comments.el | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/modules/custom-comments.el b/modules/custom-comments.el index 2f508da4..f7aadd66 100644 --- a/modules/custom-comments.el +++ b/modules/custom-comments.el @@ -5,7 +5,8 @@ ;;; Code: -(require 'custom-line-paragraph) +(eval-when-compile (require 'keybindings)) ;; for keymapping below +(autoload 'cj/join-line-or-region "custom-line-paragraph" nil t) ;; --------------------------- Delete Buffer Comments -------------------------- @@ -16,28 +17,6 @@ (let (kill-ring) (comment-kill (count-lines (point-min) (point-max))))) -;; ----------------------------- Comment User Edit ----------------------------- - -(defun cj/comment-user-edit () - "Reformat commented text in an indirect buffer." - (interactive) - (if mark-active - (uncomment-region beg end) - (let ((beg (region-beginning)) - (end (copy-marker (region-end))) - (source buffer (current-buffer)) - (indirect-buffer (make-indirect-buffer source-buffer)) - (with-current-buffer indirect-buffer - ;; Narrow to the selected region - (narrow-to-region start end) - (goto-char (point-min)) - - - ))) - (comment-region beg end)) - ;; if no region - (message "No region was selected. Select the comment lines to reformat.")) - ;; ------------------------------ Comment Reformat ----------------------------- (defun cj/comment-reformat () @@ -61,15 +40,15 @@ "Insert comment text centered around the COMMENT-CHAR character. Default to the hash character when COMMENT-CHAR is nil. Use the lesser of `fill-column' or 80 to calculate the comment length. -Begin and end the line with the appropriate comment symbols for the current mode." +Begin and end line with the appropriate comment symbols for the current mode." (interactive) (if (not (char-or-string-p comment-char)) (setq comment-char "#")) (let* ((comment (capitalize (string-trim (read-from-minibuffer "Comment: ")))) (fill-column (min fill-column 80)) (comment-length (length comment)) - (comment-start-length (length comment-start)) - (comment-end-length (length comment-end)) + ;; (comment-start-length (length comment-start)) + ;; (comment-end-length (length comment-end)) (current-column-pos (current-column)) (space-on-each-side (/ (- fill-column current-column-pos @@ -182,15 +161,15 @@ Leverages cj/comment-centered." ;; ------------------------------- Comment Keymap ------------------------------ -;; Comment styles & removal prefix and keymap -(define-prefix-command 'cj/comment-map nil - "Keymap for comment styling and removal.") -(define-key cj/custom-keymap "C" 'cj/comment-map) -(define-key cj/comment-map "r" 'cj/comment-reformat) -(define-key cj/comment-map "c" 'cj/comment-centered) -(define-key cj/comment-map "-" 'cj/comment-hyphen) -(define-key cj/comment-map "b" 'cj/comment-box) -(define-key cj/comment-map "D" 'cj/delete-buffer-comments) +;; Comment styles & comment removal keymap. +(defvar-keymap cj/comment-map + :doc "Keymap for code comment operations." + "r" #'cj/comment-reformat + "c" #'cj/comment-centered + "-" #'cj/comment-hyphen + "b" #'cj/comment-box + "D" #'cj/delete-buffer-comments) +(keymap-set cj/custom-keymap "C" 'cj/comment-map) (provide 'custom-comments) ;;; custom-comments.el ends here. |
