Skip to content

Instantly share code, notes, and snippets.

@masutaka
Last active December 11, 2015 02:18
Show Gist options
  • Save masutaka/4529276 to your computer and use it in GitHub Desktop.
Save masutaka/4529276 to your computer and use it in GitHub Desktop.
open-chalow
(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)))
@masutaka
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment