Organisational commit

Modified input method is the main highlight.
This commit is contained in:
2026-01-09 21:40:51 +09:00
parent 9cd88d6be9
commit f99504e8f0
5 changed files with 122 additions and 32 deletions

View File

@@ -53,7 +53,7 @@
:straight (hbdh :type git :host github :repo "zzhjerry/hbdh-mode") :straight (hbdh :type git :host github :repo "zzhjerry/hbdh-mode")
:config (hbdh-mode)) :config (hbdh-mode))
(defun my/hbdh-highlight-line () (defun my-hbdh-highlight-line ()
"Activate hbdh, dim text outside of current line" "Activate hbdh, dim text outside of current line"
(interactive) (interactive)
(let ((point-beginning (line-beginning-position)) (let ((point-beginning (line-beginning-position))
@@ -66,7 +66,7 @@
(setq hbdh-mode-map (make-sparse-keymap)) (setq hbdh-mode-map (make-sparse-keymap))
(define-key hbdh-mode-map "a" 'hbdh-activate-on-region) (define-key hbdh-mode-map "a" 'hbdh-activate-on-region)
(define-key hbdh-mode-map "d" 'hbdh-deactivate) (define-key hbdh-mode-map "d" 'hbdh-deactivate)
(define-key hbdh-mode-map "l" 'my/hbdh-highlight-line) (define-key hbdh-mode-map "l" 'my-hbdh-highlight-line)
(global-set-key "\C-ch" hbdh-mode-map) (global-set-key "\C-ch" hbdh-mode-map)
@@ -118,4 +118,25 @@
(unless (memq 'vterm features) (unless (memq 'vterm features)
(load "vterm" nil t)) (load "vterm" nil t))
;;
(add-to-list 'load-path (expand-file-name (concat minimal-emacs-user-directory "load")))
(register-input-method
"cyrillic-workman" "Russian" 'quail-use-package
"RUW@" "Russian (ЙЦУКЕН) input method simulating Workman keyboard"
"cyrillic-workman-input-method")
;; Reverse-IM creates additional bindings that allow usage of different input
;; methods without changing the keyboard layout (most of the time ,for example:
;; keybinds on russian layout will work with this package).
(use-package reverse-im
:ensure t
:defer nil)
(setq reverse-im-char-fold t) ; use lax matching
(setq reverse-im-read-char-advice-function #'reverse-im-read-char-include)
(setq reverse-im-input-methods '("cyrillic-workman")) ; translate these methods
(reverse-im-mode t)
;;; 05-basic.el ends here ;;; 05-basic.el ends here

View File

@@ -1,8 +1,8 @@
;;; 15-lsp.el --- Setup LSP -*- no-byte-compile: t; lexical-binding: t; -*- ;;; 15-lsp.el --- Setup LSP -*- no-byte-compile: t; lexical-binding: t; -*-
;;; Description: ;;; Commentary:
;; Despite the name, this file not only sets up LSP integration, but ;; Despite the name, this file not only sets up LSP integration, but
;; also native emacs modes for various programming lanuguages, such as ;; also native Emacs modes for various programming lanuguages, such as
;; Prolog, that do not use LSP. ;; Prolog, that do not use LSP.
;;; Code: ;;; Code:
@@ -28,13 +28,16 @@
(setq jsonrpc-event-hook nil)) (setq jsonrpc-event-hook nil))
;; This function raises the window to the front using KDE KWin. ;; This function raises the window to the front using KDE KWin.
(defun my/raise-window () (defun my-raise-window ()
"Raises the window to the front using KDE KWin.
Won't work if the script is not there."
(call-process-shell-command "~/wayland-window -f emacs &" nil 0)) (call-process-shell-command "~/wayland-window -f emacs &" nil 0))
;; Usually, when I open a file with emacsclient and the frame already exists, I ;; Usually, when I open a file with emacsclient and the frame already exists, I
;; want it to be raised to the top. Unfortunately, that does not happen by ;; want it to be raised to the top. Unfortunately, that does not happen by
;; default. Here is my solution. ;; default. Here is my solution.
(add-hook 'server-visit-hook #'my/raise-window) (add-hook 'server-visit-hook #'my-raise-window)
;; This package provides syntax highlighting for gdscript. ;; This package provides syntax highlighting for gdscript.
(use-package gdscript-mode (use-package gdscript-mode
@@ -77,12 +80,24 @@
:ensure t :ensure t
:defer t :defer t
:commands (prolog-mode) :commands (prolog-mode)
:init :config
(setq ediprolog-program "systemd-run") (my-ediprolog-select-system "swi-prolog"))
(setq ediprolog-program-switches '("--user" "--scope" "-p" "MemoryMax=2G" "-p" "MemoryHigh=1.9G" "scryer-prolog")))
(defun ediprolog-set-term-type (orig &rest args)
"Advice to set the TERM env var to dumb for the function call.
Originally created for scryer prolog, as either it itself or systemd-run
used to constrain its resources assumed that the terminal supports
escape codes (it does not in this case), so this was used as an
\":around\" advice on 'ediprolog-run-prolog', to clearly indicate that
control codes are not supported."
(let ((process-environment process-environment))
(setenv "TERM" "dumb")
(apply orig args)))
(with-eval-after-load "prolog" (with-eval-after-load "prolog"
(bind-key "C-c C-e" #'ediprolog-dwim prolog-mode-map)) (bind-key "C-c C-e" #'ediprolog-dwim prolog-mode-map)
(advice-add 'ediprolog-run-prolog :around #'ediprolog-set-term-type))
(add-to-list 'auto-mode-alist '("\\.plt?\\'" . prolog-mode)) (add-to-list 'auto-mode-alist '("\\.plt?\\'" . prolog-mode))
(add-to-list 'auto-mode-alist '("\\.axaml?\\'" . nxml-mode)) (add-to-list 'auto-mode-alist '("\\.axaml?\\'" . nxml-mode))
@@ -139,4 +154,4 @@
(indent-bars-treesit-wrap '((rust arguments parameters))) (indent-bars-treesit-wrap '((rust arguments parameters)))
:hook ((python-base-mode yaml-mode rust-mode) . indent-bars-mode)) :hook ((python-base-mode yaml-mode rust-mode) . indent-bars-mode))
;;; 15-lsp.el end here ;;; 15-lsp.el ends here

View File

@@ -7,25 +7,25 @@
;;; Code: ;;; Code:
(defun my/resize-margins-to-fill () (defun my-resize-margins-to-fill ()
"Set the current buffer margins so that its width is equal to the fill "Set the current buffer margins so that its width is equal to the fill
column." column."
(interactive) (interactive)
(let ((margin-size (/ (- (frame-width) fill-column) 2))) (let ((margin-size (/ (- (frame-width) fill-column) 2)))
(set-window-margins nil margin-size margin-size))) (set-window-margins nil margin-size margin-size)))
(defun my/reset-margins () (defun my-reset-margins ()
"Removes margins from the current buffer." "Removes margins from the current buffer."
(interactive) (interactive)
(set-window-margins nil nil nil)) (set-window-margins nil nil nil))
(defun my/insert-buffer-name () (defun my-insert-buffer-name ()
"Inserts the name of the current buffer at point." "Inserts the name of the current buffer at point."
(interactive) (interactive)
(let ((name (buffer-name))) (let ((name (buffer-name)))
(insert name))) (insert name)))
(defun my/create-org-fc-word-card () (defun my-create-org-fc-word-card ()
"Inserts and initialzes an org-fc double card with a word and its "Inserts and initialzes an org-fc double card with a word and its
translation at point." translation at point."
(interactive) (interactive)
@@ -37,13 +37,13 @@ translation at point."
(previous-line) (previous-line)
(org-fc-type-double-init))) (org-fc-type-double-init)))
(keymap-set org-mode-map "C-c C-n" 'my/create-org-fc-word-card) (keymap-set org-mode-map "C-c C-n" 'my-create-org-fc-word-card)
(setq margins-map (make-sparse-keymap)) (setq margins-map (make-sparse-keymap))
(keymap-set margins-map "f" 'my/resize-margins-to-fill) (keymap-set margins-map "f" 'my-resize-margins-to-fill)
(keymap-set margins-map "r" 'my/reset-margins) (keymap-set margins-map "r" 'my-reset-margins)
(keymap-set mode-specific-map "C-m" margins-map) (keymap-set mode-specific-map "C-m" margins-map)
(keymap-set mode-specific-map "b" 'my/insert-buffer-name) (keymap-set mode-specific-map "b" 'my-insert-buffer-name)
;;; 99-misc.el ends here ;;; 99-misc.el ends here

View File

@@ -1,7 +1,14 @@
;;; 99-my-ediprolog.el --- ediprolog extras -*- no-byte-compile: t; lexical-binding: t; -*- ;;; 99-my-ediprolog.el --- ediprolog extras -*- no-byte-compile: t; lexical-binding: t; -*-
(defun my/ediprolog-run-in-own-buffer ()
"Copy this query to another buffer and run it there" ;;; Commentary:
;; ediprolog is a very minimalist package, and I find myself needing to code
;; some functionality myself. Ergo, this file.
;;; Code:
(defun my-ediprolog-run-in-own-buffer ()
"Copy this query to another buffer and run it there."
(interactive) (interactive)
;; This is the same logic ediprolog uses to check if the point is on query. ;; This is the same logic ediprolog uses to check if the point is on query.
(when (and (not (and transient-mark-mode mark-active)) (when (and (not (and transient-mark-mode mark-active))
@@ -29,4 +36,51 @@
(ediprolog-dwim)))) (ediprolog-dwim))))
;; 99-my-ediprolog.el ends here (defun my-ediprolog-delete-next-comments ()
"Delete all commented lines after point (excluding the line under point).
Will continue until a line without a comment is encountered. See also
'ediprolog-dwim'."
(interactive)
(save-excursion
(beginning-of-line)
(next-line)
(while (looking-at "[ ]*%")
(delete-line))))
(defun my-ediprolog-return-to-closest-query ()
"Tries to set point to closest query (starts with ?-) preceding it."
(interactive)
(re-search-backward "\\([\t ]*%*[\t ]*[:?]- *\\)" nil t))
(defcustom my-ediprolog-system-types
'(("scryer-prolog" . (scryer . ("systemd-run" "--user" "--scope" "-p" "MemoryMax=2G" "-p" "MemoryHigh=1.9G" "scryer-prolog")))
("swi-prolog" . (swi . ("swipl"))))
"An alist of prolog systems and their respective run commands.
This has the form of form (NAME . TYPE . COMMAND). NAME is the display
name that user will be presented with, TYPE is one of swi or scryer, for
the two supported prolog systems respectively. COMMAND is a list, where
the first element is the command and the rest are arguments. See
'my-ediprolog-select-system'"
:type '(alist
:key-type string
:value-type (cons (choice (const :tag "Scryer Prolog" :value scryer)
(const :tag "SWI Prolog" :value swi))
(repeat string))))
(defun my-ediprolog-select-system (&optional system)
"Prompts the user to select a prolog SYSTEM and configures ediprolog to use it.
The prolog systems are defined in 'my-ediprolog-system-types'."
(interactive (list (completing-read "Select system:" my-ediprolog-system-types)))
(let ((pair (alist-get system my-ediprolog-system-types nil nil #'equal)))
(setq ediprolog-system (car pair))
(setq ediprolog-program (cadr pair))
(setq ediprolog-program-switches (cddr pair))))
(with-eval-after-load 'prolog
(keymap-set prolog-mode-map "C-c C-d" #'my-ediprolog-delete-next-comments)
(keymap-set prolog-mode-map "C-c C-b" #'my-ediprolog-return-to-closest-query))
;;; 99-my-ediprolog.el ends here

View File

@@ -3,7 +3,7 @@
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance. ;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right. ;; If there is more than one, they won't work right.
'(auth-source-save-behavior nil)) )
(custom-set-faces (custom-set-faces
;; custom-set-faces was added by Custom. ;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.