Files
.emacs.d/lisp/init-kbd-func.el
andsy10 2162b34007 Config: Strip down and simplify Emacs config
- Remove consult-dir, nerd-icons-completion, org-contrib and some other unused package
- Delete init-org-refile.el and related keybindings
- Prune EMMS config
- Remove EXWM flatpak launcher helpers (vscodium, localsend, steam)
- Extract Windows dirvish video preview fix to standalone module
- Drop built-in settings moved elsewhere (startup defaults, whitespace, etc.)
- Clean up trailing whitespace / process list prettify configs
2026-05-04 12:01:25 +08:00

116 lines
3.4 KiB
EmacsLisp

;;; 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-parent-subtree()
"Cycle parent org subtree."
(interactive)
(if (org-at-heading-p)
(progn
(org-up-heading 1)
(org-cycle))
(org-back-to-heading)
(org-cycle)))
(defun consult-org-ripgrep ()
"Search in org files use consult-ripgrep."
(interactive)
(consult-ripgrep (unless *is-windows*
'("~/org/my-org-note/" "~/org/hugo/this-is-my-blog/all-blog.org"))))
(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