Skip to content

Instantly share code, notes, and snippets.

@podhmo
Created May 30, 2024 13:38
Show Gist options
  • Save podhmo/d5554b98abaf9cf60798a994fcbc246e to your computer and use it in GitHub Desktop.
Save podhmo/d5554b98abaf9cf60798a994fcbc246e to your computer and use it in GitHub Desktop.
;; cl-letfを利用すれば内部の関数の呼び出しをすげかえる
(defun my:hello ()
(message "hello %s" "world"))
;; これは単に *Messages* bufferに出力するだけ
(my:hello)
;; これは kill-ring に追加もしてくれる
(cl-letf ((original-message (symbol-function 'message))
((symbol-function 'message)
(lambda (x &rest args)
(let ((text (apply 'format (cons x args))))
(funcall original-message text)
(kill-new text)
text))))
(my:hello))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment