diff options
| author | Craig Jennings <c@cjennings.net> | 2025-10-20 13:42:41 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-10-20 13:42:41 -0500 |
| commit | fe729159c7bde6f221a2cd09dedf6f87de5bd046 (patch) | |
| tree | 266d14950108a73358dda7056a75e49dc28336ae | |
| parent | e3b008757fe4ff438433b507f192c80c517549ef (diff) | |
refactor: show-kill-ring: improve code readability and consistency
Remove unnecessary lines and fix inconsistencies in code style: -
Remove redundant blank lines in documentation strings. - Use `#'`
for function references. - Replace `global-set-key` with
`keymap-global-set`.
| -rw-r--r-- | modules/show-kill-ring.el | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/modules/show-kill-ring.el b/modules/show-kill-ring.el index c50e5dbb..d5217719 100644 --- a/modules/show-kill-ring.el +++ b/modules/show-kill-ring.el @@ -16,7 +16,6 @@ (defvar show-kill-max-item-size 1000 "This represents the size of a \='kill ring\=' entry. - A positive number means to limit the display of \='kill-ring\=' items to that number of characters.") @@ -27,7 +26,6 @@ that number of characters.") (defun show-kill-ring () "Show the current contents of the kill ring in a separate buffer. - This makes it easy to figure out which prefix to pass to yank." (interactive) ;; kill existing one, since erasing it doesn't work @@ -66,7 +64,7 @@ This makes it easy to figure out which prefix to pass to yank." ;; use define-key instead of local-set-key (use-local-map (make-sparse-keymap)) - (define-key (current-local-map) "q" 'show-kill-ring-exit) + (define-key (current-local-map) "q" #'show-kill-ring-exit) ;; show it (goto-char (point-min)) @@ -79,7 +77,6 @@ This makes it easy to figure out which prefix to pass to yank." (defun show-kill-insert-item (item) "Insert an ITEM from the kill ring into the current buffer. - If it's too long, truncate it first." (let ((max show-kill-max-item-size)) (cond @@ -91,7 +88,7 @@ If it's too long, truncate it first." ;; put ellipsis on its own line if item is longer than 1 line (let ((preview (substring item 0 max))) (if (< (length item) (- (frame-width) 5)) - (insert (concat preview "..." )) + (insert (concat preview "...")) (insert (concat preview "\n...")))))))) (defun show-kill-insert-header () @@ -104,7 +101,7 @@ If it's too long, truncate it first." "Insert final divider and the yank-pointer (YPTR YNUM) info." (when kill-ring (save-excursion - (re-search-backward "^\\(=+ Item [0-9]+\\ +=+\\)$")) + (re-search-backward "^\\(=+ Item [0-9]+ =+\\)$")) (insert "\n") (insert (make-string (length (match-string 1)) ?=)) ;; Use number-to-string instead of int-to-string @@ -119,7 +116,7 @@ If it's too long, truncate it first." (setq kill-ring nil) (garbage-collect)) -(global-set-key (kbd "M-K") 'show-kill-ring) +(keymap-global-set "M-K" #'show-kill-ring) (provide 'show-kill-ring) ;;; show-kill-ring.el ends here |
