Created
May 14, 2010 10:02
-
-
Save omo/400997 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; modified http://www.emacswiki.org/emacs/TinyUrl | |
(require 'thingatpt) | |
(defun my-get-shorter-bug-url(longer-uri) | |
(cond ((string-match "bugs.webkit.org" longer-uri) | |
(let ((num-start (string-match "[[:digit:]]" longer-uri))) | |
(concat "http://webkit.org/b/" (substring longer-uri num-start)))) | |
((string-match "http://code.google.com/p/chromium/issues" longer-uri) | |
(let ((num-start (string-match "[[:digit:]]" longer-uri))) | |
(concat "http://crbug.com/" (substring longer-uri num-start)))) | |
((error (concat longer-uri " is not bug url"))))) | |
(defun my-shorten-bug-url() | |
(interactive) | |
(let ((bounds (bounds-of-thing-at-point 'url))) | |
(when bounds | |
(let* ((long-url (buffer-substring | |
(car bounds) (cdr bounds))) | |
(short-url (my-get-shorter-bug-url long-url))) | |
(save-excursion | |
(goto-char (car bounds)) | |
(replace-string long-url short-url nil (car bounds) (cdr bounds))))))) | |
(global-set-key (kbd "C-c S") 'my-shorten-bug-url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment