From afb6dc12acc0d3665d2315ee899fd49a985764b4 Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Sun, 25 Aug 2024 00:00:02 +0300 Subject: [PATCH] emacs: umlauts --- .emacs.d/init.el | 29 +++++++++++++++++++++++++++-- Emacs.org | 29 +++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 76af6bb..d6550ce 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -572,6 +572,29 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer." ;; (lambda () (setq visual-fill-column-center-text t))) ) +(defvar my/default-accents + '((a . ä) + (o . ö) + (u . ü) + (s . ß) + (A . Ä) + (O . Ö) + (U . Ü) + (S . ẞ))) + +(defun my/accent (arg) + (interactive "P") + (message "%s" arg) + (let* ((after? (eq accent-position 'after)) + (char (if after? (char-after) (char-before))) + (curr (intern (string char))) + (default-diac (cdr (assoc curr my/default-accents)))) + (if (and default-diac (not arg)) + (progn + (delete-char (if after? 1 -1)) + (insert (format "%c" default-diac))) + (call-interactively #'accent-company)))) + (use-package accent :straight (:host github :repo "eliascotto/accent") :init @@ -580,7 +603,7 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer." "gs" #'accent-company) (general-define-key :states '(normal insert) - "M-n" #'accent-company) + "M-n" #'my/accent) :commands (accent-menu) :config (general-define-key @@ -3277,7 +3300,7 @@ With ARG, repeats or can move backward if negative." (interactive) (let* ((files (thread-last - '("projects" "misc") + '("projects" "misc" "learning") (mapcar (lambda (f) (directory-files (concat org-directory "/" f) t (rx ".org" eos)))) (apply #'append) @@ -8971,6 +8994,8 @@ to `dired' if used interactively." (cond ((string-match-p (rx bos (? "CAPTURE-") (= 14 num) "-" (* not-newline) ".org" eos) name) "") + ((string-match-p (rx "german" (* not-newline) ".org" eos) name) + "") ((string-match-p (rx bos (+ num) "-" (+ num) "-" (+ num) ".org" eos) name) "") ((string-match-p (rx bos "EXWM") name) diff --git a/Emacs.org b/Emacs.org index 7f8b72f..2af8d7e 100644 --- a/Emacs.org +++ b/Emacs.org @@ -1039,6 +1039,29 @@ References: Input accented characters. #+begin_src emacs-lisp +(defvar my/default-accents + '((a . ä) + (o . ö) + (u . ü) + (s . ß) + (A . Ä) + (O . Ö) + (U . Ü) + (S . ẞ))) + +(defun my/accent (arg) + (interactive "P") + (message "%s" arg) + (let* ((after? (eq accent-position 'after)) + (char (if after? (char-after) (char-before))) + (curr (intern (string char))) + (default-diac (cdr (assoc curr my/default-accents)))) + (if (and default-diac (not arg)) + (progn + (delete-char (if after? 1 -1)) + (insert (format "%c" default-diac))) + (call-interactively #'accent-company)))) + (use-package accent :straight (:host github :repo "eliascotto/accent") :init @@ -1047,7 +1070,7 @@ Input accented characters. "gs" #'accent-company) (general-define-key :states '(normal insert) - "M-n" #'accent-company) + "M-n" #'my/accent) :commands (accent-menu) :config (general-define-key @@ -4538,7 +4561,7 @@ A function to open a file from =org-directory=, excluding a few directories like (interactive) (let* ((files (thread-last - '("projects" "misc") + '("projects" "misc" "learning") (mapcar (lambda (f) (directory-files (concat org-directory "/" f) t (rx ".org" eos)))) (apply #'append) @@ -12425,6 +12448,8 @@ Some functions to override the displayed message: (cond ((string-match-p (rx bos (? "CAPTURE-") (= 14 num) "-" (* not-newline) ".org" eos) name) "") + ((string-match-p (rx "german" (* not-newline) ".org" eos) name) + "") ((string-match-p (rx bos (+ num) "-" (+ num) "-" (+ num) ".org" eos) name) "") ((string-match-p (rx bos "EXWM") name)