summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSacha Chua <sacha@sachachua.com>2024-12-27 10:31:57 -0500
committerSacha Chua <sacha@sachachua.com>2024-12-27 10:31:57 -0500
commit456fb8abbcc756422f106cb00af4066100a1bf22 (patch)
tree74c9d280fb70397373b8e336c295b9ca9fe282ee
parent574e83bd218859d10f1f421ed85d37449dfc18b7 (diff)
downloademacsconf-el-main.tar.xz
emacsconf-el-main.zip
add emacsconf-erc-copyHEADmain
-rw-r--r--emacsconf-erc.el29
1 files changed, 29 insertions, 0 deletions
diff --git a/emacsconf-erc.el b/emacsconf-erc.el
index b01e3f6..71b2478 100644
--- a/emacsconf-erc.el
+++ b/emacsconf-erc.el
@@ -547,5 +547,34 @@ Usage: /conflog keyword notes go here"
(cons (cons (match-string-no-properties 1 string) (current-time))
(seq-take emacsconf-erc-recent-announcements (1- emacsconf-erc-recent-announcements-length))))))
+;; (keymap-set erc-mode-map "C-c w" #'emacsconf-erc-copy)
+(defun emacsconf-erc-copy (&optional beg end)
+ "Unwrap and copy the current line to the clipboard.
+This makes it easier to paste into the Etherpad."
+ (interactive
+ (list
+ (if (region-active-p)
+ (min (point) (mark)))
+ (if (region-active-p)
+ (max (point) (mark)))))
+ (setq beg (or beg (if (get-text-property (point) 'erc--ts)
+ (line-beginning-position)
+ (prop-match-beginning (text-property-search-backward 'erc--ts)))))
+ (setq end
+ (let ((end-field (save-excursion (text-property-search-forward 'field)))
+ (end-nick (save-excursion (text-property-search-forward 'erc--ts nil nil t))))
+ (min (if end-field (prop-match-beginning end-field) most-positive-fixnum)
+ (if end-nick (prop-match-beginning end-nick) most-positive-fixnum))))
+ (let* ((pulse-flag nil))
+ (when (fboundp 'pulse-momentary-highlight-region)
+ (pulse-momentary-highlight-region beg end))
+ (kill-new
+ (string-trim
+ (replace-regexp-in-string
+ "\n[ \t]+" " "
+ (buffer-substring-no-properties
+ beg
+ end))))))
+
(provide 'emacsconf-erc)
;;; emacsconf-erc.el ends here