Last active
December 11, 2015 02:18
-
-
Save masutaka/4529276 to your computer and use it in GitHub Desktop.
open-chalow
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
(defun open-chalow () | |
"Open the URL that is matched the article under the cursor" | |
(interactive) | |
(let ((date-regexp "^\\([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\\)") | |
(date) | |
(entry-id 1) | |
(current (point))) | |
(save-excursion | |
(setq date (and (re-search-backward date-regexp (point-min) t) | |
(match-string-no-properties 1)))) | |
(save-excursion | |
(or (re-search-forward date-regexp (point-max) t) | |
(goto-char (point-max))) | |
(catch 'loop | |
(while (re-search-backward "^ \\* " (point-min) t) | |
(if (<= (point) current) | |
(throw 'loop t) | |
(setq entry-id (+ entry-id 1)))))) | |
(if date | |
(browse-url (format "http://masutaka.net/chalow/%s-%d.html" | |
date entry-id))))) | |
(eval-after-load "clmemo" | |
'(progn | |
(define-key clmemo-mode-map (kbd "C-c C-o") 'open-chalow))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://masutaka.net/chalow/2013-01-14-1.html