Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
coupling from filename
;; 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 ()
(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
You can’t perform that action at this time.