2 changed files with 0 additions and 49 deletions
@ -1,48 +0,0 @@
|
||||
(defun cp-get-buffer-regexp (regexp &optional all) |
||||
"Returns the name of the first buffer in the buffer list which matches REGEXP. |
||||
|
||||
If ALL is non-nil, multiple matches will be returned as a list." |
||||
(let ((results (cl-remove-if-not (lambda (a) |
||||
(string-match regexp a)) |
||||
(mapcar #'buffer-name (buffer-list))))) |
||||
(if all results (car results)))) |
||||
|
||||
(cl-defun cp-buffer-name-match-p (regexp &optional (string (buffer-name))) |
||||
"Checks if STRING matches REGEXP. |
||||
If STRING is not provided, uses the current buffer name." |
||||
(if (string-match regexp string) t nil)) |
||||
|
||||
(defun cp/random-elt (list) |
||||
"Retun a random element from LIST." |
||||
(nth (random (length list)) list)) |
||||
|
||||
(defun cp/map-two (fn list) |
||||
"Apply FN to the first two elements of LIST, then the second two, and so on." |
||||
(let ((newlist '())) |
||||
(while (not (= 0 (- (length list) 1))) |
||||
(setq newlist |
||||
(append |
||||
newlist (list |
||||
(funcall fn (car list) (cadr list))))) |
||||
(pop list)) |
||||
newlist)) |
||||
|
||||
(defun cp/average (numbers) |
||||
(/ (-reduce '+ numbers) |
||||
(length numbers))) |
||||
|
||||
(defun cp/pastebinit () |
||||
(interactive) |
||||
(-> (shell-command-on-region |
||||
(if (region-active-p) (region-beginning) (point-min)) |
||||
(if (region-active-p) (region-end) (point-max)) |
||||
"pastebinit") |
||||
(kill-new))) |
||||
|
||||
(defun ^ (base pwr) |
||||
(while (not (zerop pwr)) |
||||
(setq base (* base base) |
||||
pwr (- pwr 1))) |
||||
base) |
||||
|
||||
(provide 'cp) |
Loading…
Reference in new issue