Continued elsewhere

I've decided to abandon this blog in favor of a newer, more experimental hypertext form of writing. Come over and see the new place.
Showing posts with label emacs. Show all posts
Showing posts with label emacs. Show all posts

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?

Saturday, May 17, 2008

Useful Emacs Dired launch hack

[leavening some technical stuff into the usual political/philosophical content. I'm curious to see if search engines pick it up.]

I live my computational life inside Emacs, which is the best user interface for almost everything; but it's sometimes frustrating that you can't escape Emacs' text-only world. Well, here is a little hack that lets you launch arbitrary files from a Dired view of a directory; using the operating system's registered application; ie, if you navigate to a .pdf file and hit 'l', Acrobat (or whatever) will launch and show you the file. Now I never have to use the accursed Finder. Works on Mac OS X and Ubuntu; might need modifcations for other systems.


;;; Hack dired to launch files with 'l' key. Put this in your ~/.emacs file

(defun dired-launch-command ()
(interactive)
(dired-do-shell-command
(case system-type
(gnu/linux "gnome-open") ;right for gnome (ubuntu), not for other systems
(darwin "open"))
nil
(dired-get-marked-files t current-prefix-arg)))

(setq dired-load-hook
(lambda (&rest ignore)
(define-key dired-mode-map
"l" 'dired-launch-command)))