diff options
-rw-r--r-- | emacsconf-erc.el | 29 |
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 |