Sunday, October 19, 2014

Emacs hack: yank URL from Chrome (on Mac)

Damn is this going to be useful:

(defun yank-chrome-url ()
 "Yank current URL from Chrome"
  (interactive)
  (require 'apples-mode)
  (apples-do-applescript "tell application \"Google Chrome\"
 get URL of active tab of first window
end tell"
    #'(lambda (url status script)
        ;; comes back with quotes which we strip off
        (insert (subseq url 1 (1- (length url)))))))


I suppose I should have separate blogs for stupid hacks and Deep Contemplations of the Nature of Things, but who has the time to manage multiple web presences?

No comments:

Post a Comment