Last active
January 13, 2024 22:52
-
-
Save lesliesrussell/81e864a45ddfb15a9477eba62889598b to your computer and use it in GitHub Desktop.
extract the hex color for the current line in "list-faces-display"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun extract-hex-code-current-line () | |
(interactive) | |
(let ((line (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) | |
(when (string-match "#\\([0-9a-fA-F]\\{6\\}\\)" line) | |
(let ((hex-code (match-string 1 line))) | |
(kill-new hex-code) ; Copy the hex code to the kill ring | |
(message "Copied hex code: %s" hex-code))))) ; Optional: Display a message confirming the action | |
(with-eval-after-load 'help-mode | |
(define-key help-mode-map (kbd "C-c h") 'extract-hex-code-current-line)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment