aboutsummaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2026-01-02 18:16:16 +1100
committerYuchen Pei <id@ypei.org>2026-01-02 18:16:16 +1100
commit1044060e69e756290637f388a0b671e06a9b75e0 (patch)
tree5a0e5aa48b22e3e975664ac17181f0c151a29b14 /emacs
parent0782e0efec9e44b92f5b295fef1872f169e98702 (diff)
[emacs][bin] improve random; add lilypond-mode; add scripts for git
annex with picard and write org agenda
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/init/ycp-buffer.el2
-rw-r--r--emacs/.emacs.d/init/ycp-markup.el7
-rw-r--r--emacs/.emacs.d/lisp/my/my-emms.el24
-rw-r--r--emacs/.emacs.d/lisp/my/my-utils.el12
4 files changed, 32 insertions, 13 deletions
diff --git a/emacs/.emacs.d/init/ycp-buffer.el b/emacs/.emacs.d/init/ycp-buffer.el
index 6a560ea..78f5a66 100644
--- a/emacs/.emacs.d/init/ycp-buffer.el
+++ b/emacs/.emacs.d/init/ycp-buffer.el
@@ -235,6 +235,4 @@
"C-M-<mouse-5>" #'my-decrease-default-face-height)
)
-(setq large-file-warning-threshold 15000000)
-
(provide 'ycp-buffer)
diff --git a/emacs/.emacs.d/init/ycp-markup.el b/emacs/.emacs.d/init/ycp-markup.el
index 68b5459..a53d542 100644
--- a/emacs/.emacs.d/init/ycp-markup.el
+++ b/emacs/.emacs.d/init/ycp-markup.el
@@ -144,5 +144,12 @@
(add-to-list 'auto-mode-alist '("\\.html\\'" . htmlv-mode))
)
+;;; lilypond
+(add-to-list 'load-path "/usr/share/emacs/site-lisp")
+(autoload 'LilyPond-mode "lilypond-mode" "LilyPond Editing Mode" t)
+(add-to-list 'auto-mode-alist '("\\.ly\\'" . LilyPond-mode))
+(add-to-list 'auto-mode-alist '("\\.ily\\'" . LilyPond-mode))
+(add-hook 'LilyPond-mode-hook (lambda () (turn-on-font-lock)))
+
(provide 'ycp-markup)
;;; ycp-markup.el ends here
diff --git a/emacs/.emacs.d/lisp/my/my-emms.el b/emacs/.emacs.d/lisp/my/my-emms.el
index 91065a2..0e7243a 100644
--- a/emacs/.emacs.d/lisp/my/my-emms.el
+++ b/emacs/.emacs.d/lisp/my/my-emms.el
@@ -376,6 +376,7 @@ artist/album/track."
(my-emms-playlist-make-buffer-name
my-emms-favourites-playlist)))
+(require 'my-utils)
;;; random album in emms
(defun my-emms-current-album-name ()
(file-name-directory (my-emms-get-current-track-name)))
@@ -414,17 +415,18 @@ artist/album/track."
We put a low weight on discovery album, currently any directory
under /zzz-seren/."
(let ((album
- (elt my-emms-albums-cache (random (length my-emms-albums-cache)))))
+ (elt my-emms-albums-cache (my-random
+ (length my-emms-albums-cache)))))
(while (and (string-match "/zzz-seren/" album)
- (>= (random 100) 4))
+ (>= (my-random 100) 4))
(setq album
- (elt my-emms-albums-cache (random (length my-emms-albums-cache)))))
+ (elt my-emms-albums-cache (my-random (length my-emms-albums-cache)))))
album))
(defun my-emms-playlist-random-album ()
(interactive)
(with-current-emms-playlist
- (goto-line (1+ (random (count-lines (point-min) (point-max)))))
+ (goto-line (1+ (my-random (count-lines (point-min) (point-max)))))
(let ((album-name (my-emms-playlist-album-name-at-point)))
(goto-char (point-min))
(search-forward album-name)
@@ -526,13 +528,13 @@ Override `emms-mode-line-playlist-current' to incorporate wide chars."
(defun my-emms-playlist-random-group ()
(interactive)
(with-current-emms-playlist
- (let ((random-line (1+ (random (count-lines (point-min) (point-max))))))
- (goto-line random-line)
- (pcase-let ((`(,group-start . ,group-end) (my-emms-playlist-group-bounds)))
- (message "my-emms-playlist-random-group: (%d, %d)" random-line group-start)
- (goto-line group-start)
- (my-emms-playlist-mark-bounds group-end)
- (emms-playlist-mode-play-current-track)))))
+ (let ((random-line (1+ (my-random (count-lines (point-min) (point-max))))))
+ (goto-line random-line)
+ (pcase-let ((`(,group-start . ,group-end) (my-emms-playlist-group-bounds)))
+ (message "my-emms-playlist-random-group: (%d, %d)" random-line group-start)
+ (goto-line group-start)
+ (my-emms-playlist-mark-bounds group-end)
+ (emms-playlist-mode-play-current-track)))))
;;; TODO: mark bounds if and only if the currently played is out of
;;; the existing overlay.
diff --git a/emacs/.emacs.d/lisp/my/my-utils.el b/emacs/.emacs.d/lisp/my/my-utils.el
index 05ca2e6..8e0d184 100644
--- a/emacs/.emacs.d/lisp/my/my-utils.el
+++ b/emacs/.emacs.d/lisp/my/my-utils.el
@@ -503,4 +503,16 @@ With optional N, search in the Nth line from point."
(cond ((equal name "MIT") "expat")
(t name)))
+(defun my-random (limit)
+ (string-to-number
+ (calc-eval "$1 % $2" nil
+ (calc-eval
+ (with-temp-buffer
+ (set-buffer-multibyte nil)
+ (call-process "head" "/dev/urandom" t nil "-c"
+ (format "%d" (/ 256 8)))
+ (let ((f (apply-partially #'format "%02x")))
+ (concat "16#" (mapconcat f (buffer-string) "")))))
+ limit)))
+
(provide 'my-utils)