Compare commits

...

8 commits

Author SHA1 Message Date
Benson Chu
89209e4fcf I like this a lot better 2025-07-18 17:23:41 -05:00
Benson Chu
675047fdad I should really read documentation more... 2025-07-18 13:37:00 -05:00
Benson Chu
2631db3ad8 There we go, that's how it's done 2025-07-18 13:37:00 -05:00
c25fb1a755 Merge remote-tracking branch 'origin/build36' 2025-07-15 13:41:50 -05:00
693b6d1e13 Upgraded org-ql and magit 2025-07-15 13:28:46 -05:00
f18149fa2b Turn random into pseudo-random 2025-06-22 09:33:51 -05:00
bf2867688e Fix bug when buffer is empty 2025-06-22 09:33:32 -05:00
42b213de71 Olivetti for self-chat 2025-06-22 09:33:17 -05:00
4 changed files with 82 additions and 137 deletions

View file

@ -295,33 +295,29 @@
#+end_src
* navigation
#+begin_src emacs-lisp
;; Scrollkeeper is helpful for scrolling up and down
(defvar window-third-height nil)
(defun update-window-third-height (&optional arg)
(let ((win
(cond ((framep arg)
(frame-selected-window arg))
((windowp arg)
arg)
((null arg) (selected-window)))))
;; (message "Updating window height for %s" (window-buffer win))
(when (not (active-minibuffer-window))
(setq next-screen-context-lines
(max 1 (* 2 (/ (window-height win) 3)))))))
(defun update-window-third-height (win &rest args)
;; (message "Updating window height for %s" (window-buffer win))
(setq window-third-height
(max 1 (/ (window-height win) 3))))
(update-window-third-hook)
(advice-add #'select-window
:after
'update-window-third-height)
(add-hook 'window-selection-change-functions
#'update-window-third-height)
(defun scroll-up-third ()
(interactive)
;; (pulse-momentary-highlight-one-line (point))
(scroll-up (or window-third-height 10)))
(add-hook 'window-configuration-change-hook
#'update-window-third-height)
(defun scroll-down-third ()
(interactive)
;; (pulse-momentary-highlight-one-line (point))
(scroll-down (or window-third-height 10)))
(global-set-key (kbd "C-v") 'scroll-up-third)
(global-set-key (kbd "M-v") 'scroll-down-third)
;; (use-package scrollkeeper)
;; (global-set-key (kbd "C-v") 'scrollkeeper-down)
;; (global-set-key (kbd "M-v") 'scrollkeeper-up)
;; (advice-add #'select-window
;; :after
;; 'update-window-third-height)
;; Word navigation
(global-set-key (kbd "M-f") 'forward-to-word)

2
elpa

@ -1 +1 @@
Subproject commit 513ae0ba03f7aabf13d8874b47c7322be5bad58a
Subproject commit 57637033e63d3168368de1ca382b1c68985c56f4

View file

@ -120,97 +120,14 @@
:override
#'my/magit-transient-read-person)
(defun my/transient--show ()
(transient--timer-cancel)
(setq transient--showp t)
(let ((transient--shadowed-buffer (current-buffer))
(focus nil))
(setq transient--buffer (get-buffer-create transient--buffer-name))
(with-current-buffer transient--buffer
(when transient-enable-popup-navigation
(setq focus (or (button-get (point) 'command)
(and (not (bobp))
(button-get (1- (point)) 'command))
(transient--heading-at-point))))
(erase-buffer)
(run-hooks 'transient-setup-buffer-hook)
(when transient-force-fixed-pitch
(transient--force-fixed-pitch))
(setq window-size-fixed 'width)
(when (bound-and-true-p tab-line-format)
(setq tab-line-format nil))
(setq header-line-format nil)
(setq mode-line-format
(if (or (natnump transient-mode-line-format)
(eq transient-mode-line-format 'line))
nil
transient-mode-line-format))
(setq mode-line-buffer-identification
(symbol-name (oref transient--prefix command)))
(if transient-enable-popup-navigation
(setq-local cursor-in-non-selected-windows 'box)
(setq cursor-type nil))
(setq display-line-numbers nil)
(setq show-trailing-whitespace nil)
(transient--insert-groups)
(when (or transient--helpp transient--editp)
(transient--insert-help))
(when-let ((line (transient--separator-line)))
(insert line)))
(unless (window-live-p transient--window)
(setq transient--window
(display-buffer transient--buffer
transient-display-buffer-action)))
(when (window-live-p transient--window)
(with-selected-window transient--window
;; Save the previous value of the 'no-other-window window parameter.
(set-window-parameter nil 'prev--no-other-window
(window-parameter nil 'no-other-window))
(goto-char (point-min))
(when transient-enable-popup-navigation
(transient--goto-button focus))
(transient--fit-window-to-buffer transient--window)))))
(defun my/transient--show-post ()
(setq transient--buffer (get-buffer-create transient--buffer-name))
(with-current-buffer transient--buffer
(setq window-size-fixed 'width)))
(advice-add #'transient--show
:override
#'my/transient--show)
;; What's so great about the above advice? Why can't the below work?!
;;
;; (defun my/transient--show-post ()
;; (let ((transient--shadowed-buffer (current-buffer))
;; (focus nil))
;; (setq transient--buffer (get-buffer-create transient--buffer-name))
;; (with-current-buffer transient--buffer
;; (when transient-enable-popup-navigation
;; (setq focus (or (button-get (point) 'command)
;; (and (not (bobp))
;; (button-get (1- (point)) 'command))
;; (transient--heading-at-point)))))
;; (when (window-live-p transient--window)
;; (with-selected-window transient--window
;; (set-window-parameter nil 'prev--no-other-window
;; (window-parameter nil 'no-other-window))
;; (set-window-parameter nil 'no-other-window t)
;; (goto-char (point-min))
;; (when transient-enable-popup-navigation
;; (transient--goto-button focus))
;; (transient--fit-window-to-buffer transient--window)))))
;; (advice-add #'transient--show
;; :after
;; #'my/transient--show-post)
(defun my/transient--delete-win-restore-window-param (&rest ignore)
(when (window-live-p transient--window)
(with-selected-window transient--window
;; Restore the value
(set-window-parameter nil 'no-other-window
(window-parameter nil 'prev--no-other-window)))))
(advice-add #'transient--delete-window
:before
#'my/transient--delete-win-restore-window-param)
:after
#'my/transient--show-post)
(provide 'magit-overrides)
;;; magit-overrides.el ends here

View file

@ -3,6 +3,8 @@
(require 'cl)
(defvar self-chat-num 0)
(defvar self-chat-characters nil)
(defvar self-chat-random-list nil)
(defvar self-chat-last nil)
(defvar self-chat-last2 nil)
(defvar self-chat-highlights nil)
@ -10,7 +12,8 @@
(define-derived-mode self-chat-mode fundamental-mode "self-chat"
"This is a mode where I become crazy and talk to myself."
(setq font-lock-defaults '(self-chat-highlights)))
(setq font-lock-defaults '(self-chat-highlights))
(olivetti-mode 1))
(modify-syntax-entry ?\" " " self-chat-mode-syntax-table)
@ -28,15 +31,16 @@
(not (= self-chat-num self-chat-last)))
(setq self-chat-last2 self-chat-last
self-chat-last self-chat-num))
;; Are we fixing up an old line, or creating a new one?
(if (save-excursion
(beginning-of-line)
(not (looking-at (rx (+ nonl) ":"))))
(progn
(beginning-of-line)
(kill-line))
(call-interactively #'newline)
(call-interactively #'newline))
(unless (and (eobp) (bobp))
;; Are we fixing up an old line, or creating a new one?
(if (save-excursion
(beginning-of-line)
(not (looking-at (rx (+ nonl) ":"))))
(progn
(beginning-of-line)
(kill-line))
(call-interactively #'newline)
(call-interactively #'newline)))
(insert "> "))
(defun chat-post ()
@ -75,16 +79,35 @@
(t
(call-interactively #'delete-backward-char))))
(defun swap (LIST el1 el2)
"in LIST swap indices EL1 and EL2 in place"
(let ((tmp (elt LIST el1)))
(setf (elt LIST el1) (elt LIST el2))
(setf (elt LIST el2) tmp)))
(defun shuffle (LIST)
"Shuffle the elements in LIST.
shuffling is done in place."
(loop for i in (reverse (number-sequence 1 (1- (length LIST))))
do (let ((j (random (+ i 1))))
(swap LIST i j)))
LIST)
(defmacro define-users (list)
`(progn
(setq self-chat-num 0
self-chat-last nil
self-chat-last2 nil
self-chat-highlights nil
self-chat-alist nil)
self-chat-alist nil
self-chat-characters
',(remove-if-not (lambda (char)
(cadddr char))
list))
(defhydra user-chat (:exit t
:body-pre (chat-pre)
:after-exit (chat-post))
:body-pre (chat-pre)
:after-exit (chat-post))
""
("RET" nil "Same")
("TAB" (when self-chat-last2 (setq self-chat-num self-chat-last2)) "Switch")
@ -95,7 +118,15 @@
(prog1 `(,key (setq self-chat-num ,num) ,name)
(cl-incf num))))
list))
("r" (setq self-chat-num (random ,(length list))) "Random"))
("r" (setq self-chat-num
(progn
(unless self-chat-random-list
(setq self-chat-random-list
(--> (length self-chat-characters)
(number-sequence 0 (1- it))
(shuffle it))))
(pop self-chat-random-list)))
"Random"))
,@(let ((num 0))
(mapcan #'(lambda (triple)
(let* ((name (car triple))
@ -111,15 +142,16 @@
(cl-incf num))))
list))))
(define-users (("Tau" "t" "turquoise1")
("Arc" "a" "gold")
("Tom" "T" "rosy brown")
("Dan" "d" "spring green")
("Ver" "v" "white")
("Coop" "c" "cornsilk")
("Net" "n" "magenta")
("Someone" "s" "dim gray")
("Everyone" "e" "pale green")
("Note" "N" "dim gray")))
(define-users (("Tau" "t" "turquoise1" t)
("Arc" "a" "gold" t)
("Tom" "T" "rosy brown" t)
("Dan" "d" "spring green" t)
("Ver" "v" "white" t)
("Coop" "c" "cornsilk" t)
("Net" "n" "magenta" t)
("Someone" "s" "dim gray" nil)
("Everyone" "e" "pale green" nil)
("Note" "N" "dim gray" nil)))
(provide 'self-chat-mode)