Config: extract keybinding functions and clean up key configs
- Add init-kbd-func.el for keybinding helper functions - Move global-display-line-numbers-mode from early-init.el to init.el - Slim down init-kbd.el: remove hydra-multiple-cursors, migrate defs - Reorganize dirvish config - Remove scattered global-set-key bindings from init-org, init-ui, etc. - Guard server-start with server-running-p check - Set ibuffer-default-sorting-mode to filename - Tweak gptel config
This commit is contained in:
110
lisp/init-kbd-func.el
Normal file
110
lisp/init-kbd-func.el
Normal file
@@ -0,0 +1,110 @@
|
||||
;;; init-kbd-func.el --- functions for keybindings -*- lexical-binding: t -*-
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defun open-init-file()
|
||||
"Open user's init.el file in ~/.emacs.d ."
|
||||
(interactive)
|
||||
(find-file "~/.emacs.d/init.el"))
|
||||
|
||||
(when *is-windows*
|
||||
(defun restart-emacs ()
|
||||
"Restart emacs (for Windows)"
|
||||
(interactive)
|
||||
(save-some-buffers)
|
||||
(w32-shell-execute "open" "runemacs.exe")
|
||||
(kill-emacs)))
|
||||
|
||||
(defun my/jinx-smart-toggle ()
|
||||
"Toggle jinx-mode smartly.
|
||||
Disable jinx-mode if it's enable and global-jinx-mode is disable , otherwise toggle global-jinx-mode."
|
||||
(interactive)
|
||||
(unless (featurep 'jinx)
|
||||
(require 'jinx))
|
||||
(let ((local-on (bound-and-true-p jinx-mode))
|
||||
(global-on (bound-and-true-p global-jinx-mode)))
|
||||
(cond
|
||||
((and local-on (not global-on))
|
||||
(message "disable jinx-mode in current buffer")
|
||||
(jinx-mode -1))
|
||||
(t
|
||||
(if global-on
|
||||
(progn
|
||||
(message "disable global-jinx-mode")
|
||||
(global-jinx-mode -1))
|
||||
(progn
|
||||
(message "enable global-jinx-mode")
|
||||
(global-jinx-mode 1)))))))
|
||||
|
||||
(defun duplicate-and-move-to-next-line()
|
||||
"Duplicate current line and move to next line."
|
||||
(interactive)
|
||||
(progn
|
||||
(duplicate-line)
|
||||
(next-line)))
|
||||
|
||||
(defun popper-toggle-type-delete-other-window()
|
||||
"Toggle type of popper window and delete other window."
|
||||
(interactive)
|
||||
(popper-toggle-type)
|
||||
(delete-other-windows))
|
||||
|
||||
(defun consult-directory-externally (file)
|
||||
"Open FILE externally using the default application of the system."
|
||||
(interactive "fOpen externally: ")
|
||||
(if (and (eq system-type 'windows-nt)
|
||||
(fboundp 'w32-shell-execute))
|
||||
(shell-command-to-string (encode-coding-string (replace-regexp-in-string "/" "\\\\"
|
||||
(format "explorer.exe %s" (file-name-directory (expand-file-name file))))
|
||||
'gbk))
|
||||
(call-process (pcase system-type
|
||||
('darwin "open")
|
||||
('cygwin "cygstart")
|
||||
(_ "xdg-open"))
|
||||
nil 0 nil
|
||||
(file-name-directory (expand-file-name file)))))
|
||||
|
||||
(defun my-open-current-directory ()
|
||||
"Open current directory in default file explorer."
|
||||
(interactive)
|
||||
(consult-directory-externally default-directory))
|
||||
|
||||
(defun org-cycle-current-subtree()
|
||||
"Cycle current subtree."
|
||||
(interactive)
|
||||
(org-back-to-heading)
|
||||
(org-cycle))
|
||||
|
||||
(defun consult-org-ripgrep ()
|
||||
"Jump to org agenda files use consult-ripgrep."
|
||||
(interactive)
|
||||
(consult-ripgrep org-agenda-files))
|
||||
|
||||
(defun org-journal-open-current-journal-file-delete-other-window()
|
||||
"Call org-journal-open-current-journal-file and delete other window."
|
||||
(interactive)
|
||||
(org-journal-open-current-journal-file)
|
||||
(delete-other-windows))
|
||||
|
||||
(defun org-journal-new-entry-delete-other-window()
|
||||
"Call org-journal-new-entry and delete other window."
|
||||
(interactive)
|
||||
(org-journal-new-entry nil)
|
||||
(delete-other-windows))
|
||||
|
||||
(defun switch-to-emms-playlist()
|
||||
"Switch to emms playlist."
|
||||
(interactive)
|
||||
(switch-to-buffer "*EMMS Playlist*"))
|
||||
|
||||
(defun my/dired-next-line()
|
||||
"move to forward line in dired buffer"
|
||||
(interactive)
|
||||
(forward-line 1)
|
||||
(dired-move-to-filename))
|
||||
|
||||
(provide 'init-kbd-func)
|
||||
|
||||
;;; init-kbd-func.el ends here
|
||||
Reference in New Issue
Block a user