Przeglądaj źródła

Started making myself a homebrew charmap.

It's vaguely a prototypical subset-based insert-char. I'd like later to
quickly insert specific character (or PUA character) without issues like
this.
Eiyeron Fulmincendii 6 lat temu
rodzic
commit
b8f72c9661
1 zmienionych plików z 43 dodań i 0 usunięć
  1. 43 0
      config.org

+ 43 - 0
config.org

@@ -386,6 +386,49 @@ more Doom Emacs' documentation to figure how and where to scope the mapping.
       :leader
       :desc "Everything" "sE" #'chicken/search-everything)
 #+END_SRC
+* TODO Character insertion
+** STRT Basic principle
+#+BEGIN_SRC emacs-lisp
+;; Note, I could build the list by concating the character's unicode name and itself.
+
+;; The variable that'll contain the character maps. A alist binding a symbol to
+;; an alist of name <-> symbols. Sadly, I couldn't figure how to avoid having
+;; character names to be strings. So the mapping will be a bit less readable for
+;; now.
+(setq chicken/unicode-helper-map '(
+                                   (misc . (("link" . )))))
+
+(defun chicken/get-character-map (id)
+  (cdr (assoc* id chicken/unicode-helper-map)))
+
+(defun chicken/get-character-from-map (character-map-id)
+  """Wrapper over a simple ivy-read call to automatically select
+the proper character map to list."""
+  (let* ((map (chicken/get-character-map character-map-id))
+         (entry (ivy-read
+                 "Prompt:"
+                 map
+                 :require-match t)))
+    (message (symbol-name (cdr (assoc entry map))))))
+
+(defun chicken/insert-user-character (id)
+"""Another level of wrapper. This one should be pretty much
+useable as-is as an user-editable replacement of insert-char
+after giving an argument."""
+  (insert-char
+   (string-to-char
+    (get-character-from-map id))))
+
+(defun chicken/create-user-character-inserter (id)
+  (lexical-let ((inner-id id))
+    #'(lambda () (interactive) (chicken/insert-user-character inner-id))))
+
+(chicken/insert-user-character 'misc)
+(map!  ; Add which-key description
+      :leader                           ; Use leader key from now on
+      :desc "Misc character insert" "iM" (chicken/create-user-character-inserter 'misc))
+#+END_SRC
+** TODO Pragmata's own characters
 * Unsorted Functions
 ** Search Everything with Everything
 [[https://www.voidtools.com/][Everything]] is a very useful tool for Windows that indexes all the available in