From a55a5248bd2dae5f849476d0f7b5dcd8d91cf929 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 8 Apr 2024 17:16:29 -0500 Subject: fit and finish work - gptel: added gptel-send-region with global keybinding - projectile: made project-switch-actions more efficient with regexp - prog-go: removed disabled code - mu4e: capture template captures region if selected - system utils: merged bury alive with other killing buffer code - org-capture: renamed *website-clipper to org-webpage-clipper - rg: auto switch to ripgrep-results window when ripgrep search completes - dashboard: remove dashboard banner custom face General - moved abbrev_defs to assets - removed gitmodules file - updated packages - fixed docstring and formatting throughout Custom-Functions - move cj/merge-list-to-list to custom-functions - add remove leading trailing whitespace function - corrected arrayify prompt Font-Config - added font point sizes in fontaine menu - make default font point size 11 Python - adding back python poetry support - added cj/python-setup method - merge python and python-mode configurations (they are the same built-in package) Show-Kill-Ring - show-kill-ring displays in another read-only buffer - show-kill-ring exits with q Elfeed - moved elfeed-feeds.org to assets - removed Wired from elfeed feeds - moved ElfeedDB to user-emacs-directory/.elfeed-db - moved elfeed-dashboard.org to assets --- modules/prog-comments.el | 73 ++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 37 deletions(-) (limited to 'modules/prog-comments.el') diff --git a/modules/prog-comments.el b/modules/prog-comments.el index 61d5e328..62193d6f 100644 --- a/modules/prog-comments.el +++ b/modules/prog-comments.el @@ -30,47 +30,46 @@ ;; per major mode. (defun cj/comment-centered (&optional comment-char) - "Insert comment text centered around the 'COMMENT-CHAR' character. -Will default to the '#' character if called with no arguments. Uses -\\="fill-column"\\= or 80 (whichever is less) to calculate the comment length. -Will begin and end the line with the appropriate comment symbols based on -programming mode." + "Insert comment text centered around the COMMENT-CHAR character. +Will default to the '#' character if called with no arguments. Uses the value of +fill-column or 80 (whichever is less) to calculate the comment length. Will +begin and end the line with the appropriate comment symbols based on programming mode." (interactive) (if (not (char-or-string-p comment-char)) - (setq 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)) - (current-column-pos (current-column)) - (space-on-each-side (/ (- fill-column - current-column-pos - comment-length - (length comment-start) - (length comment-end) - ;; Single space on each side of comment - (if (> comment-length 0) 2 0) - ;; Single space after comment syntax sting - 1) - 2))) + (fill-column (min fill-column 80)) + (comment-length (length comment)) + (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 + comment-length + (length comment-start) + (length comment-end) + ;; Single space on each side of comment + (if (> comment-length 0) 2 0) + ;; Single space after comment syntax sting + 1) + 2))) (if (< space-on-each-side 2) - (message "Comment string is too big to fit in one line") - (progn - (insert comment-start) - (when (equal comment-start ";") ; emacs-lisp line comments are ;; - (insert comment-start)) ; so insert comment-char again - (insert " ") - (dotimes (_ space-on-each-side) (insert comment-char)) - (when (> comment-length 0) (insert " ")) - (insert comment) - (when (> comment-length 0) (insert " ")) - (dotimes (_ (if (= (% comment-length 2) 0) - (- space-on-each-side 1) - space-on-each-side)) - (insert comment-char)) - (insert " ") - (insert comment-end))))) + (message "Comment string is too big to fit in one line") + (progn + (insert comment-start) + (when (equal comment-start ";") ; emacs-lisp line comments are ;; + (insert comment-start)) ; so insert comment-char again + (insert " ") + (dotimes (_ space-on-each-side) (insert comment-char)) + (when (> comment-length 0) (insert " ")) + (insert comment) + (when (> comment-length 0) (insert " ")) + (dotimes (_ (if (= (% comment-length 2) 0) + (- space-on-each-side 1) + space-on-each-side)) + (insert comment-char)) + (insert " ") + (insert comment-end))))) (global-set-key (kbd "C-z c l") 'cj/comment-line) ;; ------------------------------- Comment Hyphen ------------------------------ -- cgit v1.2.3