.emacs.d

the most bloated Emacs config on this planet
git clone https://git.trogloxene.org/.emacs.d.git
Log | Files | Refs

commit 224095d93434a06f11dcac19a1757e7c555ddcb5
parent 7af0e35acc08d59b1bc25ff28edddcc09c51544f
Author: andsy10 <andsy1016@gmail.com>
Date:   Mon, 19 Oct 2026 10:40:59 +0800

Add some helper functions

Diffstat:
Mlisp/init-kbd.el | 6++++++
Mlisp/init-org.el | 16++++++++++++++++
Mlisp/init-package.el | 47+++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el @@ -183,6 +183,11 @@ (general-def embark-file-map "d" #'consult-directory-externally "p" #'emms-play-dired) +(general-def embark-org-link-map + "j" #'my-embark-denote-dired-jump + "b" #'my-embark-denote-find-backlink-with-location) +(general-def embark-general-map + "j" #'embark-dired-jump) ;; emms (general-def emms-playlist-mode-map @@ -252,6 +257,7 @@ ;; help (general-def (help-mode-map helpful-mode-map) + "s" #'my-helpful-view-source "p" #'previous-line "n" #'next-line "R" #'remove-hook-at-point) diff --git a/lisp/init-org.el b/lisp/init-org.el @@ -141,6 +141,22 @@ (fetcher (lambda () (xref-matches-in-files id files)))) (consult-xref fetcher nil))) + (defun my-embark-org--refine-link (source) + (if (string-prefix-p "denote:" source) + (replace-regexp-in-string + "::.*" "" (string-remove-prefix "denote:" source)))) + + (defun my-embark-denote-find-backlink-with-location (source) + (when-let* ((id (my-embark-org--refine-link source)) + (files (delete (denote-get-path-by-id id) (denote-directory-files nil nil :text-only))) + (fetcher (lambda () (xref-matches-in-files id files)))) + (consult-xref fetcher nil))) + + (defun my-embark-denote-dired-jump (source) + (let* ((id (my-embark-org--refine-link source)) + (file (denote-get-path-by-id id))) + (dired-jump nil file))) + (defun my-org-dblock-update-all () "Update all dynamic blocks in denote files." (interactive) diff --git a/lisp/init-package.el b/lisp/init-package.el @@ -92,10 +92,33 @@ Like normal Emacs `C-k'. Kill to end of line and put content in kill-ring." (interactive) (kill-ring-save (point) (line-end-position)) (ghostel-send-key "k" "ctrl")) + + (defun my-scroll-other-ghostel-window (fun lines) + (let* ((buffer (window-buffer (other-window-for-scrolling))) + (mode (buffer-local-value 'major-mode buffer)) + (running-p (buffer-local-value 'ghostel--command-running buffer))) + (if (and (equal mode 'ghostel-mode) + running-p) + (with-current-buffer buffer + (ghostel-send-key "next")) + (funcall fun)))) + + (defun my-scroll-other-ghostel-window-down (fun lines) + (let* ((buffer (window-buffer (other-window-for-scrolling))) + (mode (buffer-local-value 'major-mode buffer)) + (running-p (buffer-local-value 'ghostel--command-running buffer))) + (if (and (equal mode 'ghostel-mode) + running-p) + (with-current-buffer buffer + (ghostel-send-key "prior")) + (funcall fun)))) + :config (setq eshell-destroy-buffer-when-process-dies t ghostel-ssh-install-terminfo t) - (defalias 'eshell/v 'eshell/ghostel)) + (defalias 'eshell/v 'eshell/ghostel) + (advice-add #'scroll-other-window :around #'my-scroll-other-ghostel-window) + (advice-add #'scroll-other-window-down :around #'my-scroll-other-ghostel-window-down)) (my-use-package consult-ghostel :straight @@ -273,7 +296,27 @@ With a prefix ARG create a new *scratch* buffer." (when (yes-or-no-p (format "Remove %s from %s? " func hook)) (remove-hook hook (intern func)) (if (memq major-mode '(helpful-mode)) - (helpful-update)))))))) + (helpful-update))))))) + + (defun my-helpful-view-source () + "View the source of the current symbol." + (interactive) + (let* ((find-file-visit-truename t) + (location + (helpful--definition helpful--sym helpful--callable-p)) + (buffer (car location)) + (position (cadr location))) + (pop-to-buffer buffer) + (set-auto-mode t) + (if position + (progn + (when (or (< position (point-min)) + (> position (point-max))) + (widen)) + (unless (= (point) position) + (push-mark nil t)) + (goto-char position)) + (message "Unable to find location in file"))))) ;; typing game (my-use-package typit my-enable-unessentials)