Skip to content

Instantly share code, notes, and snippets.

@lesliesrussell
Last active January 13, 2024 22:52
Show Gist options
  • Save lesliesrussell/81e864a45ddfb15a9477eba62889598b to your computer and use it in GitHub Desktop.
Save lesliesrussell/81e864a45ddfb15a9477eba62889598b to your computer and use it in GitHub Desktop.
extract the hex color for the current line in "list-faces-display"
(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