commit b4e48a8729031496cce97a173a43442724d478d4
parent ccbd0797c583519bc67f5513ed8d5a37ce85c221
Author: andsy10 <andsy1016@gmail.com>
Date: Fri, 16 Oct 2026 07:32:35 +0800
Update keybindings
Diffstat:
3 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/lisp/init-kbd-func.el b/lisp/init-kbd-func.el
@@ -15,6 +15,22 @@
(or (find-file custom-file)
(user-error "No custom file")))
+(defun my-copy-function-name ()
+ "Copy the function name return by `which-function'."
+ (interactive)
+ (if-let* ((func (which-function)))
+ (progn (kill-new func)
+ (message "Save `%s' to kill ring." func))
+ (message "Cannot find the name of the current function.")))
+
+(defun my-copy-buffer-name ()
+ "Copy the name of the current buffer."
+ (interactive)
+ (if-let* ((buf (buffer-name)))
+ (progn (kill-new buf)
+ (message "Save `%s' to kill ring." buf))
+ (message "Cannot find the name of the current buffer.")))
+
(defun my-bounds-of-next-thing (thing)
"Return the bounds of THING at or after point."
(or (bounds-of-thing-at-point thing)
@@ -120,6 +136,16 @@ there's a region, all lines that region covers will be duplicated."
(dolist (item (sort (hash-table-keys straight--profile-cache)))
(insert (format "- %s\n" item))))
+(defun my-insert-raw-org-link (arg)
+ "Insert the last link stored in `org-stored-links' in its raw form.
+When a prefix ARG, do not delete the links from `org-stored-links'."
+ (interactive "P")
+ (if-let* ((links (and (bound-and-true-p org-stored-links) org-stored-links))
+ (link (if arg (caar links) (car (pop org-stored-links))))
+ (unpropertized (substring-no-properties link)))
+ (insert unpropertized)
+ (message "No link to insert")))
+
(defun org-cycle-parent-subtree()
"Cycle parent org subtree."
(interactive)
diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el
@@ -48,8 +48,8 @@
"C-S-<mouse-1>" #'kmacro-x-mc-mark-at-click
;; undo
- "C-/" #'undo-fu-only-undo
- "C-?" #'undo-fu-only-redo
+ [remap undo] #'undo-fu-only-undo
+ [remap undo-redo] #'undo-fu-only-redo
"C-x u" #'vundo
;; navigate
@@ -81,6 +81,7 @@
;; org
"C-c a" #'org-agenda
"C-c l" #'org-store-link
+ "C-c M-l" #'my-insert-raw-org-link
;; other
"C-h h" #'hyperbole
@@ -523,6 +524,11 @@
"g" #'gt-translate
"w" #'my-synosaurus-lookup)
+(general-def
+ :prefix "C-c y"
+ "d" #'my-copy-function-name
+ "b" #'my-copy-buffer-name)
+
;;; other
diff --git a/lisp/init-org.el b/lisp/init-org.el
@@ -5,6 +5,7 @@
;;; Code:
(my-use-package org
+ :commands org-store-link
:hook
(org-mode . org-indent-mode)
(org-mode . visual-line-mode)