Skip to content

Instantly share code, notes, and snippets.

@faried
Created September 8, 2010 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save faried/570743 to your computer and use it in GitHub Desktop.
Save faried/570743 to your computer and use it in GitHub Desktop.
;; i don't know if anyone needs this, but i find this useful: a context menu for twittering-mode
;;
(setq twittering-mode-menu-map (make-sparse-keymap "Twittering Mode"))
(let ((map twittering-mode-menu-map))
(define-key map [ct] (cons "Copy tweet" 'twittering-push-tweet-onto-kill-ring))
(define-key map [cl] (cons "Copy link" 'twittering-push-uri-onto-kill-ring))
(define-key map [ll] (cons "Load link" 'twittering-click)))
(defalias 'twittering-mode-menu-map twittering-mode-menu-map)
(define-key twittering-mode-map [C-down-mouse-3] 'mouse-set-point)
(define-key twittering-mode-map [C-mouse-3] 'twittering-mode-menu-map)
(defun twittering-push-tweet-onto-kill-ring ()
"Copy the tweet (format: \"username: text\") to the kill-ring."
(interactive)
(let* ((username (get-text-property (point) 'username))
(text (get-text-property (point) 'text))
(copy (if (and username text)
(format "%s: %s" username text)
"")))
(cond ((string= copy "")
nil)
((string= copy (current-kill 0 t))
(message "Already copied %s" copy))
(t
(kill-new copy)
(message "Copied %s" copy)
copy))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment