Created
December 18, 2011 13:00
-
-
Save ohcannotangel/1493361 to your computer and use it in GitHub Desktop.
coupling from filename
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
;; coupling.el | |
;; written by oh_cannot_angel | |
;; | |
;;; Installation: | |
;; | |
;; Put the coupling.el to your load-path. | |
;; Add to init.el or .emacs: | |
;; (require 'coupling) | |
;; (coupling-source-directory) | |
;; (global-set-key (kbd "C-c b") 'coupling-from-directory) | |
;; M-x Neco runs Neco. Try it! | |
;; coupling.el | |
;; default coupling-source-directory | |
(setq coupling-source-directory "~/.emacs.d/elisp") | |
(defun create-coupling-source-list () | |
(delq nil (mapcar | |
(lambda (s) | |
(when (string-match "\\(.+\\)\\..+" s) | |
(match-string 1 s))) | |
;; file-list))) | |
(directory-files coupling-source-directory)))) | |
(defun coupling-from-list (lst) | |
(let* ((seme (random-select lst)) | |
(uke (random-select (delq seme lst)))) | |
(message "%s × %s" seme uke))) | |
(defun random-select (lst) | |
(cond ((null lst) nil) | |
((nth (random (length lst)) lst)))) | |
(defun coupling-from-directory () | |
(interactive) | |
(let* ((l (create-coupling-source-list))) | |
(when l | |
(coupling-from-list l)))) | |
(provide 'coupling) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment